Fixes PR35744.
Bug happens because of different nature of reserved symbols.
We add them with value -1 and output section as target section:
auto Add = [](StringRef S, int64_t Pos) { return addOptionalRegular(S, Out::ElfHeader, Pos, STV_DEFAULT); }; ElfSym::Etext1 = Add("etext", -1);
Then out code handles -1 as special case:
uint64_t SectionBase::getOffset(uint64_t Offset) const { ... // For output sections we treat offset -1 as the end of the section. return Offset == uint64_t(-1) ? OS->Size : Offset;
Though when we handle scripts and particulary expressions like
foo = etext + 1;
this might change special (-1) value and break things.
Patch fixes the issue.
In general, when you change existing code, you should update the comment instead of adding sentences to existing comment so that the comment doesn't look patchy. Comments shouldn't reflect the history of code change but just describe why we are doing this.
So, this is just that if an expression is absolute and has no alignment requirement, its value is simply the output value, no?