This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Linkerscript: support ABSOLUTE keyword in symbol assignment expression
ClosedPublic

Authored by evgeny777 on Sep 1 2016, 8:10 AM.

Details

Summary

ABSOLUTE keyword is supported only in symbol assignment expression, i.e

a = ABSOLUTE(.);

In reality it's more complex than that, but full support requires rewriting significant part of script parser.

Diff Detail

Event Timeline

evgeny777 updated this revision to Diff 70003.Sep 1 2016, 8:10 AM
evgeny777 retitled this revision from to [ELF] Linkerscript: support ABSOLUTE keyword in symbol assignment expression.
evgeny777 updated this object.
evgeny777 added reviewers: ruiu, rafael.
evgeny777 set the repository for this revision to rL LLVM.
evgeny777 added a project: lld.
evgeny777 added subscribers: ikudrin, grimar, llvm-commits.
grimar added inline comments.Sep 1 2016, 8:48 AM
ELF/LinkerScript.cpp
1170

readParenExpr ?

ruiu added inline comments.Sep 1 2016, 1:41 PM
ELF/LinkerScript.cpp
277

Needs comment.

281

Early return.

284–285

Why do you have to replace a symbol here only when it is an absolute symbol?

evgeny777 added inline comments.Sep 1 2016, 1:46 PM
ELF/LinkerScript.cpp
284–285

Because it is initially created as synthetic in addSynthetic()

ruiu added inline comments.Sep 1 2016, 3:33 PM
ELF/LinkerScript.cpp
284–285

Why don't you create that as a DefinedRegular symbol from the beginning?

evgeny777 added inline comments.Sep 2 2016, 2:07 AM
ELF/LinkerScript.cpp
284–285

To avoid creating symbol if section is discarded for some reason. Initially all section symbols are created as synthetics with Section pointer set to nullptr. If lld does not create output section those symbols will not be added to symbol table. Not sure, though, if it is right behavior if ABSOLUTE keyword is present

evgeny777 updated this revision to Diff 70313.Sep 5 2016, 3:00 AM
evgeny777 removed rL LLVM as the repository for this revision.

Diff updated. Symbols defined in empty regular output sections do not work correctly in current version (you get symbol with invalid section index)
in symtab. I'll make a separate review for this.

ruiu accepted this revision.Sep 6 2016, 5:47 PM
ruiu edited edge metadata.

LGTM with a few nits.

ELF/LinkerScript.cpp
189

This seems to be dead.

1166–1167
if (skip("ABSOLUTE")) {
This revision is now accepted and ready to land.Sep 6 2016, 5:47 PM
This revision was automatically updated to reflect the committed changes.