[lld] [lld][ELF] Demote symbols in discarded sections to Undefined. (PR #68777)
Peter Smith via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 11 23:45:18 PDT 2023
================
@@ -3062,6 +3062,30 @@ void LinkerDriver::link(opt::InputArgList &args) {
script->addOrphanSections();
}
+ // Explicitly demote symbols which didn't get placed. If we don't, any
+ // symbol in a discarded section will still be considered defined, even
+ // though it didn't end up in the output, and we get silently broken
+ // binaries.
+ if (script->hasSectionsCommand) {
----------------
smithp35 wrote:
Could it be worth adding a script->seenDiscard variable so that this potentially expensive operation is only done when someone has used /DISCARD/ ?
https://github.com/llvm/llvm-project/pull/68777
More information about the llvm-commits
mailing list