summaryrefslogtreecommitdiff
path: root/lld/ELF/SymbolTable.h
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2018-08-22 07:02:26 +0000
committerRui Ueyama <ruiu@google.com>2018-08-22 07:02:26 +0000
commit005d8d878ca7c0e06b52959b6506f9d4c6872b9a (patch)
tree237c558c9b6dda17c2699829ab29e7d46fa77aa9 /lld/ELF/SymbolTable.h
parentbb338f3934c5a9eec3f634e808d29ef0627aec86 (diff)
Change how we handle -wrap.
We have an issue with -wrap that the option doesn't work well when renamed symbols get PLT entries. I'll explain what is the issue and how this patch solves it. For one -wrap option, we have three symbols: foo, wrap_foo and real_foo. Currently, we use memcpy to overwrite wrapped symbols so that they get the same contents. This works in most cases but doesn't when the relocation processor sets some flags in the symbol. memcpy'ed symbols are just aliases, so they always have to have the same contents, but the relocation processor breaks that assumption. r336609 is an attempt to fix the issue by memcpy'ing again after processing relocations, so that symbols that are out of sync get the same contents again. That works in most cases as well, but it breaks ASan build in a mysterious way. We could probably fix the issue by choosing symbol attributes that need to be copied after they are updated. But it feels too complicated to me. So, in this patch, I fixed it once and for all. With this patch, we no longer memcpy symbols. All references to renamed symbols point to new symbols after wrapSymbols() is done. Differential Revision: https://reviews.llvm.org/D50569
Diffstat (limited to 'lld/ELF/SymbolTable.h')
-rw-r--r--lld/ELF/SymbolTable.h12
1 files changed, 1 insertions, 11 deletions
diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h
index 5e6d44dfe4f..668ea0eccc2 100644
--- a/lld/ELF/SymbolTable.h
+++ b/lld/ELF/SymbolTable.h
@@ -37,8 +37,7 @@ class SymbolTable {
public:
template <class ELFT> void addFile(InputFile *File);
template <class ELFT> void addCombinedLTOObject();
- template <class ELFT> void addSymbolWrap(StringRef Name);
- void applySymbolWrap();
+ void wrap(Symbol *Sym, Symbol *Real, Symbol *Wrap);
ArrayRef<Symbol *> getSymbols() const { return SymVector; }
@@ -121,15 +120,6 @@ private:
// directive in version scripts.
llvm::Optional<llvm::StringMap<std::vector<Symbol *>>> DemangledSyms;
- struct WrappedSymbol {
- Symbol *Sym;
- Symbol *Real;
- Symbol *Wrap;
- };
-
- // For -wrap.
- std::vector<WrappedSymbol> WrappedSymbols;
-
// For LTO.
std::unique_ptr<BitcodeCompiler> LTO;
};