-
Notifications
You must be signed in to change notification settings - Fork 12.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LLD] LLD can report "unable to move location counter backward" error too early #66836
Comments
The problem in the linker script is:
The size of I was about to send a similar patch, but I want to construct a minimal test first. Therefore, I suggested
as a temporary workaround. |
@llvm/issue-subscribers-lld-elf
I have the following linker script:
which would often report this error: However, on subsequent calls to The issue here is that lld will still throw this error from the first run even though all the sections can fit as expected in the final memory region after the fixed point loop has finished. I think the right approach here is that LLD should only return this error if DOT ends up moving backwards for the final call to this function, similar to how we delay checking of memory region sizes until the very end of linking. TODO: Come up with a public-facing minimal reproducer. I haven't made one yet because it's too hard. |
The size of .ARM.exidx may shrink across `assignAddress` calls. It is possible that the initial iteration has a larger location counter, causing `__code_size = __code_end - .; osec : { . += __code_size; }` to report an error, while the error would have been suppressed for subsequent `assignAddress` iterations. Other sections like .relr.dyn may change sizes across `assignAddress` calls as well. However, their initial size is zero, so it is difficiult to trigger a similar error. Similar to https://reviews.llvm.org/D152170, postpone the error reporting. Fix llvm#66836. While here, add more information to the error message.
The size of .ARM.exidx may shrink across `assignAddress` calls. It is possible that the initial iteration has a larger location counter, causing `__code_size = __code_end - .; osec : { . += __code_size; }` to report an error, while the error would have been suppressed for subsequent `assignAddress` iterations. Other sections like .relr.dyn may change sizes across `assignAddress` calls as well. However, their initial size is zero, so it is difficiult to trigger a similar error. Similar to https://reviews.llvm.org/D152170, postpone the error reporting. Fix #66836. While here, add more information to the error message.
I have the following linker script:
which would often report this error:
unable to move location counter backward for: .shared_ram.unused_space
. This is because on the first call toscript->assignAddresses();
infinalizeAddressDependentContent
, all of the input data sections placed into.data
exceeds the remaining space for RAM_DATA, so by the time we reach. = ABSOLUTE(ram_data_end);
, DOT is well past the end of RAM_DATA.However, on subsequent calls to
script->assignAddresses()
in the fixed-point loop infinalizeAddressDependentContent
, the start of.data
is changed and a smaller value than the first iteration because something was changed in previous sections. This could be from linker relaxations, sections being removed, allocation sizes changing, etc. Because the starting address of.data
is smaller but all the input data sections remain the same, it's possible for subsequent runs ofscript->assignAddresses()
to not throw the same error because it happens to fit.The issue here is that lld will still throw this error from the first run even though all the sections can fit as expected in the final memory region after the fixed point loop has finished. I think the right approach here is that LLD should only return this error if DOT ends up moving backwards for the final call to this function, similar to how we delay checking of memory region sizes until the very end of linking.
TODO: Come up with a public-facing minimal reproducer. I haven't made one yet because it's too hard.
The text was updated successfully, but these errors were encountered: