@@ -285,7 +285,6 @@ static void demoteSymbolsAndComputeIsPreemptible(Ctx &ctx) {
285285 llvm::TimeTraceScope timeScope (" Demote symbols" );
286286 DenseMap<InputFile *, DenseMap<SectionBase *, size_t >> sectionIndexMap;
287287 bool hasDynsym = ctx.hasDynsym ;
288- bool maybePreemptible = ctx.sharedFiles .size () || ctx.arg .shared ;
289288 for (Symbol *sym : ctx.symtab ->getSymbols ()) {
290289 if (auto *d = dyn_cast<Defined>(sym)) {
291290 if (d->section && !d->section ->isLive ())
@@ -302,8 +301,7 @@ static void demoteSymbolsAndComputeIsPreemptible(Ctx &ctx) {
302301 }
303302
304303 if (hasDynsym)
305- sym->isPreemptible = maybePreemptible &&
306- (sym->isUndefined () || sym->isExported ) &&
304+ sym->isPreemptible = (sym->isUndefined () || sym->isExported ) &&
307305 computeIsPreemptible (ctx, *sym);
308306 }
309307}
@@ -1944,7 +1942,8 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
19441942
19451943 // computeBinding might localize a linker-synthesized hidden symbol
19461944 // (e.g. __global_pointer$) that was considered exported.
1947- if ((sym->isExported || sym->isPreemptible ) && !sym->isLocal ()) {
1945+ if (ctx.hasDynsym && (sym->isUndefined () || sym->isExported ) &&
1946+ !sym->isLocal ()) {
19481947 ctx.partitions [sym->partition - 1 ].dynSymTab ->addSymbol (sym);
19491948 if (auto *file = dyn_cast<SharedFile>(sym->file ))
19501949 if (file->isNeeded && !sym->isUndefined ())
0 commit comments