[lld] r301282 - Export __progname even if a -dynamic-list is given.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 25 12:33:28 PDT 2017


Apologies. Looking.

On Tue, Apr 25, 2017 at 11:54 AM, Galina Kistanova <gkistanova at gmail.com>
wrote:

> Hello Rui,
>
> This commit broke test on one of our builders:
>
> http://lab.llvm.org:8011/builders/lld-x86_64-win7/builds/7606
>
> Failing Tests (1):
>     lld :: ELF/progname.s
>
> Please have a look at this?
>
> Thanks
>
> Galina
>
> On Mon, Apr 24, 2017 at 5:15 PM, Rui Ueyama via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: ruiu
>> Date: Mon Apr 24 19:15:48 2017
>> New Revision: 301282
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=301282&view=rev
>> Log:
>> Export __progname even if a -dynamic-list is given.
>>
>> BSD's __progname symbol is defined in crt1.o and linked against main
>> executables. The libc expects that main executables export __progname
>> symbol via .dynsym sections. In order to handle this case, we scan
>> undefined symbols in DSOs and exported them by setting Sym->ExportDynamic
>> to true.
>>
>> But it turned out that setting that variable is not enough to make sure
>> that symbols are exported in all use cases. If a -dynamic-list option is
>> given, all symbols not explicitly mentioned in a version script are
>> hidden by default. That hides __progname symbol. This patch fixes the
>> issue.
>>
>> Fixes https://bugs.llvm.org/show_bug.cgi?id=32703
>>
>> Modified:
>>     lld/trunk/ELF/SymbolTable.cpp
>>     lld/trunk/test/ELF/progname.s
>>
>> Modified: lld/trunk/ELF/SymbolTable.cpp
>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTabl
>> e.cpp?rev=301282&r1=301281&r2=301282&view=diff
>> ============================================================
>> ==================
>> --- lld/trunk/ELF/SymbolTable.cpp (original)
>> +++ lld/trunk/ELF/SymbolTable.cpp Mon Apr 24 19:15:48 2017
>> @@ -548,11 +548,20 @@ template <class ELFT> void SymbolTable<E
>>  // shared libraries can find them.
>>  // Except this, we ignore undefined symbols in DSOs.
>>  template <class ELFT> void SymbolTable<ELFT>::scanShlibUndefined() {
>> -  for (SharedFile<ELFT> *File : SharedFiles)
>> -    for (StringRef U : File->getUndefinedSymbols())
>> -      if (SymbolBody *Sym = find(U))
>> -        if (Sym->isDefined())
>> -          Sym->symbol()->ExportDynamic = true;
>> +  for (SharedFile<ELFT> *File : SharedFiles) {
>> +    for (StringRef U : File->getUndefinedSymbols()) {
>> +      SymbolBody *Sym = find(U);
>> +      if (!Sym || !Sym->isDefined())
>> +        continue;
>> +      Sym->symbol()->ExportDynamic = true;
>> +
>> +      // If -dynamic-list is given, the default version is set to
>> +      // VER_NDX_LOCAL, which prevents a symbol to be exported via
>> .dynsym.
>> +      // Set to VER_NDX_GLOBAL so the symbol will be handled as if it
>> were
>> +      // specified by -dynamic-list.
>> +      Sym->symbol()->VersionId = VER_NDX_GLOBAL;
>> +    }
>> +  }
>>  }
>>
>>  // Initialize DemangledSyms with a map from demangled symbols to symbol
>>
>> Modified: lld/trunk/test/ELF/progname.s
>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/progn
>> ame.s?rev=301282&r1=301281&r2=301282&view=diff
>> ============================================================
>> ==================
>> --- lld/trunk/test/ELF/progname.s (original)
>> +++ lld/trunk/test/ELF/progname.s Mon Apr 24 19:15:48 2017
>> @@ -12,6 +12,10 @@
>>  // RUN: ld.lld -o %t %t.o %t.so
>>  // RUN: llvm-readobj -dyn-symbols %t | FileCheck %s
>>
>> +// RUN: echo "{_start;};" > %t.dynlist
>> +// RUN: ld.lld -dynamic-list %t.dynlist -o %t %t.o %t.so
>> +// RUN: llvm-readobj -dyn-symbols %t | FileCheck %s
>> +
>>  // CHECK:      Name:     __progname@
>>  // CHECK-NEXT: Value:    0x201000
>>  // CHECK-NEXT: Size:     0
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170425/033030bb/attachment.html>


More information about the llvm-commits mailing list