This is an archive of the discontinued LLVM Phabricator instance.

Remove LinkerScript::flush
ClosedPublic

Authored by rafael on Apr 27 2017, 12:14 PM.

Details

Reviewers
peter.smith
ruiu
Summary

This patch replaces flush with a last ditch attempt at synchronizing the section list with the linker script "AST".

The synchronization in a bit of a hack and should in time be avoided by creating the AST earlier so that modifications can be made directly to it instead of modifying the section list and synchronizing it back.

This is the main step for fixing https://bugs.llvm.org/show_bug.cgi?id=32816. With this in place I think the only missing thing would be to have processCommands assign section indexes as dummy offsets so that the sort in OutputSection::finalize works.

With this LinkerScript::assignAddresses becomes much simpler, which should help with the thunk work.

Diff Detail

Event Timeline

rafael created this revision.Apr 27 2017, 12:14 PM
ruiu edited reviewers, added: ruiu; removed: rui314.Apr 27 2017, 1:11 PM
ruiu accepted this revision.Apr 27 2017, 2:41 PM

LGTM. I think this is towards a right direction.

ELF/LinkerScript.cpp
818

This needs a comment.

This revision is now accepted and ready to land.Apr 27 2017, 2:41 PM
peter.smith edited edge metadata.Apr 27 2017, 4:30 PM

This looks good to me too.

One thing I observed when writing the code in the initial Thunks submission to insert the Thunks back into the InputSectionDescriptions was that the order of OutputSections::Sections should match the order of InputSectionDescription::Sections (on the assumption that any additional Sections added to OutputSections::Sections were added on the end). If I'm correct I think you may be able to:

  • Extract the last InputSectionBase from the last InputSectionDescription
  • Find this section in OutputSection::Sections
  • From the next section to the end of OutputSection::Sections should be your missing sections.

I may have missed something though.

Looking forward we'll need to make some changes to OutputSections::finalize(), if there are orphan link-order sections (the sentinel .ARM.exidx) for example they will get added to a new InputSectionDescription. The current sort of link order sections will only work on a single InputSectionDescription. When I get back to the office on Tuesday I'll rebase D32233, and my Thunks patches on top of this.

espindola closed this revision.Mar 14 2018, 4:08 PM
espindola added a subscriber: espindola.

301745