<div dir="ltr">Apologies. Looking.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 25, 2017 at 11:54 AM, Galina Kistanova <span dir="ltr"><<a href="mailto:gkistanova@gmail.com" target="_blank">gkistanova@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello Rui,<br><br>This commit broke test on one of our builders:<br><br><a href="http://lab.llvm.org:8011/builders/lld-x86_64-win7/builds/7606" target="_blank">http://lab.llvm.org:8011/<wbr>builders/lld-x86_64-win7/<wbr>builds/7606</a><br><br>Failing Tests (1):<br> lld :: ELF/progname.s<br><br>Please have a look at this?<br><br>Thanks<span class="HOEnZb"><font color="#888888"><br><br>Galina<br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 24, 2017 at 5:15 PM, Rui Ueyama 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: ruiu<br>
Date: Mon Apr 24 19:15:48 2017<br>
New Revision: 301282<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=301282&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=301282&view=rev</a><br>
Log:<br>
Export __progname even if a -dynamic-list is given.<br>
<br>
BSD's __progname symbol is defined in crt1.o and linked against main<br>
executables. The libc expects that main executables export __progname<br>
symbol via .dynsym sections. In order to handle this case, we scan<br>
undefined symbols in DSOs and exported them by setting Sym->ExportDynamic<br>
to true.<br>
<br>
But it turned out that setting that variable is not enough to make sure<br>
that symbols are exported in all use cases. If a -dynamic-list option is<br>
given, all symbols not explicitly mentioned in a version script are<br>
hidden by default. That hides __progname symbol. This patch fixes the issue.<br>
<br>
Fixes <a href="https://bugs.llvm.org/show_bug.cgi?id=32703" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_bug<wbr>.cgi?id=32703</a><br>
<br>
Modified:<br>
lld/trunk/ELF/SymbolTable.cpp<br>
lld/trunk/test/ELF/progname.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=301282&r1=301281&r2=301282&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/SymbolTabl<wbr>e.cpp?rev=301282&r1=301281&r2=<wbr>301282&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/SymbolTable.cpp (original)<br>
+++ lld/trunk/ELF/SymbolTable.cpp Mon Apr 24 19:15:48 2017<br>
@@ -548,11 +548,20 @@ template <class ELFT> void SymbolTable<E<br>
// shared libraries can find them.<br>
// Except this, we ignore undefined symbols in DSOs.<br>
template <class ELFT> void SymbolTable<ELFT>::scanShlibUn<wbr>defined() {<br>
- for (SharedFile<ELFT> *File : SharedFiles)<br>
- for (StringRef U : File->getUndefinedSymbols())<br>
- if (SymbolBody *Sym = find(U))<br>
- if (Sym->isDefined())<br>
- Sym->symbol()->ExportDynamic = true;<br>
+ for (SharedFile<ELFT> *File : SharedFiles) {<br>
+ for (StringRef U : File->getUndefinedSymbols()) {<br>
+ SymbolBody *Sym = find(U);<br>
+ if (!Sym || !Sym->isDefined())<br>
+ continue;<br>
+ Sym->symbol()->ExportDynamic = true;<br>
+<br>
+ // If -dynamic-list is given, the default version is set to<br>
+ // VER_NDX_LOCAL, which prevents a symbol to be exported via .dynsym.<br>
+ // Set to VER_NDX_GLOBAL so the symbol will be handled as if it were<br>
+ // specified by -dynamic-list.<br>
+ Sym->symbol()->VersionId = VER_NDX_GLOBAL;<br>
+ }<br>
+ }<br>
}<br>
<br>
// Initialize DemangledSyms with a map from demangled symbols to symbol<br>
<br>
Modified: lld/trunk/test/ELF/progname.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/progname.s?rev=301282&r1=301281&r2=301282&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/test/ELF/progn<wbr>ame.s?rev=301282&r1=301281&r2=<wbr>301282&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/test/ELF/progname.s (original)<br>
+++ lld/trunk/test/ELF/progname.s Mon Apr 24 19:15:48 2017<br>
@@ -12,6 +12,10 @@<br>
// RUN: ld.lld -o %t %t.o %t.so<br>
// RUN: llvm-readobj -dyn-symbols %t | FileCheck %s<br>
<br>
+// RUN: echo "{_start;};" > %t.dynlist<br>
+// RUN: ld.lld -dynamic-list %t.dynlist -o %t %t.o %t.so<br>
+// RUN: llvm-readobj -dyn-symbols %t | FileCheck %s<br>
+<br>
// CHECK: Name: __progname@<br>
// CHECK-NEXT: Value: 0x201000<br>
// CHECK-NEXT: Size: 0<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">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>
</div></div></blockquote></div><br></div>