150
|
1 # REQUIRES: aarch64
|
|
2 # RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o
|
|
3
|
|
4 # RUN: ld.lld %t.o -o %t
|
|
5 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s --check-prefix=PDE
|
|
6 # RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=PDE-RELOC
|
|
7
|
|
8 # RUN: ld.lld -pie %t.o -o %t
|
|
9 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s --check-prefix=PIE
|
|
10 # RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=PIE-RELOC
|
|
11
|
|
12 ## When compiling with -fno-PIE or -fPIE, if the ifunc is in the same
|
|
13 ## translation unit as the address taker, the compiler knows that ifunc is not
|
|
14 ## defined in a shared library so it can use a non GOT generating relative reference.
|
|
15 .text
|
|
16 .globl myfunc
|
|
17 .type myfunc,@gnu_indirect_function
|
|
18 myfunc:
|
|
19 .globl myfunc_resolver
|
|
20 .type myfunc_resolver,@function
|
|
21 myfunc_resolver:
|
|
22 ret
|
|
23
|
|
24 .text
|
|
25 .globl main
|
|
26 .type main,@function
|
|
27 main:
|
|
28 adrp x8, myfunc
|
|
29 add x8, x8, :lo12: myfunc
|
|
30 ret
|
|
31
|
|
32 ## The address of myfunc is the address of the PLT entry for myfunc.
|
173
|
33 # PDE: <myfunc_resolver>:
|
150
|
34 # PDE-NEXT: 210170: ret
|
173
|
35 # PDE: <main>:
|
150
|
36 # PDE-NEXT: 210174: adrp x8, #0
|
|
37 # PDE-NEXT: 210178: add x8, x8, #384
|
|
38 # PDE-NEXT: 21017c: ret
|
|
39 # PDE-EMPTY:
|
|
40 # PDE-NEXT: Disassembly of section .iplt:
|
|
41 # PDE-EMPTY:
|
173
|
42 # PDE-NEXT: <myfunc>:
|
150
|
43 ## page(.got.plt) - page(0x210010) = 65536
|
|
44 # PDE-NEXT: 210180: adrp x16, #65536
|
|
45 # PDE-NEXT: 210184: ldr x17, [x16, #400]
|
|
46 # PDE-NEXT: 210188: add x16, x16, #400
|
|
47 # PDE-NEXT: 21018c: br x17
|
|
48
|
|
49 ## The adrp to myfunc should generate a PLT entry and a GOT entry with an
|
|
50 ## irelative relocation.
|
|
51 # PDE-RELOC: .rela.dyn {
|
|
52 # PDE-RELOC-NEXT: 0x220190 R_AARCH64_IRELATIVE - 0x210170
|
|
53 # PDE-RELOC-NEXT: }
|
|
54
|
173
|
55 # PIE: <myfunc_resolver>:
|
150
|
56 # PIE-NEXT: 10260: ret
|
173
|
57 # PIE: <main>:
|
150
|
58 # PIE-NEXT: 10264: adrp x8, #0
|
|
59 # PIE-NEXT: 10268: add x8, x8, #624
|
|
60 # PIE-NEXT: 1026c: ret
|
|
61 # PIE-EMPTY:
|
|
62 # PIE-NEXT: Disassembly of section .iplt:
|
|
63 # PIE-EMPTY:
|
173
|
64 # PIE-NEXT: <myfunc>:
|
150
|
65 # PIE-NEXT: 10270: adrp x16, #131072
|
|
66 # PIE-NEXT: 10274: ldr x17, [x16, #880]
|
|
67 # PIE-NEXT: 10278: add x16, x16, #880
|
|
68 # PIE-NEXT: 1027c: br x17
|
|
69
|
|
70 # PIE-RELOC: .rela.dyn {
|
|
71 # PIE-RELOC-NEXT: 0x30370 R_AARCH64_IRELATIVE - 0x10260
|
|
72 # PIE-RELOC-NEXT: }
|