[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


================
@@ -722,6 +722,27 @@ template <class ELFT> void Writer<ELFT>::copyLocalSymbols() {
       // No reason to keep local undefined symbol in symtab.
       if (!dr)
         continue;
+
+      // Demote locals which did not end up in any partition. This is similar
+      // to what we do in Driver.cpp, but that only works on globals.
+      if (script->seenDiscard && dr->section && !dr->section->isLive()) {
----------------
MaskRay wrote:

We do not need this copy. This can be unified with Driver.cpp. See https://github.com/maskray/llvm-project/tree/lld-symbols-in-discard

https://github.com/llvm/llvm-project/pull/68777


More information about the llvm-commits mailing list