This is an archive of the discontinued LLVM Phabricator instance.

[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.
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.

Diff Detail

Event Timeline

denis-protivensky retitled this revision from to [lld][LinkerScript] Consider order of headers in PHDRS command.
denis-protivensky updated this object.
denis-protivensky added a project: lld.
denis-protivensky added a subscriber: llvm-commits.
rafaelauler edited edge metadata.Aug 14 2015, 12:16 PM

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.

emaste added a subscriber: emaste.Aug 18 2015, 3:58 AM

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.

Updated:

  • Remove check for duplicate names of output sections.
rafaelauler accepted this revision.Sep 2 2015, 5:17 AM
rafaelauler edited edge metadata.

LGTM

This revision is now accepted and ready to land.Sep 2 2015, 5:17 AM
denis-protivensky abandoned this revision.Sep 18 2015, 8:37 AM

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.