[PATCH] D28481: Respect section groups in GC

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 11 11:14:06 PST 2017


Reid Kleckner via Phabricator via llvm-commits
<llvm-commits at lists.llvm.org> writes:

> rnk added a comment.
>
> In https://reviews.llvm.org/D28481#640798, @ruiu wrote:
>
>> I wonder if there's a different way to keep them alive. One thing I can think of is to add a dummy relocation (something like R_X86_64_NONE) to a section so that if the section is alive, the other sections will become alive, without actually doing any relocations. Does it work?
>
>
> Currently, linker GC retains all data in sections referenced by __start_$section __stop_$section. We need to suppress that retention in addition to establishing this inverse reference. How do you propose to do that?

See my first reply. Using LINK_ORDER might work. Or we might need to
standardize it somehow.

Since this is a question more about ELF than about lld, I suggest we
move the discussion to
https://groups.google.com/forum/#!forum/generic-abi. In particular, I
would like to know the opinion of the developers of other linkers (Cary
Coutant in particular).

So far the possibilities are:

* Change lld and gold to be like bfd (and maybe clarify the spec).
* Spec that LINK_ORDER always has a reverse dependency.
* Add a section flag that says that relocation from that section have
  inverse dependency.

OK if I start that thread and CC folks on this discussion?

> This behavior should also already be suppressed for normal comdat section groups. Consider this assembly: https://ghostbin.com/paste/v5qrp The .init_array global is in a comdat section, and should not be retained by the linker if 'x' is unreferenced.

The linker has no way to know that "init" doesn't do anything
observable (it could print to stdout).

Cheers,
Rafael


More information about the llvm-commits mailing list