[PATCH] D55958: [ELF] Simplify addShared. NFC

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 20 15:14:26 PST 2018


MaskRay updated this revision to Diff 179173.
MaskRay added a comment.

.


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55958/new/

https://reviews.llvm.org/D55958

Files:
  ELF/SymbolTable.cpp


Index: ELF/SymbolTable.cpp
===================================================================
--- ELF/SymbolTable.cpp
+++ ELF/SymbolTable.cpp
@@ -492,18 +492,16 @@
   if (Sym.getVisibility() == STV_DEFAULT)
     S->ExportDynamic = true;
 
-  // An undefined symbol with non default visibility must be satisfied
-  // in the same DSO.
-  auto Replace = [&](uint8_t Binding) {
+  if (WasInserted ||
+      // An undefined/lazy symbol with non default visibility must be satisfied
+      // in the same DSO.
+      ((S->isUndefined() || S->isLazy()) && S->Visibility == STV_DEFAULT)) {
+    // Use the original binding if inserted before.
+    uint8_t Binding = WasInserted ? Sym.getBinding() : S->Binding;
     replaceSymbol<SharedSymbol>(S, File, Name, Binding, Sym.st_other,
                                 Sym.getType(), Sym.st_value, Sym.st_size,
                                 Alignment, VerdefIndex);
-  };
-
-  if (WasInserted)
-    Replace(Sym.getBinding());
-  else if (S->Visibility == STV_DEFAULT && (S->isUndefined() || S->isLazy()))
-    Replace(S->Binding);
+  }
 }
 
 Symbol *SymbolTable::addBitcode(StringRef Name, uint8_t Binding,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55958.179173.patch
Type: text/x-patch
Size: 1150 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181220/c805263a/attachment.bin>


More information about the llvm-commits mailing list