From b262cbe6b744e9aed31b7d5f3a2655726072f44b Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 29 Nov 2017 00:31:39 +0000 Subject: [PATCH] Replace copyFrom with memcpy. It was only used for --wrap and I don't think the fields with special treatment had a meaningful impact on that feature. llvm-svn: 319265 --- lld/ELF/SymbolTable.cpp | 4 ++-- lld/ELF/Symbols.cpp | 15 --------------- lld/ELF/Symbols.h | 1 - 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index 6b61213896f5..a82046ba0082 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -192,8 +192,8 @@ void SymbolTable::applySymbolWrap() { } // Replace __real_sym with sym and sym with __wrap_sym. - W.Real->copyFrom(W.Sym); - W.Sym->copyFrom(W.Wrap); + memcpy(W.Real, W.Sym, sizeof(SymbolUnion)); + memcpy(W.Sym, W.Wrap, sizeof(SymbolUnion)); // We now have two copies of __wrap_sym. Drop one. W.Wrap->IsUsedInRegularObj = false; diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index 1b696eac578b..5d496a6aeb4f 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -134,21 +134,6 @@ InputFile *Symbol::getFile() const { return File; } -// Overwrites all attributes with Other's so that this symbol becomes -// an alias to Other. This is useful for handling some options such as -// --wrap. -void Symbol::copyFrom(Symbol *Other) { - Symbol Sym = *this; - memcpy(this, Other, sizeof(SymbolUnion)); - - VersionId = Sym.VersionId; - IsUsedInRegularObj = Sym.IsUsedInRegularObj; - ExportDynamic = Sym.ExportDynamic; - CanInline = Sym.CanInline; - Traced = Sym.Traced; - InVersionScript = Sym.InVersionScript; -} - uint64_t Symbol::getVA(int64_t Addend) const { uint64_t OutVA = getSymVA(*this, Addend); return OutVA + Addend; diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index 99fc61b963af..7a3ed4ffcaab 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -108,7 +108,6 @@ public: StringRef getName() const { return Name; } uint8_t getVisibility() const { return StOther & 0x3; } void parseSymbolVersion(); - void copyFrom(Symbol *Other); bool isInGot() const { return GotIndex != -1U; } bool isInPlt() const { return PltIndex != -1U; }