2019-05-14 23:25:21 +08:00
|
|
|
// REQUIRES: x86
|
2019-09-10 20:28:07 +08:00
|
|
|
|
|
|
|
/// Test -z ifunc-noplt.
|
|
|
|
|
2019-05-14 23:25:21 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-freebsd %S/Inputs/shared2-x86-64.s -o %t1.o
|
2019-09-10 20:28:07 +08:00
|
|
|
// RUN: ld.lld %t1.o --shared -soname=so -o %t.so
|
2019-05-14 23:25:21 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-freebsd %s -o %t.o
|
2020-03-28 02:35:02 +08:00
|
|
|
|
|
|
|
/// The default -z text is not compatible with -z ifunc-noplt.
|
|
|
|
// RUN: not ld.lld -z ifunc-noplt %t.o -o /dev/null 2>&1| FileCheck --check-prefix=INCOMPATIBLE %s
|
|
|
|
// RUN: not ld.lld -z ifunc-noplt -z text %t.o -o /dev/null 2>&1| FileCheck --check-prefix=INCOMPATIBLE %s
|
|
|
|
// INCOMPATIBLE: -z text and -z ifunc-noplt may not be used together
|
|
|
|
|
2019-05-14 23:25:21 +08:00
|
|
|
// RUN: ld.lld -z ifunc-noplt -z notext --hash-style=sysv %t.so %t.o -o %tout
|
|
|
|
// RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck %s --check-prefix=DISASM
|
|
|
|
// RUN: llvm-readobj -r --dynamic-table %tout | FileCheck %s
|
|
|
|
|
|
|
|
// Check that we emitted relocations for the ifunc calls
|
|
|
|
// CHECK: Relocations [
|
|
|
|
// CHECK-NEXT: Section (4) .rela.dyn {
|
2019-09-16 15:05:34 +08:00
|
|
|
// CHECK-NEXT: 0x201323 R_X86_64_PLT32 foo 0xFFFFFFFFFFFFFFFC
|
2021-02-14 02:32:27 +08:00
|
|
|
// CHECK-NEXT: 0x201328 R_X86_64_PLT32 bar 0xFFFFFFFFFFFFFFFC
|
2019-05-14 23:25:21 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Section (5) .rela.plt {
|
2019-09-16 15:05:34 +08:00
|
|
|
// CHECK-NEXT: 0x203498 R_X86_64_JUMP_SLOT bar2 0x0
|
|
|
|
// CHECK-NEXT: 0x2034A0 R_X86_64_JUMP_SLOT zed2 0x0
|
2019-05-14 23:25:21 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
|
|
|
|
// Check that ifunc call sites still require relocation
|
|
|
|
// DISASM: Disassembly of section .text:
|
|
|
|
// DISASM-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: 0000000000201320 <foo>:
|
2019-09-16 15:05:34 +08:00
|
|
|
// DISASM-NEXT: 201320: retq
|
2019-05-14 23:25:21 +08:00
|
|
|
// DISASM-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: 0000000000201321 <bar>:
|
2019-09-16 15:05:34 +08:00
|
|
|
// DISASM-NEXT: 201321: retq
|
2019-05-14 23:25:21 +08:00
|
|
|
// DISASM-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: 0000000000201322 <_start>:
|
2020-03-23 06:03:10 +08:00
|
|
|
// DISASM-NEXT: 201322: callq 0x201327 <_start+0x5>
|
|
|
|
// DISASM-NEXT: 201327: callq 0x20132c <_start+0xa>
|
|
|
|
// DISASM-NEXT: 20132c: callq 0x201350 <bar2@plt>
|
|
|
|
// DISASM-NEXT: 201331: callq 0x201360 <zed2@plt>
|
2019-05-14 23:25:21 +08:00
|
|
|
// DISASM-EMPTY:
|
|
|
|
// DISASM-NEXT: Disassembly of section .plt:
|
|
|
|
// DISASM-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: 0000000000201340 <.plt>:
|
2019-09-16 15:05:34 +08:00
|
|
|
// DISASM-NEXT: 201340: pushq 8514(%rip)
|
|
|
|
// DISASM-NEXT: 201346: jmpq *8516(%rip)
|
|
|
|
// DISASM-NEXT: 20134c: nopl (%rax)
|
2019-05-14 23:25:21 +08:00
|
|
|
// DISASM-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: 0000000000201350 <bar2@plt>:
|
2019-09-16 15:05:34 +08:00
|
|
|
// DISASM-NEXT: 201350: jmpq *8514(%rip)
|
|
|
|
// DISASM-NEXT: 201356: pushq $0
|
2020-03-23 06:03:10 +08:00
|
|
|
// DISASM-NEXT: 20135b: jmp 0x201340 <.plt>
|
2019-05-14 23:25:21 +08:00
|
|
|
// DISASM-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: 0000000000201360 <zed2@plt>:
|
2019-09-16 15:05:34 +08:00
|
|
|
// DISASM-NEXT: 201360: jmpq *8506(%rip)
|
|
|
|
// DISASM-NEXT: 201366: pushq $1
|
2020-03-23 06:03:10 +08:00
|
|
|
// DISASM-NEXT: 20136b: jmp 0x201340 <.plt>
|
2019-05-14 23:25:21 +08:00
|
|
|
|
|
|
|
.text
|
|
|
|
.type foo STT_GNU_IFUNC
|
|
|
|
.globl foo
|
|
|
|
foo:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.type bar STT_GNU_IFUNC
|
|
|
|
.globl bar
|
|
|
|
bar:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.globl _start
|
|
|
|
_start:
|
|
|
|
call foo
|
|
|
|
call bar
|
|
|
|
call bar2
|
|
|
|
call zed2
|