@@ -255,16 +255,19 @@ void elf::addReservedSymbols() {
255
255
// DT_NEEDED. If that happens, replace ShardSymbol with Undefined to avoid
256
256
// dangling references to an unneeded DSO. Use a weak binding to avoid
257
257
// --no-allow-shlib-undefined diagnostics. Similarly, demote lazy symbols.
258
- static void demoteSymbols () {
258
+ static void demoteSymbolsAndComputeIsPreemptible () {
259
259
llvm::TimeTraceScope timeScope (" Demote symbols" );
260
260
for (Symbol *sym : symtab.getSymbols ()) {
261
261
auto *s = dyn_cast<SharedSymbol>(sym);
262
- if (!(s && !cast<SharedFile>(s->file )->isNeeded ) && !sym->isLazy ())
263
- continue ;
264
- uint8_t binding = sym->isLazy () ? sym->binding : uint8_t (STB_WEAK);
265
- Undefined (nullptr , sym->getName (), binding, sym->stOther , sym->type )
266
- .overwrite (*sym);
267
- sym->versionId = VER_NDX_GLOBAL;
262
+ if (sym->isLazy () || (s && !cast<SharedFile>(s->file )->isNeeded )) {
263
+ uint8_t binding = sym->isLazy () ? sym->binding : uint8_t (STB_WEAK);
264
+ Undefined (nullptr , sym->getName (), binding, sym->stOther , sym->type )
265
+ .overwrite (*sym);
266
+ sym->versionId = VER_NDX_GLOBAL;
267
+ }
268
+
269
+ if (config->hasDynSymTab )
270
+ sym->isPreemptible = computeIsPreemptible (*sym);
268
271
}
269
272
}
270
273
@@ -1954,12 +1957,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
1954
1957
}
1955
1958
}
1956
1959
1957
- demoteSymbols ();
1958
- if (config->hasDynSymTab ) {
1959
- parallelForEach (symtab.getSymbols (), [](Symbol *sym) {
1960
- sym->isPreemptible = computeIsPreemptible (*sym);
1961
- });
1962
- }
1960
+ demoteSymbolsAndComputeIsPreemptible ();
1963
1961
1964
1962
// Change values of linker-script-defined symbols from placeholders (assigned
1965
1963
// by declareSymbols) to actual definitions.
0 commit comments