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.