1// REQUIRES: x86 2// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o 3// RUN: ld.lld --shared -o %t.so %t.o 4// RUN: llvm-objdump -d %t.so | FileCheck %s --check-prefix=DISASM 5// RUN: llvm-readobj -r %t.so | FileCheck %s 6 7// Check that an IRELATIVE relocation is used for a non-preemptible ifunc 8// handler and a JUMP_SLOT is used for a preemptible ifunc 9// DISASM: Disassembly of section .text: 10// DISASM-NEXT: fct: 11// DISASM-NEXT: 1000: c3 retq 12// DISASM: fct2: 13// DISASM-NEXT: 1001: c3 retq 14// DISASM: f1: 15// DISASM-NEXT: 1002: e8 49 00 00 00 callq 73 16// DISASM-NEXT: 1007: e8 24 00 00 00 callq 36 17// DISASM-NEXT: 100c: e8 2f 00 00 00 callq 47 18// DISASM-NEXT: 1011: c3 retq 19// DISASM: f2: 20// DISASM-NEXT: 1012: c3 retq 21// DISASM-NEXT: Disassembly of section .plt: 22// DISASM-NEXT: .plt: 23// DISASM-NEXT: 1020: ff 35 e2 0f 00 00 pushq 4066(%rip) 24// DISASM-NEXT: 1026: ff 25 e4 0f 00 00 jmpq *4068(%rip) 25// DISASM-NEXT: 102c: 0f 1f 40 00 nopl (%rax) 26// DISASM-NEXT: 1030: ff 25 e2 0f 00 00 jmpq *4066(%rip) 27// DISASM-NEXT: 1036: 68 00 00 00 00 pushq $0 28// DISASM-NEXT: 103b: e9 e0 ff ff ff jmp -32 <.plt> 29// DISASM-NEXT: 1040: ff 25 da 0f 00 00 jmpq *4058(%rip) 30// DISASM-NEXT: 1046: 68 01 00 00 00 pushq $1 31// DISASM-NEXT: 104b: e9 d0 ff ff ff jmp -48 <.plt> 32// DISASM-NEXT: 1050: ff 25 d2 0f 00 00 jmpq *4050(%rip) 33// DISASM-NEXT: 1056: 68 00 00 00 00 pushq $0 34// DISASM-NEXT: 105b: e9 e0 ff ff ff jmp -32 <.plt+0x20> 35 36// CHECK: Relocations [ 37// CHECK-NEXT: Section (4) .rela.plt { 38// CHECK-NEXT: 0x2018 R_X86_64_JUMP_SLOT fct2 0x0 39// CHECK-NEXT: 0x2020 R_X86_64_JUMP_SLOT f2 0x0 40// CHECK-NEXT: 0x2028 R_X86_64_IRELATIVE - 0x1000 41 42 // Hidden expect IRELATIVE 43 .globl fct 44 .hidden fct 45 .type fct, STT_GNU_IFUNC 46fct: 47 ret 48 49 // Not hidden expect JUMP_SLOT 50 .globl fct2 51 .type fct2, STT_GNU_IFUNC 52fct2: 53 ret 54 55 .globl f1 56 .type f1, @function 57f1: 58 call fct 59 call fct2 60 call f2@PLT 61 ret 62 63 .globl f2 64 .type f2, @function 65f2: 66 ret 67