[PATCH] D39489: [ELF] - Linkerscript: fix issue with multiple output sections definitions.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 15 07:20:34 PST 2017
grimar added inline comments.
================
Comment at: ELF/ScriptParser.cpp:974
StringRef Name = readParenLiteral();
- OutputSection *Sec = Script->getOrCreateOutputSection(Name);
+ Script->declareOutputSection(Name);
return [=]() -> ExprValue {
----------------
peter.smith wrote:
> If I understand correctly this might create a forward reference to some OutputSection Name that we've not seen yet? I don't think that this is allowed in this case: https://sourceware.org/binutils/docs/ld/Builtin-Functions.html
> > Return the address (VMA) of the named section. Your script must previously have defined the location of that section.
>
It is actually what original code did already before my change. `getOrCreateOutputSection` creates forward reference.
We rely on that in our testcases, for example absolute.s has just:
"PROVIDE(foo = 1 + ABSOLUTE(ADDR(.text)));" and expects we can evaluate that. I believe we have the same
behavior as gnu linkers here.
Below you referenced to spec saying that for ALIGNOF "If the section *has not been allocated* when this is evaluated, the linker will report an error.". I think that is how it should say for all commands you mentioned.
We use `checkIfExists` to verify that section was allocated at the moment when we call evaluation of `ADDR` or other commands, and for parsing script we create forward references atm.
https://reviews.llvm.org/D39489
More information about the llvm-commits
mailing list