78 lines · plain
1// REQUIRES: x862 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.o6// RUN: ld.lld %t1.o --shared -soname=so -o %t.so7// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-freebsd %s -o %t.o8 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 %s11// RUN: not ld.lld -z ifunc-noplt -z text %t.o -o /dev/null 2>&1| FileCheck --check-prefix=INCOMPATIBLE %s12// INCOMPATIBLE: -z text and -z ifunc-noplt may not be used together13 14// RUN: ld.lld -z ifunc-noplt -z notext --hash-style=sysv %t.so %t.o -o %tout15// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %tout | FileCheck %s --check-prefix=DISASM16// RUN: llvm-readobj -r --dynamic-table %tout | FileCheck %s17 18// Check that we emitted relocations for the ifunc calls19// CHECK: Relocations [20// CHECK-NEXT: Section (4) .rela.dyn {21// CHECK-NEXT: 0x201323 R_X86_64_PLT32 foo 0xFFFFFFFFFFFFFFFC22// CHECK-NEXT: 0x201328 R_X86_64_PLT32 bar 0xFFFFFFFFFFFFFFFC23// CHECK-NEXT: }24// CHECK-NEXT: Section (5) .rela.plt {25// CHECK-NEXT: 0x203498 R_X86_64_JUMP_SLOT bar2 0x026// CHECK-NEXT: 0x2034A0 R_X86_64_JUMP_SLOT zed2 0x027// CHECK-NEXT: }28 29// Check that ifunc call sites still require relocation30// DISASM: Disassembly of section .text:31// DISASM-EMPTY:32// DISASM-NEXT: 0000000000201320 <foo>:33// DISASM-NEXT: 201320: retq34// DISASM-EMPTY:35// DISASM-NEXT: 0000000000201321 <bar>:36// DISASM-NEXT: 201321: retq37// 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 $054// 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 $159// DISASM-NEXT: 20136b: jmp 0x201340 <.plt>60 61.text62.type foo STT_GNU_IFUNC63.globl foo64foo:65 ret66 67.type bar STT_GNU_IFUNC68.globl bar69bar:70 ret71 72.globl _start73_start:74 call foo75 call bar76 call bar277 call zed278