xref: /llvm-project/lld/test/ELF/relocatable-local-sym.s (revision a317afaf00b0b898538855c36c203bb9117d6b86)
1# REQUIRES: x86
2## Test relocations referencing non-STT_SECTION local symbols in SHF_ALLOC and non-SHF_ALLOC sections for -r.
3
4# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
5# RUN: ld.lld -r -o %t %t.o %t.o
6# RUN: llvm-readelf -r -x .nonalloc %t | FileCheck --check-prefix=RELA %s
7
8# RUN: llvm-mc -filetype=obj -triple=i686 --defsym X86_32=1 %s -o %t1.o
9# RUN: ld.lld -r -o %t1 %t1.o %t1.o
10# RUN: llvm-readelf -r -x .nonalloc %t1 | FileCheck --check-prefix=REL %s
11
12# RELA:       Relocation section '.rela.data' at offset {{.*}} contains 2 entries:
13# RELA:         Offset          Info         Type      Symbol's Value  Symbol's Name + Addend
14# RELA-NEXT:  0000000000000000  {{.*}} R_X86_64_32   0000000000000000 ifunc + 9
15# RELA-NEXT:  0000000000000004  {{.*}} R_X86_64_32   0000000000000004 ifunc + 9
16# RELA:       Relocation section '.rela.nonalloc' at offset {{.*}} contains 2 entries:
17# RELA:         Offset          Info         Type      Symbol's Value  Symbol's Name + Addend
18# RELA-NEXT:  0000000000000000  {{.*}} R_X86_64_32   0000000000000000 ifunc + 9
19# RELA-NEXT:  0000000000000004  {{.*}} R_X86_64_32   0000000000000004 ifunc + 9
20# RELA:       Hex dump of section '.nonalloc':
21# RELA-NEXT:  0x00000000 00000000 00000000                   ........
22
23# REL:         Offset   Info   Type         Sym. Value  Symbol's Name
24# REL-NEXT:  00000000  {{.*}} R_386_32        00000000   ifunc
25# REL-NEXT:  00000004  {{.*}} R_386_32        00000004   ifunc
26# REL-EMPTY:
27# REL:         Offset   Info   Type         Sym. Value  Symbol's Name
28# REL-NEXT:  00000000  {{.*}} R_386_32        00000000   ifunc
29# REL-NEXT:  00000004  {{.*}} R_386_32        00000004   ifunc
30# REL:       Hex dump of section '.nonalloc':
31# REL-NEXT:  0x00000000 09000000 09000000                   ........
32
33resolver: ret
34.type ifunc, @gnu_indirect_function
35.set ifunc, resolver
36
37.data
38.long ifunc+9
39
40.section .nonalloc
41## The relocation references ifunc instead of the STT_SECTION symbol.
42.long ifunc+9
43