llvm-project/lld/test/elf/ifunc.test

70 lines
2.1 KiB
Plaintext
Raw Normal View History

# REQUIRES: x86
# This test checks that IRELATIVE relocations are created for symbols that
# need relocation even for static links.
RUN: lld -flavor gnu -target x86_64-linux --output-filetype=yaml -r \
RUN: %p/Inputs/ifunc.x86-64 | FileCheck %s
RUN: lld -flavor gnu -target x86_64-linux --output-filetype=yaml --noinhibit-exec \
RUN: %p/Inputs/ifunc.x86-64 %p/Inputs/ifunc.cpp.x86-64 \
RUN: | FileCheck %s --check-prefix=PLT
RUN: lld -flavor gnu -target x86_64-linux -o %t %p/Inputs/ifunc.x86-64 \
RUN: -e main -static %p/Inputs/ifunc.cpp.x86-64
RUN: llvm-objdump -d -s %t| FileCheck %s --check-prefix=BIN
RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=RELATIVEADDEND
# Test that STT_GNU_IFUNC symbols have type Code in SharedLibraryAtom.
RUN: lld -flavor gnu -target x86_64-linux --output-filetype=yaml \
RUN: --noinhibit-exec %p/Inputs/ifunc.cpp.x86-64 -L%p/Inputs -lifunc.x86-64 \
RUN: | FileCheck %s --check-prefix=SHARED
PLT: defined-atoms:
PLT: name: plt
PLT: scope: global
PLT: references:
PLT: kind: R_X86_64_PC32
PLT: target: [[PLTNAME:[-a-zA-Z0-9_]+]]
PLT: name: main
PLT: scope: global
PLT: references:
PLT: kind: R_X86_64_PC32
PLT: target: [[PLTNAME]]
// Make sure the target of main's relocation is a stub with a PC32 relocation.
// This relocation is to the got atom, but you can't really write that check in
// FileCheck.
PLT: name:
PLT: type: stub
PLT: references
PLT: kind: R_X86_64_PC32
// Make sure there's a got entry with a IRELATIVE relocation.
PLT: type: got
PLT: references:
PLT: kind: R_X86_64_IRELATIVE
PLT: target: hey
CHECK: name: hey
CHECK: scope: global
CHECK: type: resolver
// This is a horribly brittle test. We need a way to do arithmetic on captured
// variables.
BIN: {{[0-9a-f]+}}: ff 25 {{[0-9a-f]+}} {{[0-9a-f]+}} 00 00 jmpq *{{[0-9]+}}(%rip)
BIN: .got.plt:
BIN-NEXT: {{[0-9a-f]+}} 00000000 00000000
RELATIVEADDEND: Relocations [
RELATIVEADDEND-NEXT: Section (1) .rela.plt {
RELATIVEADDEND-NEXT: 0x401000 R_X86_64_IRELATIVE - 0x400110
RELATIVEADDEND-NEXT: }
RELATIVEADDEND-NEXT: ]
SHARED: shared-library-atoms
SHARED: name: hey
SHARED-NOT: data