<div dir="ltr">This change triggers assertion on one of Chromium bots. Looks like `assert(!B.isLocal())` in computeIsPreemptible is failing.<div><br></div><div><a href="https://logs.chromium.org/v/?s=chromium%2Fbb%2Fchromium.chrome%2FGoogle_Chrome_Linux_x64%2F25172%2F%2B%2Frecipes%2Fsteps%2Fcompile%2F0%2Fstdout">https://logs.chromium.org/v/?s=chromium%2Fbb%2Fchromium.chrome%2FGoogle_Chrome_Linux_x64%2F25172%2F%2B%2Frecipes%2Fsteps%2Fcompile%2F0%2Fstdout</a><br></div><div><br></div><div>Looking at your change, it looks like we were (and still?) accidentally adding shared local symbols to the symbol table as STB_WEAK. My hypothesis is that now that they are added with the original binding, the assertion starts triggering.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 27, 2017 at 5:04 PM, Rafael Espindola via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rafael<br>
Date: Mon Nov 27 17:04:51 2017<br>
New Revision: 319127<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=319127&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=319127&view=rev</a><br>
Log:<br>
Store the real binding of shared symbols.<br>
<br>
Currently we mark every shared symbol as STB_WEAK.<br>
<br>
That is a hack to make it easy to decide when a .so is needed or not<br>
because of a reference to a given symbol.<br>
<br>
That hack leaks when we create copy relocations as shown by the update<br>
to relocation-copy-alias.s.<br>
<br>
This patch stores the original binding when we first read a shared<br>
symbol. We still have to update the binding to weak if we see a weak<br>
undef, but I find the logic easier to read where it is now.<br>
<br>
Modified:<br>
    lld/trunk/ELF/SymbolTable.cpp<br>
    lld/trunk/ELF/Symbols.h<br>
    lld/trunk/test/ELF/relocation-<wbr>copy-alias.s<br>
<br>
Modified: lld/trunk/ELF/SymbolTable.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=319127&r1=319126&r2=319127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>SymbolTable.cpp?rev=319127&r1=<wbr>319126&r2=319127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/SymbolTable.cpp (original)<br>
+++ lld/trunk/ELF/SymbolTable.cpp Mon Nov 27 17:04:51 2017<br>
@@ -300,9 +300,9 @@ Symbol *SymbolTable::addUndefined(<wbr>String<br>
     replaceSymbol<Undefined>(S, File, Name, Binding, StOther, Type);<br>
     return S;<br>
   }<br>
+  if (S->isShared() || S->isLazy() || (S->isUndefined() && Binding != STB_WEAK))<br>
+    S->Binding = Binding;<br>
   if (Binding != STB_WEAK) {<br>
-    if (!S->isDefined())<br>
-      S->Binding = Binding;<br>
     if (auto *SS = dyn_cast<SharedSymbol>(S))<br>
       if (!Config->GcSections)<br>
         SS->getFile<ELFT>()->IsNeeded = true;<br>
@@ -310,12 +310,10 @@ Symbol *SymbolTable::addUndefined(<wbr>String<br>
   if (auto *L = dyn_cast<Lazy>(S)) {<br>
     // An undefined weak will not fetch archive members. See comment on Lazy in<br>
     // Symbols.h for the details.<br>
-    if (Binding == STB_WEAK) {<br>
+    if (Binding == STB_WEAK)<br>
       L->Type = Type;<br>
-      L->Binding = STB_WEAK;<br>
-    } else if (InputFile *F = L->fetch()) {<br>
+    else if (InputFile *F = L->fetch())<br>
       addFile<ELFT>(F);<br>
-    }<br>
   }<br>
   return S;<br>
 }<br>
@@ -497,8 +495,9 @@ void SymbolTable::addShared(<wbr>StringRef Na<br>
   if (WasInserted || ((S->isUndefined() || S->isLazy()) &&<br>
                       S->getVisibility() == STV_DEFAULT)) {<br>
     uint8_t Binding = S->Binding;<br>
-    replaceSymbol<SharedSymbol>(S, File, Name, Sym.st_other, Sym.getType(),<br>
-                                Sym.st_value, Sym.st_size, Alignment, Verdef);<br>
+    replaceSymbol<SharedSymbol>(S, File, Name, Sym.getBinding(), Sym.st_other,<br>
+                                Sym.getType(), Sym.st_value, Sym.st_size,<br>
+                                Alignment, Verdef);<br>
     if (!WasInserted) {<br>
       S->Binding = Binding;<br>
       if (!S->isWeak() && !Config->GcSections)<br>
<br>
Modified: lld/trunk/ELF/Symbols.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=319127&r1=319126&r2=319127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Symbols.<wbr>h?rev=319127&r1=319126&r2=<wbr>319127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Symbols.h (original)<br>
+++ lld/trunk/ELF/Symbols.h Mon Nov 27 17:04:51 2017<br>
@@ -209,10 +209,11 @@ class SharedSymbol : public Symbol {<br>
 public:<br>
   static bool classof(const Symbol *S) { return S->kind() == SharedKind; }<br>
<br>
-  SharedSymbol(StringRef Name, uint8_t StOther, uint8_t Type, uint64_t Value,<br>
-               uint64_t Size, uint32_t Alignment, const void *Verdef)<br>
-      : Symbol(SharedKind, Name, llvm::ELF::STB_WEAK, StOther, Type),<br>
-        Verdef(Verdef), Value(Value), Size(Size), Alignment(Alignment) {<br>
+  SharedSymbol(StringRef Name, uint8_t Binding, uint8_t StOther, uint8_t Type,<br>
+               uint64_t Value, uint64_t Size, uint32_t Alignment,<br>
+               const void *Verdef)<br>
+      : Symbol(SharedKind, Name, Binding, StOther, Type), Verdef(Verdef),<br>
+        Value(Value), Size(Size), Alignment(Alignment) {<br>
     // GNU ifunc is a mechanism to allow user-supplied functions to<br>
     // resolve PLT slot values at load-time. This is contrary to the<br>
     // regualr symbol resolution scheme in which symbols are resolved just<br>
<br>
Modified: lld/trunk/test/ELF/relocation-<wbr>copy-alias.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation-copy-alias.s?rev=319127&r1=319126&r2=319127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/test/ELF/<wbr>relocation-copy-alias.s?rev=<wbr>319127&r1=319126&r2=319127&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/test/ELF/relocation-<wbr>copy-alias.s (original)<br>
+++ lld/trunk/test/ELF/relocation-<wbr>copy-alias.s Mon Nov 27 17:04:51 2017<br>
@@ -61,7 +61,7 @@ movl $5, b2<br>
 // CHECK:      Name: b3<br>
 // CHECK-NEXT: Value: [[B]]<br>
 // CHECK-NEXT: Size: 1<br>
-// CHECK-NEXT: Binding: Weak<br>
+// CHECK-NEXT: Binding: Global<br>
 // CHECK-NEXT: Type: Object (0x1)<br>
 // CHECK-NEXT: Other: 0<br>
 // CHECK-NEXT: Section: .bss<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>