]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ELF/gnu-ifunc-plt.s
Vendor import of lld trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / test / ELF / gnu-ifunc-plt.s
1 // REQUIRES: x86
2 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/shared2-x86-64.s -o %t1.o
3 // RUN: ld.lld %t1.o --shared -o %t.so
4 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
5 // RUN: ld.lld --hash-style=sysv %t.so %t.o -o %tout
6 // RUN: llvm-objdump -d %tout | FileCheck %s --check-prefix=DISASM
7 // RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT
8 // RUN: llvm-readobj -r -dynamic-table %tout | FileCheck %s
9
10 // Check that the IRELATIVE relocations are after the JUMP_SLOT in the plt
11 // CHECK: Relocations [
12 // CHECK-NEXT:   Section (4) .rela.plt {
13 // CHECK-NEXT:     0x202018 R_X86_64_JUMP_SLOT bar2 0x0
14 // CHECK-NEXT:     0x202020 R_X86_64_JUMP_SLOT zed2 0x0
15 // CHECK-NEXT:     0x202028 R_X86_64_IRELATIVE - 0x201000
16 // CHECK-NEXT:     0x202030 R_X86_64_IRELATIVE - 0x201001
17
18 // Check that .got.plt entries point back to PLT header
19 // GOTPLT: Contents of section .got.plt:
20 // GOTPLT-NEXT:  202000 00302000 00000000 00000000 00000000
21 // GOTPLT-NEXT:  202010 00000000 00000000 36102000 00000000
22 // GOTPLT-NEXT:  202020 46102000 00000000 56102000 00000000
23 // GOTPLT-NEXT:  202030 66102000 00000000
24
25 // Check that the PLTRELSZ tag includes the IRELATIVE relocations
26 // CHECK: DynamicSection [
27 // CHECK:   0x0000000000000002 PLTRELSZ             96 (bytes)
28
29 // Check that a PLT header is written and the ifunc entries appear last
30 // DISASM: Disassembly of section .text:
31 // DISASM-NEXT: foo:
32 // DISASM-NEXT:   201000:       c3      retq
33 // DISASM:      bar:
34 // DISASM-NEXT:   201001:       c3      retq
35 // DISASM:      _start:
36 // DISASM-NEXT:   201002:       e8 49 00 00 00          callq   73
37 // DISASM-NEXT:   201007:       e8 54 00 00 00          callq   84
38 // DISASM-NEXT:   20100c:       e8 1f 00 00 00          callq   31
39 // DISASM-NEXT:   201011:       e8 2a 00 00 00          callq   42
40 // DISASM-NEXT: Disassembly of section .plt:
41 // DISASM-NEXT: .plt:
42 // DISASM-NEXT:   201020:       ff 35 e2 0f 00 00       pushq   4066(%rip)
43 // DISASM-NEXT:   201026:       ff 25 e4 0f 00 00       jmpq    *4068(%rip)
44 // DISASM-NEXT:   20102c:       0f 1f 40 00     nopl    (%rax)
45 // DISASM-EMPTY:
46 // DISASM-NEXT:   bar2@plt:
47 // DISASM-NEXT:   201030:       ff 25 e2 0f 00 00       jmpq    *4066(%rip)
48 // DISASM-NEXT:   201036:       68 00 00 00 00          pushq   $0
49 // DISASM-NEXT:   20103b:       e9 e0 ff ff ff          jmp     -32 <.plt>
50 // DISASM-EMPTY:
51 // DISASM-NEXT:   zed2@plt:
52 // DISASM-NEXT:   201040:       ff 25 da 0f 00 00       jmpq    *4058(%rip)
53 // DISASM-NEXT:   201046:       68 01 00 00 00          pushq   $1
54 // DISASM-NEXT:   20104b:       e9 d0 ff ff ff          jmp     -48 <.plt>
55 // DISASM-NEXT:   201050:       ff 25 d2 0f 00 00       jmpq    *4050(%rip)
56 // DISASM-NEXT:   201056:       68 00 00 00 00          pushq   $0
57 // DISASM-NEXT:   20105b:       e9 e0 ff ff ff          jmp     -32 <zed2@plt>
58 // DISASM-NEXT:   201060:       ff 25 ca 0f 00 00       jmpq    *4042(%rip)
59 // DISASM-NEXT:   201066:       68 01 00 00 00          pushq   $1
60 // DISASM-NEXT:   20106b:       e9 d0 ff ff ff          jmp     -48 <zed2@plt>
61
62 .text
63 .type foo STT_GNU_IFUNC
64 .globl foo
65 foo:
66  ret
67
68 .type bar STT_GNU_IFUNC
69 .globl bar
70 bar:
71  ret
72
73 .globl _start
74 _start:
75  call foo
76  call bar
77  call bar2
78  call zed2