This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Support ABSOLUTE on the right hand side in linkerscripts
ClosedPublic

Authored by phosek on Mar 10 2017, 3:09 PM.

Details

Summary

This also requires postponing the assignment the assignment of symbols defined in input linker scripts since those can refer to output sections and in case we don't have a SECTIONS command, we need to wait until all output sections have been created and assigned addresses.

Diff Detail

Repository
rL LLVM

Event Timeline

phosek created this revision.Mar 10 2017, 3:09 PM
phosek updated this revision to Diff 91428.Mar 10 2017, 3:14 PM
grimar added a subscriber: grimar.Mar 13 2017, 2:49 AM
grimar added inline comments.
ELF/LinkerScript.cpp
764

That can be shorter:

for (const std::unique_ptr<BaseCommand> &Base : Opt.Commands) {
  if (auto *Cmd = dyn_cast<SymbolAssignment>(Base.get()))
    assignSymbol(Cmd);
  else if (auto *Cmd = dyn_cast<AssertCommand>(Base.get()))
    Cmd->Expression();
}

Also name of method doesn't really corresponds to what it do, it also processes AssertCommand, not just
assign symbols.

1834

I think you could just

expect(")");
return E;
test/ELF/linkerscript/absolute.s
8

you don't need to add "requires x86" and to run llvm-mc again.

phosek updated this revision to Diff 91604.Mar 13 2017, 12:30 PM
phosek marked 3 inline comments as done.
ruiu edited edge metadata.Mar 13 2017, 1:23 PM

Does this compile? I cannot find a definition of processNonSectionCommands function.

phosek updated this revision to Diff 91610.Mar 13 2017, 1:27 PM

Should be fixed now.

ruiu added a comment.Mar 13 2017, 1:34 PM

Generally looking good, but this might conflict with https://reviews.llvm.org/D30891. Rafael?

ELF/LinkerScript.cpp
1829

Can you add this at the start of this list? They should be sorted alphabetically. I'll do that later.

1830

You can use readParenExpr.

phosek updated this revision to Diff 91611.Mar 13 2017, 1:40 PM
phosek marked 2 inline comments as done.
ruiu accepted this revision.Mar 14 2017, 8:29 PM

LGTM

This revision is now accepted and ready to land.Mar 14 2017, 8:29 PM
This revision was automatically updated to reflect the committed changes.