-
Notifications
You must be signed in to change notification settings - Fork 15
--pic-vineer
for arm32 lld
#286
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
Comments
I tested this patch with
I'm exhausted so debugging probably isn't a great idea at the moment but I should be able to triage further tomorrow (unless someone beats me to it). Just an FYI, |
GCC never uses place-relative movw/movt pairs, and while it seems appealing for position independent code, the fact that ARM uses REL type relocations (which put the addend in the place rather in than in the relocation), and the fact that the addend needs to be duplicated between the two instructions (or you wouldn't be able to handle a carry between the low and the high part ), the addend range is only [-32k, 32k), and I am not surprised this breaks when building an allyesconfig kernel (which is huge) I know Clang does support -mno-movt, but this gets rid of movw/movt pairs entirely, which would be unfortunate. |
Ah, so that particular set of errors is something that needs to fixed/addressed in Clang? |
cc @smithp35 |
I will take a look when I get back to the office next January. I'm interested to see where the PC-Relative use of movt/movw comes from. They should only be generated from compiled code when position independent, but when -fpic or -fpie is used it looks like care is taken to avoid using movt/movw. |
The implementation of ARMV7PILongThunk emits place-relative movw/movt pairs. My suspicion is that calls from __init code to ordinary code with static linkage in the same object file is causing the addends to overflow here, since the .init code section is far away from the ordinary code section, and the .text section will be much larger than 32 KB on a allyesconfig kernel. I think this is a fundamental problem that could occur in any large program where functions in the same object file may be emitted into different ELF sections, e.g., hot/cold partitioning or -ffunction-sections. So perhaps the V7 PI long thunk should be dropped entirely in favor of the v5 one. |
Thanks for the pointer. I have made an example with a simple reproducer:
high: bl low SECTIONS { ld.lld test.o -o test.axf -fpie --script=test.lds This is consistent with the overflow checking for the movt relocation looking for a signed 32-bit integer, and also why we haven't seen this before as LLD has tended to be used on applications with continuous address spaces. I don't think that this overflow behaviour is right (at the stage that it is being evaluated) so I'll have to investigate both the overflow behaviour and what thunks are appropriate next year. |
I've submitted https://reviews.llvm.org/D56396 that should fix the relocation overflow problem. The ELF for the ARM Architecture document states that the relocations shouldn't have overflow checking, and it is possible for LLD to inject the values it needs to into the movt/movw pair so I've done that. |
OK, so the limited range of the addend is not a problem here since we never actually have to deal with the static relocation in the thunk case, right? |
Yes, in this particular case we are just reusing the part of the relocation code that encodes the final result so we don't have to deal with the encoding of the addend in the relocation. |
Looks like both are now fixed. @smithp35 , will these been in lld-8, or do we need to ask Hans to pick these up? |
--pic-veneer just missed the branch. I've created https://llvm.org/pr40352 and linked it to the 8.0 release https://llvm.org/pr40331 as a blocker. |
Added to the 8.0 branch: llvm/llvm-project@37174c6 Thanks @smithp35! |
https://reviews.llvm.org/D55505
The text was updated successfully, but these errors were encountered: