Details
- Reviewers
ruiu
Diff Detail
- Repository
- rL LLVM
Event Timeline
That's what I tried initially, but I don't think it's correct. The problem is that if I use {A.Sec, A.ForceAbsolute, A.getValue() + B.getValue(), A.Loc}, the section offset (if A.Sec != nullptr) will get applied twice. If I use A.getValue() + B.getValue() the resulting expression will be absolute and not section relative as it should be if A is.
Added a test case, which revealed another issue: while trying PROVIDE_HIDDEN(newsym = ALIGN(_end, CONSTANT(MAXPAGESIZE)) + 5);, I noticed it was working fine in our project but not in LLD. Turned the problem is that we also use a linker script which defines PROVIDE_HIDDEN(_end = .). However, when using only input linker script, this breaks because LLD only finalizes the _end value in fixPredefinedSymbols after all symbol assignment commands have been processed, so newsym will get a wrong value. This change still fixes the case when script is being used.
The test you added doesn't seem to exercise the code you added. Don't you need something like ALIGN(3, 8) + 10 to test that?
I have added few more test cases. This one is still useful because it checks that the relative case works with alignment (i.e. it'd break if we used A.getValue() + B.getValue() or A.getValue() - B.getValue()).