[lld] r319265 - Replace copyFrom with memcpy.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 28 16:31:39 PST 2017


Author: rafael
Date: Tue Nov 28 16:31:39 2017
New Revision: 319265

URL: http://llvm.org/viewvc/llvm-project?rev=319265&view=rev
Log:
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.

Modified:
    lld/trunk/ELF/SymbolTable.cpp
    lld/trunk/ELF/Symbols.cpp
    lld/trunk/ELF/Symbols.h

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=319265&r1=319264&r2=319265&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Tue Nov 28 16:31:39 2017
@@ -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;

Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=319265&r1=319264&r2=319265&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Tue Nov 28 16:31:39 2017
@@ -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;

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=319265&r1=319264&r2=319265&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Tue Nov 28 16:31:39 2017
@@ -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; }




More information about the llvm-commits mailing list