-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Lazy files extracted post LTO compilation might reference other lazy bitcode files, leading to incorrect absolute defined symbols #127284
Comments
@llvm/issue-subscribers-lld-elf Author: Alexander Richardson (arichardson)
I was trying to build an arm32 binary that uses 64-bit division a LTO build of compiler-rt.
The 64-bit division function in compiler-rt ( __aeabi_ldivmod dump:
I discussed this issue with @ilovepi and it appears that one problem here is that the call to __aeabi_ldivmod is generated post-LTO and the __divmoddi4 symbol is marked as not needed before final codegen.
This suggests __divmoddi4 was replaced with and absolute zero symbol. |
I would guess that this is the same bug that @ilovepi and @mysterymath have been chasing plus another bug. That is, the fact that the proper definition of |
Added some notes to my https://gist.github.com/MaskRay/24f4e2eed208b9d8b0a3752575a665d4 This is another variant of the "Symbols unknown to the IR symbol table" problem: Lazy files extracted post LTO compilation might reference other lazy files. Referenced relocatable files are extracted and everything works as intended. However, if the referenced lazy file is a bitcode file, no further LTO compilation occurs. lld currently treats any symbols from that bitcode file as absolute, which leads to a "refer to absolute symbol" error in PIC links and leads to silently broken output. For example, lazy aeabi_ldivmod.o post LTO extraction might call |
…calls This can happen when using a LTO build of compiler-rt for ARM and the program uses 64-bit division. The 64-bit division function in compiler-rt (__aeabi_ldivmod) is written in assembly and calls the C function __divmoddi4, which works fine in non-LTO links. However, when building with LTO the call inside __aeabi_ldivmod is replaced with a jump to address zero, which then crashes the program. Building with -pie generates an error instead of a jump to address zero, and surprisingly just declaring the __aeabi_ldivmod function (but not calling it) in the input IR also avoids this issue. Reported as #127284 Co-authored-by: Fangrui Song <i@maskray.me> Reviewed By: MaskRay Pull Request: #127286
…st runtime calls This can happen when using a LTO build of compiler-rt for ARM and the program uses 64-bit division. The 64-bit division function in compiler-rt (__aeabi_ldivmod) is written in assembly and calls the C function __divmoddi4, which works fine in non-LTO links. However, when building with LTO the call inside __aeabi_ldivmod is replaced with a jump to address zero, which then crashes the program. Building with -pie generates an error instead of a jump to address zero, and surprisingly just declaring the __aeabi_ldivmod function (but not calling it) in the input IR also avoids this issue. Reported as llvm/llvm-project#127284 Co-authored-by: Fangrui Song <i@maskray.me> Reviewed By: MaskRay Pull Request: llvm/llvm-project#127286
…calls This can happen when using a LTO build of compiler-rt for ARM and the program uses 64-bit division. The 64-bit division function in compiler-rt (__aeabi_ldivmod) is written in assembly and calls the C function __divmoddi4, which works fine in non-LTO links. However, when building with LTO the call inside __aeabi_ldivmod is replaced with a jump to address zero, which then crashes the program. Building with -pie generates an error instead of a jump to address zero, and surprisingly just declaring the __aeabi_ldivmod function (but not calling it) in the input IR also avoids this issue. Reported as llvm#127284 Co-authored-by: Fangrui Song <i@maskray.me> Reviewed By: MaskRay Pull Request: llvm#127286
I was trying to build an arm32 binary that uses 64-bit division a LTO build of compiler-rt.
The 64-bit division function in compiler-rt (
__aeabi_ldivmod
) is written in assembly and calls the C function__divmoddi4
, which works fine normally. However, when building with LTO the call inside __aeabi_ldivmod is replaced with a jump to address zero, which then crashes my program.__aeabi_ldivmod dump:
I discussed this issue with @ilovepi and it appears that one problem here is that the call to __aeabi_ldivmod is generated post-LTO and the __divmoddi4 symbol is marked as not needed before final codegen.
However, it does seem like lld should be reporting an error for the missing __divmoddi4 instead of using address zero (it is not marked as weak, so that is invalid).
When building with
-pie
instead of position dependent static linking, I do get an error:This suggests __divmoddi4 was replaced with and absolute zero symbol.
I have created a minimized test case which I will upload as a PR shortly.
The text was updated successfully, but these errors were encountered: