Skip to content

Commit 8b1edc0

Browse files
committed
Revert "[ELF] Remove redundant isExported computation"
This reverts commit 1a4d6de. It causes problems with `-static-pie`. See repro at 1a4d6de#commitcomment-151827775
1 parent 8cc83b6 commit 8b1edc0

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

lld/ELF/Config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,6 @@ struct Ctx : CommonLinkerContext {
619619
};
620620
ElfSym sym{};
621621
std::unique_ptr<SymbolTable> symtab;
622-
SmallVector<Symbol *, 0> synthesizedSymbols;
623622

624623
SmallVector<std::unique_ptr<MemoryBuffer>> memoryBuffers;
625624
SmallVector<ELFFileBase *, 0> objectFiles;

lld/ELF/Writer.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ static Defined *addOptionalRegular(Ctx &ctx, StringRef name, SectionBase *sec,
149149
if (!s || s->isDefined() || s->isCommon())
150150
return nullptr;
151151

152-
ctx.synthesizedSymbols.push_back(s);
153152
s->resolve(ctx, Defined{ctx, ctx.internalFile, StringRef(), STB_GLOBAL,
154153
stOther, STT_NOTYPE, val,
155154
/*size=*/0, sec});
@@ -283,7 +282,6 @@ static void demoteDefined(Defined &sym, DenseMap<SectionBase *, size_t> &map) {
283282
static void demoteSymbolsAndComputeIsPreemptible(Ctx &ctx) {
284283
llvm::TimeTraceScope timeScope("Demote symbols");
285284
DenseMap<InputFile *, DenseMap<SectionBase *, size_t>> sectionIndexMap;
286-
bool hasDynSymTab = ctx.arg.hasDynSymTab;
287285
for (Symbol *sym : ctx.symtab->getSymbols()) {
288286
if (auto *d = dyn_cast<Defined>(sym)) {
289287
if (d->section && !d->section->isLive())
@@ -296,12 +294,11 @@ static void demoteSymbolsAndComputeIsPreemptible(Ctx &ctx) {
296294
sym->type)
297295
.overwrite(*sym);
298296
sym->versionId = VER_NDX_GLOBAL;
299-
if (sym->includeInDynsym(ctx))
300-
sym->isExported = true;
301297
}
302298
}
303299

304-
if (hasDynSymTab)
300+
sym->isExported = sym->includeInDynsym(ctx);
301+
if (ctx.arg.hasDynSymTab)
305302
sym->isPreemptible = sym->isExported && computeIsPreemptible(ctx, *sym);
306303
}
307304
}
@@ -1839,11 +1836,6 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
18391836
}
18401837
}
18411838

1842-
// If the previous code block defines any non-hidden symbols (e.g.
1843-
// __global_pointer$), they may be exported.
1844-
for (Symbol *sym : ctx.synthesizedSymbols)
1845-
sym->isExported = sym->includeInDynsym(ctx);
1846-
18471839
demoteSymbolsAndComputeIsPreemptible(ctx);
18481840

18491841
if (ctx.arg.copyRelocs && ctx.arg.discard != DiscardPolicy::None)

0 commit comments

Comments
 (0)