Sort segments according to their order in PHDRS command.
Handle first load segment containing ELF and program headers.
Discard ELF and program headers if not set by PT_PHDR or first PT_LOAD segment in PHDRS command.
Test cases are included.
Paths
| Differential D12027
[lld][LinkerScript] Consider order of headers in PHDRS command AbandonedPublic Authored by denis-protivensky on Aug 14 2015, 1:25 AM.
Details
Summary Sort segments according to their order in PHDRS command. Test cases are included.
Diff Detail Event Timelinedenis-protivensky retitled this revision from to [lld][LinkerScript] Consider order of headers in PHDRS command. denis-protivensky updated this object. Comment Actions Is it an error in gnu ld to have two output sections with the same name? I'm not sure if it is. IIRC, I remember Rafael specifically relying on the ability to have multiple sections with the same name in order to reduce the final binary size. Comment Actions Rafael, you're right. There may be more than one output section description with the same name. But headers in PHDRS command should have unique names, so I'll leave only check for duplicate header names. denis-protivensky edited edge metadata. Comment ActionsUpdated:
This revision is now accepted and ready to land.Sep 2 2015, 5:17 AM Comment Actions Rafael, thanks for the effort, but I have to abandon this one since the implemented logic is partially wrong. I might re-implement it, but it's more likely to appear in the new linker some time later.
Revision Contents
Diff 32135 include/lld/Core/Error.h
include/lld/ReaderWriter/LinkerScript.h
lib/Core/Error.cpp
lib/ReaderWriter/ELF/HeaderChunks.h
lib/ReaderWriter/ELF/OutputELFWriter.cpp
lib/ReaderWriter/ELF/TargetLayout.h
lib/ReaderWriter/ELF/TargetLayout.cpp
lib/ReaderWriter/LinkerScript.cpp
test/elf/linkerscript/phdrs-all-none.test
test/elf/linkerscript/phdrs-custom-none.test
test/elf/linkerscript/phdrs-custom-order.test
test/elf/linkerscript/phdrs-different.test
test/elf/linkerscript/phdrs-dup-name.test
test/elf/linkerscript/phdrs-extra-program.test
test/elf/linkerscript/phdrs-flags.test
test/elf/linkerscript/phdrs-has-program.test
test/elf/linkerscript/phdrs-load-empty.test
test/elf/linkerscript/phdrs-load-filehdr.test
test/elf/linkerscript/phdrs-load-phdrs.test
test/elf/linkerscript/phdrs-misplaced-program.test
test/elf/linkerscript/phdrs-no-program.test
test/elf/linkerscript/phdrs-one-none.test
test/elf/linkerscript/phdrs-program-good-phdrs.test
test/elf/linkerscript/phdrs-same-flags.test
test/elf/linkerscript/phdrs-same.test
test/elf/linkerscript/sections-dup-name.test
|