-
Notifications
You must be signed in to change notification settings - Fork 13.5k
lld crash with Wl,-fixup_chains when build ios #94716
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
@llvm/issue-subscribers-lld-macho Author: None (liudikang)
## What did you do?
First we build a go project with gomobile (https://github.com/xxf098/go-tun2socks-build) as a static library,
then linker this static library into our IOS project.
What did you see happen? I found crash position of lld:
After we remove ldflags "-Wl,-fixup_chains" ,or modify llvm code crash not happed. this is crash stack (this lld is build by myself,prebuild is same)
|
Thank you for the report. Could you create a standalone reproducer tarball by executing ld64.lld with the |
this file is too large,I don’t have enough time to deal it today. I'll deal with it on Tue. |
Uploading it to Google Drive or another cloud file sharing platform should be enough. |
When `-fixup_chains`/`-init_offsets` is used, a different section, `__init_offsets` is synthesized from `__mod_init_func`. If there are any symbols defined inside `__mod_init_func`, they are added to the symbol table unconditionally while processing the input files. Later, when querying these symbols' addresses (when constructing the symtab or exports trie), we crash with a null deref, as there is no output section assigned to them. Just making the symbols point to `__init_offsets` is a bad idea, as the new section stores 32-bit integers instead of 64-bit pointers; accessing the symbols would not do what the programmer intended. We should entirely omit them from the output. This is what ld64 and ld-prime do. This patch uses the same mechanism as dead-stripping to mark these symbols as not needed in the output. There might be nicer fixes than the workaround, this is discussed in llvm#97155. Fixes llvm#79894 (comment) Fixes llvm#94716
The repro file in llvm#94716 contains a few thin archives without their member object files present. I couldn't figure out why this happened (issue in repro tarball generation?), but this caused an "unhandled Error" crash on `LLVM_ENABLE_ABI_BREAKING_CHECKS` builds.
Hello! I'm working on a fix for your issue, it should be ready very soon. There is a pretty strange issue with your repro file, though. It seems to contain thin archives that reference files that don't actually exist anywhere:
None of these exist (the paths are relative to the extracted repro tarball's root directory). This causes an assertion failure in LLD that's built in debug mode (#97169). I'm working on creating a fix for that; could you help me figure out how the issue can be reproduced? Answering these would be very helpful:
|
…97156) When `-fixup_chains`/`-init_offsets` is used, a different section, `__init_offsets` is synthesized from `__mod_init_func`. If there are any symbols defined inside `__mod_init_func`, they are added to the symbol table unconditionally while processing the input files. Later, when querying these symbols' addresses (when constructing the symtab or exports trie), we crash with a null deref, as there is no output section assigned to them. Just making the symbols point to `__init_offsets` is a bad idea, as the new section stores 32-bit integers instead of 64-bit pointers; accessing the symbols would not do what the programmer intended. We should entirely omit them from the output. This is what ld64 and ld-prime do. This patch uses the same mechanism as dead-stripping to mark these symbols as not needed in the output. There might be nicer fixes than the workaround, this is discussed in #97155. Fixes #79894 (comment) Fixes #94716
What did you do?
First we build a go project with gomobile (https://github.com/xxf098/go-tun2socks-build) as a static library,
then linker this static library into our IOS project.
What did you see happen?
lld crashed.
I found crash position of lld:
SymtabSectionImpl<LP>::writeTo
of filelld/MachO/SyntheticSections.cpp
Crashed on this line:
nList->n_sect = defined->isec()->parent->index;
After we remove ldflags "-Wl,-fixup_chains" ,or modify llvm code crash not happed.
this is crash stack (this lld is build by myself,prebuild is same)
The text was updated successfully, but these errors were encountered: