2 # RUN: rm -rf %t && split-file %s %t && cd %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64 b.s -o b.o
5 # RUN: ld.lld -shared -soname=b.so b.o -o b.so
8 # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn a | FileCheck %s --check-prefix=DISASM
9 # RUN: llvm-readelf -r -s a | FileCheck %s
11 # CHECK: Relocation section '.rela.dyn' at offset {{.*}} contains 3 entries:
13 # CHECK-NEXT: {{0*}}[[#%x,O:]] [[#%x,]] R_X86_64_IRELATIVE [[#%x,QUX:]]
14 # CHECK-NEXT: {{0*}}[[#O+8]] [[#%x,]] R_X86_64_IRELATIVE
15 # CHECK-NEXT: {{0*}}[[#O+16]] [[#%x,]] R_X86_64_IRELATIVE
17 # CHECK: 0 NOTYPE LOCAL HIDDEN [[#]] __rela_iplt_start
18 # CHECK-NEXT: 0 NOTYPE LOCAL HIDDEN [[#]] __rela_iplt_end
19 # CHECK-NEXT: {{0*}}[[#QUX]] 0 IFUNC GLOBAL DEFAULT [[#]] qux
21 # RUN: ld.lld -pie a.o b.so -o a1
22 # RUN: llvm-readelf -rs a1 | FileCheck %s --check-prefixes=PIC,PIE
23 # RUN: ld.lld -shared a.o b.so -o a2
24 # RUN: llvm-readelf -rs a2 | FileCheck %s --check-prefix=PIC
26 # PIC: {{0*}}[[#%x,O:]] [[#%x,]] R_X86_64_RELATIVE
27 # PIC-NEXT: R_X86_64_GLOB_DAT 0000000000000000 ext + 0
28 # PIC-NEXT: {{0*}}[[#O-16]] [[#%x,]] R_X86_64_64 0000000000000000 __rela_iplt_start + 0
29 # PIC-NEXT: {{0*}}[[#O-8]] [[#%x,]] R_X86_64_64 0000000000000000 __rela_iplt_end + 0
30 # PIE-NEXT: {{0*}}[[#O+8]] [[#%x,]] R_X86_64_IRELATIVE
31 # PIE-NEXT: {{0*}}[[#O+16]] [[#%x,]] R_X86_64_IRELATIVE
32 # PIE-NEXT: {{0*}}[[#O+24]] [[#%x,]] R_X86_64_IRELATIVE
34 # PIC: 0 NOTYPE WEAK DEFAULT UND __rela_iplt_start
35 # PIC-NEXT: 0 NOTYPE WEAK DEFAULT UND __rela_iplt_end
37 # DISASM: Disassembly of section .text:
44 # DISASM-NEXT: callq 0x[[#%x,foo:]]
45 # DISASM-NEXT: callq 0x[[#%x,bar:]]
46 # DISASM-NEXT: callq 0x[[#%x,qux:]]
48 # DISASM-NEXT: Disassembly of section .iplt:
50 # DISASM-NEXT: <.iplt>:
51 # DISASM-NEXT: [[#qux]]: jmpq *{{.*}}(%rip)
52 # DISASM-NEXT: pushq $0
53 # DISASM-NEXT: jmp 0x0
54 # DISASM-NEXT: [[#foo]]: jmpq *{{.*}}(%rip)
55 # DISASM-NEXT: pushq $1
56 # DISASM-NEXT: jmp 0x0
57 # DISASM-NEXT: [[#bar]]: jmpq *{{.*}}(%rip)
58 # DISASM-NEXT: pushq $2
59 # DISASM-NEXT: jmp 0x0
63 .type qux, @gnu_indirect_function
64 .type foo STT_GNU_IFUNC
65 .type bar STT_GNU_IFUNC
70 .type unused, @gnu_indirect_function
73 unused
: mov ext@gotpcrel
(%rip
), %rax
75 .weak __rela_iplt_start
85 .quad __rela_iplt_start