@@ -12,7 +12,7 @@ RUN: %objdump --no-show-raw-insn -M no-aliases -h -d %t.a.so | FileCheck %s --ch
1212## Test the TLSDESC to LE optimization. Also check --emit-relocs.
1313RUN: %link %linkopts -z now --no-align-segments --section-start .text=0x11000 %t.a.o %t.c.o -o %t.a.le --emit-relocs
1414RUN: %readelf --dyn-relocations %t.a.le | FileCheck %s --match-full-lines --allow-empty --check-prefix=LE-REL
15- RUN: %objdump --no-show-raw-insn -M no-aliases -hdr %t.a.le | FileCheck %s --check-prefix=LE
15+ RUN: %objdump --no-show-raw-insn -M no-aliases -hdr %t.a.le | FileCheck %s --check-prefix=LE --check-prefix=LER
1616
1717RUN: %link %linkopts -z now --no-align-segments --section-start .text=0x11000 %t.aa.o %t.c.o -o %t.aa.le
1818RUN: %objdump --no-show-raw-insn -M no-aliases -h -d %t.aa.le | FileCheck %s --check-prefix=LEA
@@ -22,6 +22,21 @@ RUN: %link %linkopts -z now --no-align-segments --section-start .text=0x11000 --
2222RUN: %readelf --dyn-relocations %t.a.ie | FileCheck %s --match-full-lines --check-prefix=IE-REL%xlen
2323RUN: %objdump --no-show-raw-insn -M no-aliases -h -d %t.a.ie | FileCheck %s --check-prefix=IE --check-prefix=IE%xlen
2424
25+ ## The same tests for executables are repeated with -pie, except for output static relocation checks as --emit-relocs does not work with -pie.
26+
27+ ## Test the TLSDESC to LE optimization. Also check --emit-relocs.
28+ RUN: %link %linkopts -pie -z now --keep-labels --no-align-segments --section-start .text=0x11000 %t.a.o %t.c.o -o %t.a.pie.le --emit-relocs
29+ RUN: %readelf --dyn-relocations %t.a.pie.le | FileCheck %s --match-full-lines --allow-empty --check-prefix=LE-REL
30+ RUN: %objdump --no-show-raw-insn -M no-aliases -hdr %t.a.pie.le | FileCheck %s --check-prefix=LE
31+
32+ RUN: %link %linkopts -pie -z now --keep-labels --no-align-segments --section-start .text=0x11000 %t.aa.o %t.c.o -o %t.aa.pie.le
33+ RUN: %objdump --no-show-raw-insn -M no-aliases -h -d %t.aa.pie.le | FileCheck %s --check-prefix=LEA
34+
35+ ## Test the TLSDESC to IE optimization.
36+ RUN: %link %linkopts -pie -z now --keep-labels --no-align-segments --section-start .text=0x11000 --section-start .got=0x120e0 %t.a.o %t.c.so -o %t.a.pie.ie
37+ RUN: %readelf --dyn-relocations %t.a.pie.ie | FileCheck %s --match-full-lines --check-prefix=IE-REL%xlen
38+ RUN: %objdump --no-show-raw-insn -M no-aliases -h -d %t.a.pie.ie | FileCheck %s --check-prefix=IE --check-prefix=IE%xlen
39+
2540## .got has 3 additional header slots before the TLS slot.
2641
2742GD4: .got {{0*}}14 {{0*}}20c0 DATA
@@ -79,49 +94,49 @@ LE-REL-NOT: R_RISCV
7994LE-LABEL: <foo>:
8095LE-NEXT: c.add a7, a7
8196LE-NEXT-LLD: R_RISCV_TLSDESC_HI20 b
82- LE -NEXT: R_RISCV_NONE b
83- LE -NEXT: R_RISCV_RELAX *ABS*
97+ LER -NEXT: R_RISCV_NONE b
98+ LER -NEXT: R_RISCV_RELAX *ABS*
8499LE-NEXT: c.add a7, a7
85100LE-NEXT-LLD: R_RISCV_TLSDESC_LOAD_LO12 .Ltlsdesc_hi0
86- LE -NEXT: R_RISCV_NONE b
87- LE -NEXT: R_RISCV_RELAX *ABS*
101+ LER -NEXT: R_RISCV_NONE b
102+ LER -NEXT: R_RISCV_RELAX *ABS*
88103LE-NEXT: 11008: c.add a7, a7
89104LE-NEXT-LLD: R_RISCV_TLSDESC_ADD_LO12 .Ltlsdesc_hi0
90- LE -NEXT: R_RISCV_NONE b
91- LE -NEXT: R_RISCV_RELAX *ABS*
105+ LER -NEXT: R_RISCV_NONE b
106+ LER -NEXT: R_RISCV_RELAX *ABS*
92107LE-NEXT: addi a0, zero, 0x7ff
93108LE-NEXT-LLD: R_RISCV_TLSDESC_CALL .Ltlsdesc_hi0
94- LE -NEXT: R_RISCV_LO12_I b
95- LE -NEXT: R_RISCV_RELAX *ABS*
109+ LER -NEXT: R_RISCV_LO12_I b
110+ LER -NEXT: R_RISCV_RELAX *ABS*
96111LE-NEXT: c.add a0, tp
97112
98113LE-LABEL: <.Ltlsdesc_hi1>:
99114LE-NEXT: addi a0, zero, 0x7ff
100115LE-NEXT-LLD: R_RISCV_TLSDESC_HI20 b
101- LE -NEXT: R_RISCV_NONE b
102- LE -NEXT: R_RISCV_RELAX *ABS*
116+ LER -NEXT: R_RISCV_NONE b
117+ LER -NEXT: R_RISCV_RELAX *ABS*
103118LE-NEXT-LLD: R_RISCV_TLSDESC_LOAD_LO12 .Ltlsdesc_hi1
104119LE-NEXT-LLD: R_RISCV_TLSDESC_ADD_LO12 .Ltlsdesc_hi1
105- LE -NEXT: R_RISCV_NONE b
106- LE -NEXT: R_RISCV_NONE b
120+ LER -NEXT: R_RISCV_NONE b
121+ LER -NEXT: R_RISCV_NONE b
107122LE-NEXT-LLD: R_RISCV_TLSDESC_CALL .Ltlsdesc_hi1
108- LE -NEXT: R_RISCV_LO12_I b
123+ LER -NEXT: R_RISCV_LO12_I b
109124LE-NEXT: c.add a0, tp
110125LE-LABEL: <.Ltlsdesc_hi2>:
111126LE-NEXT: addi zero, zero, 0x0
112- LE -NEXT-LLD: R_RISCV_TLSDESC_HI20 b
113- LE -NEXT: R_RISCV_NONE b
127+ LER -NEXT-LLD: R_RISCV_TLSDESC_HI20 b
128+ LER -NEXT: R_RISCV_NONE b
114129LE-NEXT: addi zero, zero, 0x0
115130LE-NEXT-LLD: R_RISCV_TLSDESC_LOAD_LO12 .Ltlsdesc_hi2
116- LE -NEXT: R_RISCV_NONE b
117- LE -NEXT: R_RISCV_RELAX *ABS*
131+ LER -NEXT: R_RISCV_NONE b
132+ LER -NEXT: R_RISCV_RELAX *ABS*
118133LE-NEXT: addi zero, zero, 0x0
119134LE-NEXT-LLD: R_RISCV_TLSDESC_ADD_LO12 .Ltlsdesc_hi2
120- LE -NEXT: R_RISCV_NONE b
121- LE -NEXT: R_RISCV_RELAX *ABS*
135+ LER -NEXT: R_RISCV_NONE b
136+ LER -NEXT: R_RISCV_RELAX *ABS*
122137LE-NEXT: addi a0, zero, 0x7ff
123138LE-NEXT-LLD: R_RISCV_TLSDESC_CALL .Ltlsdesc_hi2
124- LE -NEXT: R_RISCV_LO12_I b
139+ LER -NEXT: R_RISCV_LO12_I b
125140LE-NEXT: c.add a0, tp
126141
127142LEA-LABEL: <foo>:
0 commit comments