[clang-tidy][modernize-use-starts-ends-with] Fix operator rewriting false negative...
[llvm-project.git] / lld / test / ELF / aarch64-gnu-ifunc-nonpreemptable.s
blob8598f419baee9582d1a32e6a343745f6b4a77528
1 # REQUIRES: aarch64
2 # RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o
4 # RUN: ld.lld --no-relax %t.o -o %t
5 # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t | FileCheck %s --check-prefix=PDE
6 # RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=PDE-RELOC
8 # RUN: ld.lld -pie --no-relax %t.o -o %t
9 # RUN: ld.lld -pie --no-relax --apply-dynamic-relocs %t.o -o %t.apply
10 # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t | FileCheck %s --check-prefix=PIE
11 # RUN: llvm-readobj -r -x .got.plt %t | FileCheck %s --check-prefixes=PIE-RELOC,NO-APPLY
12 # RUN: llvm-readobj -r -x .got.plt %t.apply | FileCheck %s --check-prefixes=PIE-RELOC,APPLY
14 ## When compiling with -fno-PIE or -fPIE, if the ifunc is in the same
15 ## translation unit as the address taker, the compiler knows that ifunc is not
16 ## defined in a shared library so it can use a non GOT generating relative reference.
17 .text
18 .globl myfunc
19 .type myfunc,@gnu_indirect_function
20 myfunc:
21 .globl myfunc_resolver
22 .type myfunc_resolver,@function
23 myfunc_resolver:
24 ret
26 .text
27 .globl main
28 .type main,@function
29 main:
30 adrp x8, myfunc
31 add x8, x8, :lo12: myfunc
32 ret
34 ## The address of myfunc is the address of the PLT entry for myfunc.
35 # PDE: <myfunc_resolver>:
36 # PDE-NEXT: 210170: ret
37 # PDE: <main>:
38 # PDE-NEXT: 210174: adrp x8, 0x210000
39 # PDE-NEXT: 210178: add x8, x8, #384
40 # PDE-NEXT: 21017c: ret
41 # PDE-EMPTY:
42 # PDE-NEXT: Disassembly of section .iplt:
43 # PDE-EMPTY:
44 # PDE-NEXT: <myfunc>:
45 ## page(.got.plt) - page(0x210010) = 65536
46 # PDE-NEXT: 210180: adrp x16, 0x220000
47 # PDE-NEXT: 210184: ldr x17, [x16, #400]
48 # PDE-NEXT: 210188: add x16, x16, #400
49 # PDE-NEXT: 21018c: br x17
51 ## The adrp to myfunc should generate a PLT entry and a GOT entry with an
52 ## irelative relocation.
53 # PDE-RELOC: .rela.dyn {
54 # PDE-RELOC-NEXT: 0x220190 R_AARCH64_IRELATIVE - 0x210170
55 # PDE-RELOC-NEXT: }
57 # PIE: <myfunc_resolver>:
58 # PIE-NEXT: 10260: ret
59 # PIE: <main>:
60 # PIE-NEXT: 10264: adrp x8, 0x10000
61 # PIE-NEXT: 10268: add x8, x8, #624
62 # PIE-NEXT: 1026c: ret
63 # PIE-EMPTY:
64 # PIE-NEXT: Disassembly of section .iplt:
65 # PIE-EMPTY:
66 # PIE-NEXT: <myfunc>:
67 # PIE-NEXT: 10270: adrp x16, 0x30000
68 # PIE-NEXT: ldr x17, [x16, #832]
69 # PIE-NEXT: add x16, x16, #832
70 # PIE-NEXT: br x17
72 # PIE-RELOC: .rela.dyn {
73 # PIE-RELOC-NEXT: 0x30340 R_AARCH64_IRELATIVE - 0x10260
74 # PIE-RELOC-NEXT: }
75 # PIE-RELOC: Hex dump of section '.got.plt':
76 # NO-APPLY: 0x00030340 00000000 00000000
77 # APPLY: 0x00030340 60020100 00000000
78 # PIE-RELOC-EMPTY: