• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// REQUIRES: x86
2
3/// Test -z ifunc-noplt.
4
5// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-freebsd %S/Inputs/shared2-x86-64.s -o %t1.o
6// RUN: ld.lld %t1.o --shared -soname=so -o %t.so
7// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-freebsd %s -o %t.o
8
9/// The default -z text is not compatible with -z ifunc-noplt.
10// RUN: not ld.lld -z ifunc-noplt %t.o -o /dev/null 2>&1| FileCheck --check-prefix=INCOMPATIBLE %s
11// RUN: not ld.lld -z ifunc-noplt -z text %t.o -o /dev/null 2>&1| FileCheck --check-prefix=INCOMPATIBLE %s
12// INCOMPATIBLE: -z text and -z ifunc-noplt may not be used together
13
14// RUN: ld.lld -z ifunc-noplt -z notext --hash-style=sysv %t.so %t.o -o %tout
15// RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck %s --check-prefix=DISASM
16// RUN: llvm-readobj -r --dynamic-table %tout | FileCheck %s
17
18// Check that we emitted relocations for the ifunc calls
19// CHECK: Relocations [
20// CHECK-NEXT:   Section (4) .rela.dyn {
21// CHECK-NEXT:     0x201328 R_X86_64_PLT32 bar 0xFFFFFFFFFFFFFFFC
22// CHECK-NEXT:     0x201323 R_X86_64_PLT32 foo 0xFFFFFFFFFFFFFFFC
23// CHECK-NEXT:   }
24// CHECK-NEXT:   Section (5) .rela.plt {
25// CHECK-NEXT:     0x203498 R_X86_64_JUMP_SLOT bar2 0x0
26// CHECK-NEXT:     0x2034A0 R_X86_64_JUMP_SLOT zed2 0x0
27// CHECK-NEXT:   }
28
29// Check that ifunc call sites still require relocation
30// DISASM: Disassembly of section .text:
31// DISASM-EMPTY:
32// DISASM-NEXT: 0000000000201320 <foo>:
33// DISASM-NEXT:   201320:      	retq
34// DISASM-EMPTY:
35// DISASM-NEXT: 0000000000201321 <bar>:
36// DISASM-NEXT:   201321:      	retq
37// DISASM-EMPTY:
38// DISASM-NEXT: 0000000000201322 <_start>:
39// DISASM-NEXT:   201322:      	callq	0x201327 <_start+0x5>
40// DISASM-NEXT:   201327:      	callq	0x20132c <_start+0xa>
41// DISASM-NEXT:   20132c:      	callq	0x201350 <bar2@plt>
42// DISASM-NEXT:   201331:      	callq	0x201360 <zed2@plt>
43// DISASM-EMPTY:
44// DISASM-NEXT: Disassembly of section .plt:
45// DISASM-EMPTY:
46// DISASM-NEXT: 0000000000201340 <.plt>:
47// DISASM-NEXT:   201340:      	pushq	8514(%rip)
48// DISASM-NEXT:   201346:      	jmpq	*8516(%rip)
49// DISASM-NEXT:   20134c:      	nopl	(%rax)
50// DISASM-EMPTY:
51// DISASM-NEXT: 0000000000201350 <bar2@plt>:
52// DISASM-NEXT:   201350:      	jmpq	*8514(%rip)
53// DISASM-NEXT:   201356:      	pushq	$0
54// DISASM-NEXT:   20135b:      	jmp	0x201340 <.plt>
55// DISASM-EMPTY:
56// DISASM-NEXT: 0000000000201360 <zed2@plt>:
57// DISASM-NEXT:   201360:      	jmpq	*8506(%rip)
58// DISASM-NEXT:   201366:      	pushq	$1
59// DISASM-NEXT:   20136b:      	jmp	0x201340 <.plt>
60
61.text
62.type foo STT_GNU_IFUNC
63.globl foo
64foo:
65 ret
66
67.type bar STT_GNU_IFUNC
68.globl bar
69bar:
70 ret
71
72.globl _start
73_start:
74 call foo
75 call bar
76 call bar2
77 call zed2
78