[PATCH] D24782: Do not merge input sections if --relocatable.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 20 13:41:47 PDT 2016


ruiu created this revision.
ruiu added a reviewer: peter.smith.
ruiu added a subscriber: llvm-commits.
Herald added a subscriber: aemerson.

This was discussed in https://reviews.llvm.org/D24728 and I think
it's worth to bring up as a separate and concrete patch so that
we can discuss about it.

This is a patch to disable section merging if --relocatable option
is given. Currently, if --relocatable is given, LLD produces a
relinkable object file, but multiple .text input sections are merged
together to produce a single .text output section (and so is true
for other regular output sections such as .data, .rodata, etc.)

Such behavior is the same as what GNU linkers do, which is an
obvious advantage, but it also has a few drawbacks.

First, it is not always easy to merge sections for --relocatable.
That is discussed in the review thread for D24728. For D24728,
we wanted to merge exception table for ARM, and merging .ARM.exidx
is tricky because we have to create corresponding sh_link sections
for a newly created output section. If we don't merge input sections,
but instead pass them through, we can eliminate that complexity
completely.

Second, --gc-sections and --icf doesn't work well for merged inputs.
Once we merge multiple .text secitons, the output is very likely to
be eliminated by --gc-sections on the final link.

Overall, I think not merging input sections is a better choice for us.
It is easier to impolement than merging sections and will yield
better final outputs. Therefore, I want to change the current behavior
with this change.

https://reviews.llvm.org/D24782

Files:
  ELF/OutputSections.cpp
  ELF/Writer.cpp
  test/ELF/relocatable-ehframe.s
  test/ELF/relocatable-reloc.s
  test/ELF/relocatable.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24782.71978.patch
Type: text/x-patch
Size: 8186 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160920/6117df85/attachment.bin>


More information about the llvm-commits mailing list