1// REQUIRES: x86 2 3/// For non-preemptable ifunc, place ifunc PLT entries after regular PLT entries. 4 5// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o 6// RUN: ld.lld --shared -o %t.so %t.o 7// RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck %s --check-prefix=DISASM 8// RUN: llvm-readobj -r %t.so | FileCheck %s 9 10// Check that an IRELATIVE relocation is used for a non-preemptible ifunc 11// handler and a JUMP_SLOT is used for a preemptible ifunc 12// DISASM: Disassembly of section .text: 13// DISASM-EMPTY: 14// DISASM-NEXT: fct: 15// DISASM-NEXT: 1308: retq 16// DISASM: fct2: 17// DISASM-NEXT: 1309: retq 18// DISASM: f1: 19// DISASM-NEXT: 130a: callq 65 20// DISASM-NEXT: 130f: callq 28 21// DISASM-NEXT: 1314: callq 39 22// DISASM-NEXT: 1319: retq 23// DISASM: f2: 24// DISASM-NEXT: 131a: retq 25// DISASM-EMPTY: 26// DISASM-NEXT: Disassembly of section .plt: 27// DISASM-EMPTY: 28// DISASM-NEXT: .plt: 29// DISASM-NEXT: 1320: pushq 8482(%rip) 30// DISASM-NEXT: 1326: jmpq *8484(%rip) 31// DISASM-NEXT: 132c: nopl (%rax) 32// DISASM-EMPTY: 33// DISASM-NEXT: fct2@plt: 34// DISASM-NEXT: 1330: jmpq *8482(%rip) 35// DISASM-NEXT: 1336: pushq $0 36// DISASM-NEXT: 133b: jmp -32 <.plt> 37// DISASM-EMPTY: 38// DISASM-NEXT: f2@plt: 39// DISASM-NEXT: 1340: jmpq *8474(%rip) 40// DISASM-NEXT: 1346: pushq $1 41// DISASM-NEXT: 134b: jmp -48 <.plt> 42// DISASM-NEXT: 1350: jmpq *8466(%rip) 43// DISASM-NEXT: 1356: pushq $0 44// DISASM-NEXT: 135b: jmp -32 <f2@plt> 45 46// CHECK: Relocations [ 47// CHECK-NEXT: Section (5) .rela.dyn { 48// CHECK-NEXT: 0x3468 R_X86_64_IRELATIVE - 0x1308 49// CHECK-NEXT: } 50// CHECK-NEXT: Section (6) .rela.plt { 51// CHECK-NEXT: 0x3458 R_X86_64_JUMP_SLOT fct2 0x0 52// CHECK-NEXT: 0x3460 R_X86_64_JUMP_SLOT f2 0x0 53// CHECK-NEXT: } 54 55 // Hidden expect IRELATIVE 56 .globl fct 57 .hidden fct 58 .type fct, STT_GNU_IFUNC 59fct: 60 ret 61 62 // Not hidden expect JUMP_SLOT 63 .globl fct2 64 .type fct2, STT_GNU_IFUNC 65fct2: 66 ret 67 68 .globl f1 69 .type f1, @function 70f1: 71 call fct 72 call fct2 73 call f2@PLT 74 ret 75 76 .globl f2 77 .type f2, @function 78f2: 79 ret 80