From f43fba739cd2d07874a02c60c26d455e1861a874 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 18 Jul 2018 18:24:46 +0000 Subject: [PATCH] Revert r336609: Fix direct calls to __wrap_sym when it is relocated. This reverts commit r336609 as it doesn't seem to work with AArch64 thunk creation when used with ASan. llvm-svn: 337413 --- lld/ELF/Relocations.cpp | 2 +- lld/ELF/SymbolTable.cpp | 11 ----------- lld/ELF/SymbolTable.h | 1 - lld/ELF/Writer.cpp | 3 --- lld/test/ELF/wrap-plt.s | 45 --------------------------------------------- 5 files changed, 1 insertion(+), 61 deletions(-) delete mode 100644 lld/test/ELF/wrap-plt.s diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 854711b..467219a 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -1010,7 +1010,7 @@ static void scanReloc(InputSectionBase &Sec, OffsetGetter &GetOffset, RelTy *&I, } // If a relocation needs PLT, we create PLT and GOTPLT slots for the symbol. - if (needsPlt(Expr) && !Sym.isInPlt() && Sym.IsUsedInRegularObj) { + if (needsPlt(Expr) && !Sym.isInPlt()) { if (Sym.isGnuIFunc() && !Sym.IsPreemptible) addPltEntry(InX::Iplt, InX::IgotPlt, InX::RelaIplt, Target->IRelativeRel, Sym); diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index c52ec8f..1f5a84e 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -212,17 +212,6 @@ void SymbolTable::applySymbolWrap() { } } -// Apply changes caused by relocations to wrapped symbols -// This is needed for direct calls to __wrap_sym -void SymbolTable::applySymbolWrapReloc() { - for (WrappedSymbol &W : WrappedSymbols) { - memcpy(W.Wrap, W.Sym, sizeof(SymbolUnion)); - - // Keep this so that this copy of the symbol remains dropped - W.Wrap->IsUsedInRegularObj = false; - } -} - static uint8_t getMinVisibility(uint8_t VA, uint8_t VB) { if (VA == STV_DEFAULT) return VB; diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h index 4c5e276..5e6d44d 100644 --- a/lld/ELF/SymbolTable.h +++ b/lld/ELF/SymbolTable.h @@ -39,7 +39,6 @@ public: template void addCombinedLTOObject(); template void addSymbolWrap(StringRef Name); void applySymbolWrap(); - void applySymbolWrapReloc(); ArrayRef getSymbols() const { return SymVector; } diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index f141eae..533ac47 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1567,9 +1567,6 @@ template void Writer::finalizeSections() { if (!Config->Relocatable) forEachRelSec(scanRelocations); - // Apply changes caused by relocations to wrapped symbols - Symtab->applySymbolWrapReloc(); - if (InX::Plt && !InX::Plt->empty()) InX::Plt->addSymbols(); if (InX::Iplt && !InX::Iplt->empty()) diff --git a/lld/test/ELF/wrap-plt.s b/lld/test/ELF/wrap-plt.s deleted file mode 100644 index bef5434..0000000 --- a/lld/test/ELF/wrap-plt.s +++ /dev/null @@ -1,45 +0,0 @@ -// REQUIRES: x86 -// 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: Name: .plt -// CHECK-NEXT: Type: SHT_PROGBITS -// CHECK-NEXT: Flags [ -// CHECK-NEXT: SHF_ALLOC -// CHECK-NEXT: SHF_EXECINSTR -// CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x1020 -// CHECK-NEXT: Offset: -// CHECK-NEXT: Size: 48 -// CHECK-NEXT: Link: 0 -// CHECK-NEXT: Info: 0 -// CHECK-NEXT: AddressAlignment: 16 - -// CHECK: Relocations [ -// CHECK-NEXT: Section ({{.*}}) .rela.plt { -// CHECK-NEXT: 0x2018 R_X86_64_JUMP_SLOT __wrap_foo 0x0 -// CHECK-NEXT: 0x2020 R_X86_64_JUMP_SLOT _start 0x0 -// CHECK-NEXT: } -// CHECK-NEXT: ] - -// DISASM: _start: -// DISASM-NEXT: jmp 41 -// DISASM-NEXT: jmp 36 -// DISASM-NEXT: jmp 47 - -.global foo -foo: - nop - -.global __wrap_foo -__wrap_foo: - nop - -.global _start -_start: - jmp foo@plt - jmp __wrap_foo@plt - jmp _start@plt -- 2.7.4