[ELF] Fix includeInDynsym() when an undefined weak is merged with a lazy definition
An undefined weak does not fetch the lazy definition. A lazy weak symbol
should be considered undefined, and thus preemptible if .dynsym exists.
D71795 is not quite an NFC. It errors on an R_X86_64_PLT32 referencing
an undefined weak symbol. isPreemptible is false (incorrect) => R_PLT_PC
is optimized to R_PC => in isStaticLinkTimeConstant, an error is emitted
when an R_PC is applied on an undefined weak (considered absolute).
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index a9e3645..f0f6121 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -277,8 +277,10 @@
return false;
if (computeBinding() == STB_LOCAL)
return false;
+ if (!isDefined() && !isCommon())
+ return true;
- return isUndefined() || isShared() || exportDynamic || inDynamicList;
+ return exportDynamic || inDynamicList;
}
// Print out a log message for --trace-symbol.