[lld] [lld][ELF] Demote symbols in discarded sections to Undefined. (PR #68777)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 17 01:11:32 PDT 2023
================
@@ -3061,6 +3061,37 @@ void LinkerDriver::link(opt::InputArgList &args) {
script->addOrphanSections();
}
+ // Demote symbols defined relative to input sections that are discarded by
+ // /DISCARD/ so that relocations referencing them will get reported.
+ if (script->seenDiscard) {
----------------
MaskRay wrote:
It's a corner case but I think is worth testing. The demotion logic applies `--gc-sections` as well but we only run the code when `/DISCARD/` is seen, so there will be some behavior differences.
I have updated `lld/test/ELF/gc-sections-tls.s` in https://github.com/MaskRay/llvm-project/tree/lld-symbols-in-discard to test this.
Actually, we probably should do #69295 so that all non-local symbols in discarded sections are demoted, regardless of whether `/DISCARD/` is seen? @smithp35
https://github.com/llvm/llvm-project/pull/68777
More information about the llvm-commits
mailing list