Skip to content

Commit 561b98f

Browse files
committed
[ELF][test] Improve non-abs-reloc.s to test non-STT_SECTION local symbol
1 parent ab3cd07 commit 561b98f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lld/test/ELF/non-abs-reloc.s

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
// RUN: llvm-mc -filetype=obj -triple=i386 --defsym X86_32=1 asm -o a.o
44
// RUN: ld.lld -T lds a.o -o a 2>&1 | FileCheck %s --implicit-check-not=warning:
55
// CHECK: warning: {{.*}}.o:(.nonalloc1+0x1): has non-ABS relocation R_386_PC32 against symbol '_start'
6-
// CHECK-NEXT: warning: {{.*}}.o:(.nonalloc1+0x6): has non-ABS relocation R_386_PC32 against symbol '_start'
6+
// CHECK-NEXT: warning: {{.*}}.o:(.nonalloc1+0x6): has non-ABS relocation R_386_PC32 against symbol 'ifunc'
7+
// CHECK-NEXT: warning: {{.*}}.o:(.nonalloc1+0xa): has non-ABS relocation R_386_PC32 against symbol ''
78

89
// RUN: llvm-objdump -D --no-show-raw-insn a | FileCheck --check-prefix=DISASM %s
910
// DISASM: Disassembly of section .nonalloc:
1011
// DISASM-EMPTY:
1112
// DISASM-NEXT: <.nonalloc>:
1213
// DISASM-NEXT: 0: nop
1314
// DISASM-NEXT: 1: call{{.}} 0x0
14-
// DISASM-NEXT: 6: call{{.}} 0x0
15+
// DISASM-NEXT: 6: call{{.}} 0x5
1516

1617
/// There is currently no error for -r. See also https://github.com/ClangBuiltLinux/linux/issues/1937
1718
// RUN: ld.lld -T lds -r a.o -o /dev/null --fatal-warnings
@@ -21,7 +22,8 @@
2122
// RUN: llvm-objdump -D --no-show-raw-insn b | FileCheck --check-prefix=DISASM %s
2223
// RUN: ld.lld -T lds -r b.o -o /dev/null --fatal-warnings
2324
// CHECK2: warning: {{.*}}.o:(.nonalloc1+0x1): has non-ABS relocation R_X86_64_PC32 against symbol '_start'
24-
// CHECK2-NEXT: warning: {{.*}}.o:(.nonalloc1+0x6): has non-ABS relocation R_X86_64_PC32 against symbol '_start'
25+
// CHECK2-NEXT: warning: {{.*}}.o:(.nonalloc1+0x6): has non-ABS relocation R_X86_64_PC32 against symbol 'ifunc'
26+
// CHECK2-NEXT: warning: {{.*}}.o:(.nonalloc1+0xa): has non-ABS relocation R_X86_64_PC32 against symbol ''
2527

2628
//--- lds
2729
SECTIONS {
@@ -33,14 +35,19 @@ _start:
3335
.L0:
3436
nop
3537

38+
resolver: ret
39+
.type ifunc, @gnu_indirect_function
40+
.set ifunc, resolver
41+
3642
.section .nonalloc0
3743
nop
3844

3945
.section .nonalloc1
4046
.byte 0xe8
4147
.long _start - . - 4
4248
.byte 0xe8
43-
.long _start - . - 4
49+
.long ifunc - .
50+
.long .nonalloc0 - .
4451

4552
// GCC may relocate DW_AT_GNU_call_site_value with R_386_GOTOFF.
4653
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98946

0 commit comments

Comments
 (0)