If --dynamic-list is given, only those symbols are preemptible.
This allows combining --dynamic-list and version scripts too. The
version script controls which symbols are visible, and
--dynamic-list controls which of those are preemptible.
Unlike previous versions, undefined symbols are still considered
preemptible, which was the issue breaking the cfi tests.
This fixes pr34053.
llvm-svn: 312806
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 1f20657..921d15f 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1245,9 +1245,16 @@
// -unresolved-symbols=ignore-all is specified, undefined symbols in
// executables are automatically exported so that the runtime linker
// can try to resolve them. In that case, they are preemptible. So, we
- // return true for an undefined symbol in case the option is specified.
+ // return true for an undefined symbols in all cases.
+ if (B.isUndefined())
+ return true;
+
+ // If we have a dynamic list it specifies which local symbols are preemptible.
+ if (!Config->DynamicList.empty())
+ return false;
+
if (!Config->Shared)
- return B.isUndefined();
+ return false;
// -Bsymbolic means that definitions are not preempted.
if (Config->Bsymbolic || (Config->BsymbolicFunctions && B.isFunc()))
@@ -1289,7 +1296,7 @@
[](SyntheticSection *SS) { SS->finalizeContents(); });
for (Symbol *S : Symtab->getSymbols())
- S->body()->IsPreemptible = computeIsPreemptible(*S->body());
+ S->body()->IsPreemptible |= computeIsPreemptible(*S->body());
// Scan relocations. This must be done after every symbol is declared so that
// we can correctly decide if a dynamic relocation is needed.