[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / gnu-ifunc-nonpreemptible.s
blobf3f90083cebb22354854c5c7d7e47742c14c51a0
1 # REQUIRES: x86
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
7 # RUN: ld.lld a.o -o a
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:
12 # CHECK-NEXT: Type
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:
38 # DISASM-EMPTY:
39 # DISASM-NEXT: <qux>:
40 # DISASM: <foo>:
41 # DISASM: <bar>:
42 # DISASM: <unused>:
43 # DISASM: <_start>:
44 # DISASM-NEXT: callq 0x[[#%x,foo:]]
45 # DISASM-NEXT: callq 0x[[#%x,bar:]]
46 # DISASM-NEXT: callq 0x[[#%x,qux:]]
47 # DISASM-EMPTY:
48 # DISASM-NEXT: Disassembly of section .iplt:
49 # DISASM-EMPTY:
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
61 #--- a.s
62 .globl qux, foo, bar
63 .type qux, @gnu_indirect_function
64 .type foo STT_GNU_IFUNC
65 .type bar STT_GNU_IFUNC
66 qux: ret
67 foo: ret
68 bar: ret
70 .type unused, @gnu_indirect_function
71 .globl unused
72 .weak ext
73 unused: mov ext@gotpcrel(%rip), %rax
75 .weak __rela_iplt_start
76 .weak __rela_iplt_end
78 .globl _start
79 _start:
80 call foo
81 call bar
82 call qux
84 .data
85 .quad __rela_iplt_start
86 .quad __rela_iplt_end
87 .quad .data
89 #--- b.s
90 .globl ext
91 ext:
92 ret