[PATCH] D40582: Simplify Symbol::copyFrom

Rafael Ávila de Espíndola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 28 15:38:03 PST 2017


rafael updated this revision to Diff 124654.
rafael added a comment.

Just use memcpy.


https://reviews.llvm.org/D40582

Files:
  ELF/SymbolTable.cpp
  ELF/Symbols.cpp
  ELF/Symbols.h


Index: ELF/Symbols.h
===================================================================
--- ELF/Symbols.h
+++ ELF/Symbols.h
@@ -108,7 +108,6 @@
   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; }
Index: ELF/Symbols.cpp
===================================================================
--- ELF/Symbols.cpp
+++ ELF/Symbols.cpp
@@ -134,21 +134,6 @@
   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;
Index: ELF/SymbolTable.cpp
===================================================================
--- ELF/SymbolTable.cpp
+++ ELF/SymbolTable.cpp
@@ -192,8 +192,8 @@
     }
 
     // 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40582.124654.patch
Type: text/x-patch
Size: 1683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171128/64b8d85b/attachment.bin>


More information about the llvm-commits mailing list