[lld] cde37a7 - [ELF][test] Add tests for mixed GD-to-IE and IE, mixed TLSDESC and GD
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 24 22:24:20 PST 2021
Author: Fangrui Song
Date: 2021-12-24T22:24:15-08:00
New Revision: cde37a7e5a1fd3917ab8f66c8b61d86220afc581
URL: https://github.com/llvm/llvm-project/commit/cde37a7e5a1fd3917ab8f66c8b61d86220afc581
DIFF: https://github.com/llvm/llvm-project/commit/cde37a7e5a1fd3917ab8f66c8b61d86220afc581.diff
LOG: [ELF][test] Add tests for mixed GD-to-IE and IE, mixed TLSDESC and GD
Note: mixed TLSDESC and GD currently does not work.
Added:
lld/test/ELF/x86-64-tlsdesc-gd-mixed.s
Modified:
lld/test/ELF/x86-64-tls-ie.s
Removed:
################################################################################
diff --git a/lld/test/ELF/x86-64-tls-ie.s b/lld/test/ELF/x86-64-tls-ie.s
index e5510f84d5f35..8190c569f0fe8 100644
--- a/lld/test/ELF/x86-64-tls-ie.s
+++ b/lld/test/ELF/x86-64-tls-ie.s
@@ -4,7 +4,7 @@
// RUN: ld.lld -shared %t2.o -soname=so -o %t2.so
// RUN: ld.lld -e main %t1.o %t2.so -o %t3
// RUN: llvm-readobj -S -r %t3 | FileCheck %s
-// RUN: llvm-objdump -d %t3 | FileCheck --check-prefix=DISASM %s
+// RUN: llvm-objdump -d --no-show-raw-insn %t3 | FileCheck --check-prefix=DISASM %s
// CHECK: Section {
// CHECK: Index: 9
@@ -15,7 +15,7 @@
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
// CHECK-NEXT: Address: [[ADDR:.*]]
-// CHECK-NEXT: Offset: 0x3B0
+// CHECK-NEXT: Offset: 0x3F0
// CHECK-NEXT: Size: 16
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
@@ -26,23 +26,27 @@
// CHECK: Relocations [
// CHECK-NEXT: Section (5) .rela.dyn {
// CHECK-NEXT: [[ADDR]] R_X86_64_TPOFF64 tls1 0x0
-// CHECK-NEXT: 0x2023B8 R_X86_64_TPOFF64 tls0 0x0
+// CHECK-NEXT: 0x2023F8 R_X86_64_TPOFF64 tls0 0x0
// CHECK-NEXT: }
// CHECK-NEXT: ]
-// 0x2012d0 + 4313 + 7 = 0x2023B0
-// 0x2012dA + 4311 + 7 = 0x2023B8
-// 0x2012e4 + 4301 + 7 = 0x2023B8
+/// 0x2023F0 - 0x201307 = 4329
+/// 0x2023F8 - 0x201311 = 4327
+/// 0x2023F8 - 0x20131b = 4317
// DISASM: Disassembly of section .text:
// DISASM-EMPTY:
// DISASM-NEXT: <main>:
-// DISASM-NEXT: 2012d0: {{.*}} movq 4313(%rip), %rax
-// DISASM-NEXT: 2012d7: {{.*}} movl %fs:(%rax), %eax
-// DISASM-NEXT: 2012da: {{.*}} movq 4311(%rip), %rax
-// DISASM-NEXT: 2012e1: {{.*}} movl %fs:(%rax), %eax
-// DISASM-NEXT: 2012e4: {{.*}} movq 4301(%rip), %rax
-// DISASM-NEXT: 2012eb: {{.*}} movl %fs:(%rax), %eax
-// DISASM-NEXT: 2012ee: {{.*}} retq
+// DISASM-NEXT: movq 4329(%rip), %rax
+// DISASM-NEXT: 201307: movl %fs:(%rax), %eax
+// DISASM-NEXT: movq 4327(%rip), %rax
+// DISASM-NEXT: 201311: movl %fs:(%rax), %eax
+// DISASM-NEXT: movq 4317(%rip), %rax
+// DISASM-NEXT: 20131b: movl %fs:(%rax), %eax
+
+/// 0x2023F0 - 0x20132e = 4290
+// DISASM-NEXT: movq %fs:0, %rax
+// DISASM-NEXT: addq 4290(%rip), %rax
+// DISASM-NEXT: 20132e: retq
.section .tdata,"awT", at progbits
@@ -57,4 +61,11 @@ main:
movl %fs:0(%rax), %eax
movq tls0 at GOTTPOFF(%rip), %rax
movl %fs:0(%rax), %eax
+
+## Relaxed to TLS IE. Share the GOT entry with GOTTPOFF.
+ .byte 0x66
+ leaq tls1 at tlsgd(%rip), %rdi
+ .value 0x6666
+ rex64
+ call __tls_get_addr at PLT
ret
diff --git a/lld/test/ELF/x86-64-tlsdesc-gd-mixed.s b/lld/test/ELF/x86-64-tlsdesc-gd-mixed.s
new file mode 100644
index 0000000000000..f6bfe5bbba1cb
--- /dev/null
+++ b/lld/test/ELF/x86-64-tlsdesc-gd-mixed.s
@@ -0,0 +1,25 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
+# RUN: ld.lld -shared %t.o -o %t.so
+# RUN: llvm-readobj -r %t.so | FileCheck %s --check-prefix=RELA
+
+## FIXME Both TLSDESC and DTPMOD64/DTPOFF64 should be present.
+# RELA: .rela.dyn {
+# RELA-NEXT: 0x2430 R_X86_64_TLSDESC a 0x0
+# RELA-NEXT: }
+
+leaq a at tlsdesc(%rip), %rax
+call *a at tlscall(%rax)
+movl %fs:(%rax), %eax
+
+.byte 0x66
+leaq a at tlsgd(%rip), %rdi
+.word 0x6666
+rex64
+call __tls_get_addr at PLT
+
+.section .tbss
+.globl a
+.zero 8
+a:
+.zero 4
More information about the llvm-commits
mailing list