]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ELF/gnu-ifunc-plt-i386.s
Vendor import of lld trunk r338150:
[FreeBSD/FreeBSD.git] / test / ELF / gnu-ifunc-plt-i386.s
1 // REQUIRES: x86
2 // RUN: llvm-mc -filetype=obj -triple=i686-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=i686-pc-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) .rel.plt {
13 // CHECK-NEXT:     0x1200C R_386_JUMP_SLOT bar2
14 // CHECK-NEXT:     0x12010 R_386_JUMP_SLOT zed2
15 // CHECK-NEXT:     0x12014 R_386_IRELATIVE
16 // CHECK-NEXT:     0x12018 R_386_IRELATIVE
17
18 // Check that IRELATIVE .got.plt entries point to ifunc resolver and not
19 // back to the plt entry + 6.
20 // GOTPLT: Contents of section .got.plt:
21 // GOTPLT:       12000 00300100 00000000 00000000 36100100
22 // GOTPLT-NEXT:  12010 46100100 00100100 01100100
23
24 // Check that the PLTRELSZ tag includes the IRELATIVE relocations
25 // CHECK: DynamicSection [
26 // CHECK:  0x00000002 PLTRELSZ             32 (bytes)
27
28 // Check that a PLT header is written and the ifunc entries appear last
29 // DISASM: Disassembly of section .text:
30 // DISASM-NEXT: foo:
31 // DISASM-NEXT:    11000:       c3      retl
32 // DISASM:      bar:
33 // DISASM-NEXT:    11001:       c3      retl
34 // DISASM:      _start:
35 // DISASM-NEXT:    11002:       e8 49 00 00 00          calll   73
36 // DISASM-NEXT:    11007:       e8 54 00 00 00          calll   84
37 // DISASM-NEXT:    1100c:       e8 1f 00 00 00          calll   31
38 // DISASM-NEXT:    11011:       e8 2a 00 00 00          calll   42
39 // DISASM-NEXT: Disassembly of section .plt:
40 // DISASM-NEXT: .plt:
41 // DISASM-NEXT:    11020:       ff 35 04 20 01 00       pushl   73732
42 // DISASM-NEXT:    11026:       ff 25 08 20 01 00       jmpl    *73736
43 // DISASM-NEXT:    1102c:       90      nop
44 // DISASM-NEXT:    1102d:       90      nop
45 // DISASM-NEXT:    1102e:       90      nop
46 // DISASM-NEXT:    1102f:       90      nop
47 // DISASM-NEXT:    11030:       ff 25 0c 20 01 00       jmpl    *73740
48 // DISASM-NEXT:    11036:       68 00 00 00 00          pushl   $0
49 // DISASM-NEXT:    1103b:       e9 e0 ff ff ff          jmp     -32 <.plt>
50 // DISASM-NEXT:    11040:       ff 25 10 20 01 00       jmpl    *73744
51 // DISASM-NEXT:    11046:       68 08 00 00 00          pushl   $8
52 // DISASM-NEXT:    1104b:       e9 d0 ff ff ff          jmp     -48 <.plt>
53 // DISASM-NEXT:    11050:       ff 25 14 20 01 00       jmpl    *73748
54 // DISASM-NEXT:    11056:       68 30 00 00 00          pushl   $48
55 // DISASM-NEXT:    1105b:       e9 e0 ff ff ff          jmp     -32 <.plt+0x20>
56 // DISASM-NEXT:    11060:       ff 25 18 20 01 00       jmpl    *73752
57 // DISASM-NEXT:    11066:       68 38 00 00 00          pushl   $56
58 // DISASM-NEXT:    1106b:       e9 d0 ff ff ff          jmp     -48 <.plt+0x20>
59
60 .text
61 .type foo STT_GNU_IFUNC
62 .globl foo
63 foo:
64  ret
65
66 .type bar STT_GNU_IFUNC
67 .globl bar
68 bar:
69  ret
70
71 .globl _start
72 _start:
73  call foo@plt
74  call bar@plt
75  call bar2@plt
76  call zed2@plt