• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// REQUIRES: x86
2// RUN: llvm-mc -filetype=obj -triple=i686-pc-freebsd %S/Inputs/shared2-x86-64.s -o %t1.o
3// RUN: ld.lld %t1.o --shared --soname=t.so -o %t.so
4// RUN: llvm-mc -filetype=obj -triple=i686-pc-freebsd %s -o %t.o
5// RUN: ld.lld -z ifunc-noplt -z notext --hash-style=sysv %t.so %t.o -o %tout
6// RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %tout | FileCheck %s --check-prefix=DISASM
7// RUN: llvm-readobj -r --dynamic-table %tout | FileCheck %s
8
9// Check that we emitted relocations for the ifunc calls
10// CHECK: Relocations [
11// CHECK-NEXT:   Section (4) .rel.dyn {
12// CHECK-NEXT:     0x4011F4 R_386_PLT32 bar
13// CHECK-NEXT:     0x4011EF R_386_PLT32 foo
14// CHECK-NEXT:   }
15// CHECK-NEXT:   Section (5) .rel.plt {
16// CHECK-NEXT:     0x4032D4 R_386_JUMP_SLOT bar2
17// CHECK-NEXT:     0x4032D8 R_386_JUMP_SLOT zed2
18// CHECK-NEXT:   }
19
20// Check that ifunc call sites still require relocation
21// DISASM: Disassembly of section .text:
22// DISASM-EMPTY:
23// DISASM-NEXT: 004011ec <foo>:
24// DISASM-NEXT:   retl
25// DISASM-EMPTY:
26// DISASM-NEXT: 004011ed <bar>:
27// DISASM-NEXT:   retl
28// DISASM-EMPTY:
29// DISASM-NEXT: 004011ee <_start>:
30// DISASM-NEXT:   calll	0x4011ef <_start+0x1>
31// DISASM-NEXT:   calll	0x4011f4 <_start+0x6>
32// DISASM-NEXT:   calll	0x401220 <bar2@plt>
33// DISASM-NEXT:   calll	0x401230 <zed2@plt>
34// DISASM-EMPTY:
35// DISASM-NEXT: Disassembly of section .plt:
36// DISASM-EMPTY:
37// DISASM-NEXT: 00401210 <.plt>:
38// DISASM-NEXT:   pushl 0x4032cc
39// DISASM-NEXT:   jmpl *0x4032d0
40// DISASM-NEXT:   nop
41// DISASM-NEXT:   nop
42// DISASM-NEXT:   nop
43// DISASM-NEXT:   nop
44// DISASM-EMPTY:
45// DISASM-NEXT: 00401220 <bar2@plt>:
46// DISASM-NEXT:   jmpl	*0x4032d4
47// DISASM-NEXT:   pushl	$0x0
48// DISASM-NEXT:   jmp	0x401210 <.plt>
49// DISASM-EMPTY:
50// DISASM-NEXT: 00401230 <zed2@plt>:
51// DISASM-NEXT:   jmpl	*0x4032d8
52// DISASM-NEXT:   pushl	$0x8
53// DISASM-NEXT:   jmp	0x401210 <.plt>
54
55.text
56.type foo STT_GNU_IFUNC
57.globl foo
58foo:
59 ret
60
61.type bar STT_GNU_IFUNC
62.globl bar
63bar:
64 ret
65
66.globl _start
67_start:
68 call foo@plt
69 call bar@plt
70 call bar2@plt
71 call zed2@plt
72