This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Do not merge sections in case of relocatable object generation
ClosedPublic

Authored by atanasyan on Sep 29 2016, 9:32 PM.

Details

Summary

Do not merge sections if generate a relocatable object. It makes the code simpler because we do not need to update relocations addend to reflect changes introduced by merging. Instead of that we write such "merge" sections into separate output ones and keep SHF_MERGE / SHF_STRINGS flags and sh_entsize value to be able to perform merging later during a final linking.

Diff Detail

Repository
rL LLVM

Event Timeline

atanasyan updated this revision to Diff 72973.Sep 29 2016, 9:32 PM
atanasyan retitled this revision from to [ELF] Do not merge sections in case of relocatable object generation.
atanasyan updated this object.
atanasyan added reviewers: ruiu, psmith.
atanasyan set the repository for this revision to rL LLVM.
atanasyan added a project: lld.
atanasyan added a subscriber: llvm-commits.
ruiu added inline comments.Sep 29 2016, 9:43 PM
ELF/InputFiles.cpp
180–183

The thing that a relocation could point to a location beyond the end of a section is a bug if we don't update a relocation, and that is fixable. So I found this explanation a bit confusing. It is just that we don't merge strings as a design decision because (1) it makes code simpler and (2) the final link will merge strings anyway so we don't lose almost nothing by not doing this at the moment. Could you clarify these points?

atanasyan updated this revision to Diff 73425.Oct 4 2016, 1:39 AM
atanasyan updated this object.
  • Update comment
  • Keep sh_entsize values of "merge" sections to allow merging at final linking

I think the implementation looks ok. I have made some suggestions to improve the comment, but I understood what it meant as it was written.

ELF/InputFiles.cpp
179

A few suggestions for the comment.
"if generate" -> "if generating"
"update relocations addend" -> "update relocation addends"
"separate output ones" -> "separate OutputSections"

ruiu accepted this revision.Oct 4 2016, 1:40 PM
ruiu edited edge metadata.

LGTM

This revision is now accepted and ready to land.Oct 4 2016, 1:40 PM

Thanks for review and the comment improvement.

This revision was automatically updated to reflect the committed changes.