Files
clang-p2996/lld/test/ELF/wrap-plt.s
Fangrui Song cf783be8d7 Reland D114783/D115603 [ELF] Split scanRelocations into scanRelocations/postScanRelocations
(Fixed an issue about GOT on a copy relocated alias.)
(Fixed an issue about not creating r_addend=0 IRELATIVE for unreferenced non-preemptible ifunc.)

The idea is to make scanRelocations mark some actions are needed (GOT/PLT/etc)
and postpone the real work to postScanRelocations. It gives some flexibility:

* Make it feasible to support .plt.got (PR32938): we need to know whether GLOB_DAT and JUMP_SLOT are both needed.
* Make non-preemptible IFUNC handling slightly cleaner: avoid setting/clearing sym.gotInIgot
* -z nocopyrel: report all copy relocation places for one symbol
* Make GOT deduplication feasible
* Make parallel relocation scanning feasible (if we can avoid all stateful operations and make Symbol attributes atomic), but parallelism may not be the appealing choice

Since this patch moves a large chunk of code out of ELFT templates. My x86-64
executable is actually a few hundred bytes smaller.

For ppc32-ifunc-nonpreemptible-pic.s: I remove absolute relocation references to non-preemptible ifunc
because absolute relocation references are incorrect in -fpie mode.

Reviewed By: peter.smith, ikudrin

Differential Revision: https://reviews.llvm.org/D114783
2021-12-14 16:28:41 -08:00

39 lines
894 B
ArmAsm

// REQUIRES: x86
/// Test we correctly wrap PLT calls.
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
// RUN: ld.lld -o %t2 %t -wrap foo -shared
// RUN: llvm-readobj -S -r %t2 | FileCheck %s
// RUN: llvm-objdump -d %t2 | FileCheck --check-prefix=DISASM %s
// CHECK: Relocations [
// CHECK-NEXT: Section ({{.*}}) .rela.plt {
// CHECK-NEXT: R_X86_64_JUMP_SLOT foo 0x0
// CHECK-NEXT: R_X86_64_JUMP_SLOT __wrap_foo 0x0
// CHECK-NEXT: R_X86_64_JUMP_SLOT _start 0x0
// CHECK-NEXT: }
// CHECK-NEXT: ]
// DISASM: <_start>:
// DISASM-NEXT: jmp {{.*}} <__wrap_foo@plt>
// DISASM-NEXT: jmp {{.*}} <__wrap_foo@plt>
// DISASM-NEXT: jmp {{.*}} <foo@plt>
// DISASM-NEXT: jmp {{.*}} <_start@plt>
.global foo
foo:
nop
.global __wrap_foo
__wrap_foo:
nop
.global _start
_start:
jmp foo@plt
jmp __wrap_foo@plt
jmp __real_foo@plt
jmp _start@plt