[lld] r267188 - ELF: Scan for undefined symbols in shlibs and symbols in dynamic lists before LTO.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 22 14:04:16 PDT 2016


Thanks!

On 22 April 2016 at 14:47, Peter Collingbourne via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: pcc
> Date: Fri Apr 22 13:47:52 2016
> New Revision: 267188
>
> URL: http://llvm.org/viewvc/llvm-project?rev=267188&view=rev
> Log:
> ELF: Scan for undefined symbols in shlibs and symbols in dynamic lists before LTO.
>
> This ensures that these features work correctly with bitcode files.
>
> Added:
>     lld/trunk/test/ELF/lto/dynamic-list.ll
>     lld/trunk/test/ELF/lto/shlib-undefined.ll
> Modified:
>     lld/trunk/ELF/Driver.cpp
>
> Modified: lld/trunk/ELF/Driver.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=267188&r1=267187&r2=267188&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Driver.cpp (original)
> +++ lld/trunk/ELF/Driver.cpp Fri Apr 22 13:47:52 2016
> @@ -458,14 +458,15 @@ template <class ELFT> void LinkerDriver:
>    if (Config->OutputFile.empty())
>      Config->OutputFile = "a.out";
>
> +  Symtab.scanShlibUndefined();
> +  Symtab.scanDynamicList();
> +
>    Symtab.addCombinedLtoObject();
>
>    for (auto *Arg : Args.filtered(OPT_wrap))
>      Symtab.wrap(Arg->getValue());
>
>    // Write the result to the file.
> -  Symtab.scanShlibUndefined();
> -  Symtab.scanDynamicList();
>    if (Config->GcSections)
>      markLive<ELFT>(&Symtab);
>    if (Config->ICF)
>
> Added: lld/trunk/test/ELF/lto/dynamic-list.ll
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/dynamic-list.ll?rev=267188&view=auto
> ==============================================================================
> --- lld/trunk/test/ELF/lto/dynamic-list.ll (added)
> +++ lld/trunk/test/ELF/lto/dynamic-list.ll Fri Apr 22 13:47:52 2016
> @@ -0,0 +1,25 @@
> +; REQUIRES: x86
> +; RUN: llvm-as %s -o %t.o
> +; RUN: echo "{ foo; };" > %t.list
> +; RUN: ld.lld -m elf_x86_64 -o %t --dynamic-list %t.list -pie %t.o
> +; RUN: llvm-readobj -dyn-symbols %t | FileCheck %s
> +
> +; CHECK:      Name:     foo@
> +; CHECK-NEXT: Value:    0x1010
> +; CHECK-NEXT: Size:     1
> +; CHECK-NEXT: Binding:  Global (0x1)
> +; CHECK-NEXT: Type:     Function
> +; CHECK-NEXT: Other:    0
> +; CHECK-NEXT: Section:  .text
> +; CHECK-NEXT: }
> +
> +target triple = "x86_64-unknown-linux-gnu"
> +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
> +
> +define void @_start() {
> +  ret void
> +}
> +
> +define void @foo() {
> +  ret void
> +}
>
> Added: lld/trunk/test/ELF/lto/shlib-undefined.ll
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/shlib-undefined.ll?rev=267188&view=auto
> ==============================================================================
> --- lld/trunk/test/ELF/lto/shlib-undefined.ll (added)
> +++ lld/trunk/test/ELF/lto/shlib-undefined.ll Fri Apr 22 13:47:52 2016
> @@ -0,0 +1,27 @@
> +; REQUIRES: x86
> +; RUN: llvm-as %s -o %t.o
> +; RUN: echo .global __progname > %t2.s
> +; RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t2.s -o %t2.o
> +; RUN: ld.lld -shared %t2.o -o %t2.so
> +; RUN: ld.lld -o %t %t.o %t2.so
> +; RUN: llvm-readobj -dyn-symbols %t | FileCheck %s
> +
> +; CHECK:      Name:     __progname@
> +; CHECK-NEXT: Value:    0x11010
> +; CHECK-NEXT: Size:     1
> +; CHECK-NEXT: Binding:  Global (0x1)
> +; CHECK-NEXT: Type:     Function
> +; CHECK-NEXT: Other:    0
> +; CHECK-NEXT: Section:  .text
> +; CHECK-NEXT: }
> +
> +target triple = "x86_64-unknown-linux-gnu"
> +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
> +
> +define void @_start() {
> +  ret void
> +}
> +
> +define void @__progname() {
> +  ret void
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list