-
Notifications
You must be signed in to change notification settings - Fork 10.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
LLD 18 leaves leaves behind undef symbols from discarded sections #85048
Comments
@llvm/issue-subscribers-lld-elf Author: Nikita Popov (nikic)
After https://github.com/llvm/llvm-project/commit/1981b1b6b92f7579a30c9ed32dbdf3bc749c1b40, LLD converts symbols in discarded sections into undef symbols. This happens even if there are no references to the symbol from non-discarded sections.
This change breaks building the Linux kernel with LLD in some configurations ( To reproduce the issue: test.c:
module.lds:
Then run:
This will produce:
While previously it did not. |
At Google, we noticed a related issue (internal 307561801) in our Linux kernel builds, but we believed it was specific to Google-internal build configurations, and that the LLD behavior was correct. |
llvm#69295 demoted Defined symbols relative to discarded sections. If such a symbol is unreferenced, the desired behavior is to eliminate it from .symtab just like --gc-sections discarded definitions. Linux kernel's CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y configuration expects that the unreferenced `unused` is not emitted to .symtab (ClangBuiltLinux/linux#2006). For relocations referencing demoted symbols, the symbol index restores to 0 like older lld (`R_X86_64_64 0` in `discard-section.s`). Fix llvm#85048
Thanks for the detailed reproduce. A few changes have depended on this representation, so dropping |
…85167) #69295 demoted Defined symbols relative to discarded sections. If such a symbol is unreferenced, the desired behavior is to eliminate it from .symtab just like --gc-sections discarded definitions. Linux kernel's CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y configuration expects that the unreferenced `unused` is not emitted to .symtab (ClangBuiltLinux/linux#2006). For relocations referencing demoted symbols, the symbol index restores to 0 like older lld (`R_X86_64_64 0` in `discard-section.s`). Fix #85048
/cherry-pick 8fe3e70 |
…lvm#85167) llvm#69295 demoted Defined symbols relative to discarded sections. If such a symbol is unreferenced, the desired behavior is to eliminate it from .symtab just like --gc-sections discarded definitions. Linux kernel's CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y configuration expects that the unreferenced `unused` is not emitted to .symtab (ClangBuiltLinux/linux#2006). For relocations referencing demoted symbols, the symbol index restores to 0 like older lld (`R_X86_64_64 0` in `discard-section.s`). Fix llvm#85048 (cherry picked from commit 8fe3e70)
/pull-request #85266 |
After 1981b1b, LLD converts symbols in discarded sections into undef symbols. This happens even if there are no references to the symbol from non-discarded sections.
This change breaks building the Linux kernel with LLD in some configurations (
CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y
) and does not match the behavior of previous LLD versions or the behavior of the BFD linker.To reproduce the issue:
test.c:
module.lds:
Then run:
This will produce:
While previously it did not.
The text was updated successfully, but these errors were encountered: