[lld] r315727 - Handle shared symbols in --gc-sections.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 13 11:41:24 PDT 2017


By the way, I think isInCurrentDSO isn't a precisely correct name, because
it may not be a shared object file but an executable.

What is a generic name for both executables and DSOs? I thought that ELF
module could be the one, but since "module" is a overloaded term, it might
not be a good name. So, maybe "ELF binary"? Or, something else?

On Fri, Oct 13, 2017 at 11:32 AM, Rafael Espindola via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: rafael
> Date: Fri Oct 13 11:32:16 2017
> New Revision: 315727
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315727&view=rev
> Log:
> Handle shared symbols in --gc-sections.
>
> We don't want to gc a section if it is used via __start_*, but we were
> doing that if the same symbol was visible in a shared library.
>
> Modified:
>     lld/trunk/ELF/MarkLive.cpp
>     lld/trunk/test/ELF/startstop-gccollect.s
>
> Modified: lld/trunk/ELF/MarkLive.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/
> MarkLive.cpp?rev=315727&r1=315726&r2=315727&view=diff
> ============================================================
> ==================
> --- lld/trunk/ELF/MarkLive.cpp (original)
> +++ lld/trunk/ELF/MarkLive.cpp Fri Oct 13 11:32:16 2017
> @@ -74,7 +74,7 @@ static void resolveReloc(InputSectionBas
>      return;
>    }
>
> -  if (B.isUndefined())
> +  if (!B.isInCurrentDSO())
>      for (InputSectionBase *Sec : CNamedSections.lookup(B.getName()))
>        Fn(Sec, 0);
>  }
>
> Modified: lld/trunk/test/ELF/startstop-gccollect.s
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/
> startstop-gccollect.s?rev=315727&r1=315726&r2=315727&view=diff
> ============================================================
> ==================
> --- lld/trunk/test/ELF/startstop-gccollect.s (original)
> +++ lld/trunk/test/ELF/startstop-gccollect.s Fri Oct 13 11:32:16 2017
> @@ -11,6 +11,12 @@
>  # RUN: ld.lld %t --gc-sections -o %tout
>  # RUN: llvm-objdump -d %tout | FileCheck -check-prefix=DISASM %s
>
> +# RUN: echo ".global __start_foo; __start_foo:" > %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 %t --gc-sections -o %tout %t2.so
> +# RUN: llvm-objdump -d %tout | FileCheck -check-prefix=DISASM %s
> +
>  # DISASM:      _start:
>  # DISASM-NEXT: 201000:        e8 05 00 00 00  callq   5 <__start_foo>
>  # DISASM-NEXT: 201005:        e8 02 00 00 00  callq   2 <__stop_bar>
>
>
> _______________________________________________
> 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/20171013/49c003ee/attachment.html>


More information about the llvm-commits mailing list