[PATCH] D39959: [ELF] - Allow merging of strings sections for -relocatable output.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 13 08:23:12 PST 2017


grimar created this revision.
Herald added subscribers: arichardson, aprantl, emaste.

This is PR35223.

r317406 stopped merging SHF_MERGE sections when -r is given.
Previously we used Alignment, Flags and section Name together to
generate a complex key for merging sections. For -r case all 3 were used,
but for regular case we merged sections by name only for a long time
and r317406 changed behavior to merge sections by name for all outputs,
that allowed to simplify code and sped up linker a bit.

But above broke -relocatable output in sence that tools like dwarfdump (both gnu
and llvm one) expects to see single .debug_str section in output.
After the r317406 we started producing unique output section for each input
and tools are upset.

I suggest to allow relocatable output to merge SHF_MERGE strings sections.
In case when input sections has different sh_entsize, I think we can just drop
the SHF_MERGE flag and merge them. That looks consistent with what ld.bfd
do and should not be an issue, because I believe normally string sections
always have sh_entsize = 1. llvm-mc even ignores any values explicitly set for .debug_str
sh_entsize and renders 1 to output, though gas allows different values.


https://reviews.llvm.org/D39959

Files:
  ELF/LinkerScript.cpp
  test/ELF/relocatable-mergeable.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39959.122654.patch
Type: text/x-patch
Size: 4136 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171113/2cba8697/attachment.bin>


More information about the llvm-commits mailing list