Skip to content

Commit a89e538

Browse files
quic-akaryakiquic-seaswara
authored andcommitted
[RISC-V] Duplicate TLSDESC tests for -pie
Signed-off-by: Alexey Karyakin <akaryaki@qti.qualcomm.com>
1 parent 3bcc013 commit a89e538

2 files changed

Lines changed: 45 additions & 21 deletions

File tree

test/lld/ELF/riscv-tlsdesc-relax.test

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
1313
RUN: %link %linkopts -z now --no-align-segments --section-start .text=0x11000 %t.a.o %t.c.o -o %t.a.le --emit-relocs
1414
RUN: %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

1717
RUN: %link %linkopts -z now --no-align-segments --section-start .text=0x11000 %t.aa.o %t.c.o -o %t.aa.le
1818
RUN: %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 --
2222
RUN: %readelf --dyn-relocations %t.a.ie | FileCheck %s --match-full-lines --check-prefix=IE-REL%xlen
2323
RUN: %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

2742
GD4: .got {{0*}}14 {{0*}}20c0 DATA
@@ -79,49 +94,49 @@ LE-REL-NOT: R_RISCV
7994
LE-LABEL: <foo>:
8095
LE-NEXT: c.add a7, a7
8196
LE-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*
8499
LE-NEXT: c.add a7, a7
85100
LE-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*
88103
LE-NEXT: 11008: c.add a7, a7
89104
LE-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*
92107
LE-NEXT: addi a0, zero, 0x7ff
93108
LE-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*
96111
LE-NEXT: c.add a0, tp
97112

98113
LE-LABEL: <.Ltlsdesc_hi1>:
99114
LE-NEXT: addi a0, zero, 0x7ff
100115
LE-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*
103118
LE-NEXT-LLD: R_RISCV_TLSDESC_LOAD_LO12 .Ltlsdesc_hi1
104119
LE-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
107122
LE-NEXT-LLD: R_RISCV_TLSDESC_CALL .Ltlsdesc_hi1
108-
LE-NEXT: R_RISCV_LO12_I b
123+
LER-NEXT: R_RISCV_LO12_I b
109124
LE-NEXT: c.add a0, tp
110125
LE-LABEL: <.Ltlsdesc_hi2>:
111126
LE-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
114129
LE-NEXT: addi zero, zero, 0x0
115130
LE-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*
118133
LE-NEXT: addi zero, zero, 0x0
119134
LE-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*
122137
LE-NEXT: addi a0, zero, 0x7ff
123138
LE-NEXT-LLD: R_RISCV_TLSDESC_CALL .Ltlsdesc_hi2
124-
LE-NEXT: R_RISCV_LO12_I b
139+
LER-NEXT: R_RISCV_LO12_I b
125140
LE-NEXT: c.add a0, tp
126141

127142
LEA-LABEL: <foo>:

test/lld/ELF/riscv-tlsdesc.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ RUN: %link %linkopts --no-emit-relocs --keep-labels --no-align-segments --sectio
1616
RUN: llvm-readobj -r %t.a.ie | FileCheck --check-prefix=IE-RELA%xlen %s
1717
RUN: %objdump --no-show-raw-insn -M no-aliases -h -d %t.a.ie | FileCheck %s --check-prefix=IE --check-prefix=IE%xlen
1818

19+
## The same tests for executables are repeated with -pie.
20+
RUN: %link %linkopts --no-emit-relocs -pie --keep-labels --no-align-segments --section-start .text=0x1800 -z now %t.a.o %t.c.o -o %t.a.pie.le
21+
RUN: %readelf -r %t.a.pie.le | FileCheck --check-prefix=NOREL %s
22+
RUN: %objdump --no-show-raw-insn -M no-aliases -h -d %t.a.pie.le | FileCheck %s --check-prefix=LE
23+
24+
RUN: %link %linkopts --no-emit-relocs -pie --keep-labels --no-align-segments --section-start .text=0x1800 --section-start .got=0x2880 -z now %t.a.o %t.c.so -o %t.a.pie.ie
25+
RUN: llvm-readobj -r %t.a.pie.ie | FileCheck --check-prefix=IE-RELA%xlen %s
26+
RUN: %objdump --no-show-raw-insn -M no-aliases -h -d %t.a.pie.ie | FileCheck %s --check-prefix=IE --check-prefix=IE%xlen
27+
1928
## Prior to https://github.com/llvm/llvm-project/pull/85817 the local TLSDESC
2029
## labels would be marked STT_TLS, resulting in an error "has an STT_TLS symbol but doesn't have an SHF_TLS section"
2130

0 commit comments

Comments
 (0)