diff options
author | Fangrui Song <i@maskray.me> | 2022-10-16 21:55:38 +0300 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2022-10-16 21:55:38 +0300 |
commit | 8800869337e437783d0e5ceeed450f05622efa66 (patch) | |
tree | bb7b2389520d1c65c8337602e36cfc20fc3bba8d /lld | |
parent | 986ca95e064b095b808eee18e6434f51b38eba5b (diff) |
[ELF][test] Improve AArch64 TLS IE tests
Diffstat (limited to 'lld')
-rw-r--r-- | lld/test/ELF/aarch64-tls-ie.s | 78 | ||||
-rw-r--r-- | lld/test/ELF/aarch64-tls-iele.s | 38 |
2 files changed, 37 insertions, 79 deletions
diff --git a/lld/test/ELF/aarch64-tls-ie.s b/lld/test/ELF/aarch64-tls-ie.s index bd6ec5ea541e..c1b4dce9653d 100644 --- a/lld/test/ELF/aarch64-tls-ie.s +++ b/lld/test/ELF/aarch64-tls-ie.s @@ -1,48 +1,44 @@ # REQUIRES: aarch64 -# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %p/Inputs/aarch64-tls-ie.s -o %tdso.o -# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %s -o %tmain.o -# RUN: ld.lld -shared -soname=tdso.so %tdso.o -o %tdso.so -# RUN: ld.lld --hash-style=sysv %tmain.o %tdso.so -o %tout -# RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck %s -# RUN: llvm-readobj -S -r %tout | FileCheck -check-prefix=RELOC %s +# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o +# RUN: ld.lld -shared %t.o -o %t.so +# RUN: llvm-readobj -d -r %t.so | FileCheck %s --check-prefix=IE-REL +# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t.so | FileCheck %s --check-prefix=IE -# RELOC: Section { -# RELOC: Index: -# RELOC: Name: .got -# RELOC-NEXT: Type: SHT_PROGBITS -# RELOC-NEXT: Flags [ -# RELOC-NEXT: SHF_ALLOC -# RELOC-NEXT: SHF_WRITE -# RELOC-NEXT: ] -# RELOC-NEXT: Address: 0x220338 -# RELOC-NEXT: Offset: 0x338 -# RELOC-NEXT: Size: 16 -# RELOC-NEXT: Link: 0 -# RELOC-NEXT: Info: 0 -# RELOC-NEXT: AddressAlignment: 8 -# RELOC-NEXT: EntrySize: 0 -# RELOC-NEXT: } -# RELOC: Relocations [ -# RELOC-NEXT: Section ({{.*}}) .rela.dyn { -# RELOC-NEXT: 0x220338 R_AARCH64_TLS_TPREL64 bar 0x0 -# RELOC-NEXT: 0x220340 R_AARCH64_TLS_TPREL64 foo 0x0 -# RELOC-NEXT: } -# RELOC-NEXT:] +# RUN: ld.lld %t.o -o %t +# RUN: llvm-readobj -d -r %t | FileCheck %s --check-prefix=LE-REL +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s --check-prefix=LE -## Page(0x2200B0) - Page(0x210000) = 0x10000 = 65536 -## 0x2200B0 & 0xff8 = 0xB0 = 176 -## Page(0x2200B8) - Page(0x210000) = 0x10000 = 65536 -## 0x2200B8 & 0xff8 = 0xB8 = 184 -# CHECK: <_start>: -# CHECK-NEXT: 210278: adrp x0, 0x220000 -# CHECK-NEXT: 21027c: ldr x0, [x0, #824] -# CHECK-NEXT: 210280: adrp x0, 0x220000 -# CHECK-NEXT: 210284: ldr x0, [x0, #832] +# IE-REL: .rela.dyn { +# IE-REL-NEXT: 0x20380 R_AARCH64_TLS_TPREL64 - 0xC +# IE-REL-NEXT: 0x20378 R_AARCH64_TLS_TPREL64 a 0x0 +# IE-REL-NEXT: } + +# IE: adrp x0, 0x20000 +# IE-NEXT: ldr x0, [x0, #0x378] +# IE-NEXT: adrp x1, 0x20000 +# IE-NEXT: ldr x1, [x1, #0x380] + +# LE-REL-NOT: FLAGS +# LE-REL: Relocations [ +# LE-REL-NEXT: ] + +## TP is followed by a gap of 2 words, followed by alignment padding (empty in this case), then the static TLS blocks. +## a's offset is 16+8=24. +# LE: movz x0, #0, lsl #16 +# LE-NEXT: movk x0, #24 +# LE-NEXT: movz x1, #0, lsl #16 +# LE-NEXT: movk x1, #28 .globl _start _start: - adrp x0, :gottprel:bar - ldr x0, [x0, #:gottprel_lo12:bar] + adrp x0, :gottprel:a + ldr x0, [x0, #:gottprel_lo12:a] + adrp x1, :gottprel:b + ldr x1, [x1, #:gottprel_lo12:b] - adrp x0, :gottprel:foo - ldr x0, [x0, #:gottprel_lo12:foo] +.section .tbss,"awT",%nobits +.globl a +.zero 8 +a: +.zero 4 +b: diff --git a/lld/test/ELF/aarch64-tls-iele.s b/lld/test/ELF/aarch64-tls-iele.s deleted file mode 100644 index a40575b54f90..000000000000 --- a/lld/test/ELF/aarch64-tls-iele.s +++ /dev/null @@ -1,38 +0,0 @@ -# REQUIRES: aarch64 -# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-linux %p/Inputs/aarch64-tls-ie.s -o %ttlsie.o -# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-linux %s -o %tmain.o -# RUN: ld.lld %tmain.o %ttlsie.o -o %tout -# RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck %s -# RUN: llvm-readobj -r %tout | FileCheck -check-prefix=RELOC %s - -# RUN: ld.lld -pie %tmain.o %ttlsie.o -o %tout -# RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck %s -# RUN: llvm-readobj -r %tout | FileCheck -check-prefix=RELOC %s - -# Initial-Exec to Local-Exec relax creates no dynamic relocations. -# RELOC: Relocations [ -# RELOC-NEXT: ] - -# TCB size = 0x16 and foo is first element from TLS register. -# CHECK: Disassembly of section .text: -# CHECK-EMPTY: -# CHECK: <_start>: -# CHECK-NEXT: movz x0, #0, lsl #16 -# CHECK-NEXT: movk x0, #20 -# CHECK-NEXT: movz x0, #0, lsl #16 -# CHECK-NEXT: movk x0, #16 - -.section .tdata -.align 2 -.type foo_local, %object -.size foo_local, 4 -foo_local: -.word 5 -.text - -.globl _start -_start: - adrp x0, :gottprel:foo - ldr x0, [x0, :gottprel_lo12:foo] - adrp x0, :gottprel:foo_local - ldr x0, [x0, :gottprel_lo12:foo_local] |