[PATCH] D25325: [ELF] Change way we place non-scripted (orphan) sections
Eugene Leviant via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 6 07:33:57 PDT 2016
evgeny777 created this revision.
evgeny777 added reviewers: ruiu, rafael.
evgeny777 added subscribers: grimar, ikudrin, llvm-commits.
evgeny777 set the repository for this revision to rL LLVM.
evgeny777 added a project: lld.
Currently implemented algorithm doesn't work well for me, because my linker scripts put RW or RWX sections first. For example
SECTIONS {
.rwx : { *(.rwx) } /* RWX sections go here */
.ro : { *(.ro) } /* RO sections go after RWX */
}
If there is any RO orphan section in linked image it will be placed before RWX sections and produce extra PT_LOAD. This doesn't match nor gold nor ld behavior.
The approach I'm currently using (and one this patch implements) is to first find sections which can share same PT_LOAD with some orphan section. If such sections have been found they are compared with orphan section using compareSectionsNonScript<ELFT>() and best insertion position is chosen. If no section has equal access attributes then insertion position is found using current algorithm (insert before first section which is greater in sort order).
I don't know if this is right way to go, but this works much better for me (I don't have to edit scripts and results match ld/gold)
Repository:
rL LLVM
https://reviews.llvm.org/D25325
Files:
ELF/Writer.cpp
test/ELF/linkerscript/merge-sections.s
test/ELF/linkerscript/no-space.s
test/ELF/linkerscript/orphan.s
test/ELF/linkerscript/sections-constraint.s
test/ELF/linkerscript/sections-keep.s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25325.73794.patch
Type: text/x-patch
Size: 7469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161006/9d0dad56/attachment-0001.bin>
More information about the llvm-commits
mailing list