[PATCH] D55960: Simplify. NFC.

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


MaskRay created this revision.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.

Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D55960

Files:
  ELF/SymbolTable.cpp


Index: ELF/SymbolTable.cpp
===================================================================
--- ELF/SymbolTable.cpp
+++ ELF/SymbolTable.cpp
@@ -492,22 +492,15 @@
   if (Sym.getVisibility() == STV_DEFAULT)
     S->ExportDynamic = true;
 
-  // An undefined symbol with non default visibility must be satisfied
-  // in the same DSO.
-  if (WasInserted) {
-    replaceSymbol<SharedSymbol>(S, File, Name, Sym.getBinding(), Sym.st_other,
+  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);
-    return;
-  }
-
-  if ((S->isUndefined() || S->isLazy()) && S->Visibility == STV_DEFAULT) {
-    uint8_t Binding = S->Binding;
-    replaceSymbol<SharedSymbol>(S, File, Name, Sym.getBinding(), Sym.st_other,
-                                Sym.getType(), Sym.st_value, Sym.st_size,
-                                Alignment, VerdefIndex);
-
-    S->Binding = Binding;
   }
 }
 


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


More information about the llvm-commits mailing list