summaryrefslogtreecommitdiffstats
path: root/lld/wasm
diff options
context:
space:
mode:
Diffstat (limited to 'lld/wasm')
-rw-r--r--lld/wasm/Writer.cpp58
1 files changed, 30 insertions, 28 deletions
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 9ae020e0f61..d8986c83738 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -903,40 +903,42 @@ void Writer::assignSymtab() {
StringMap<uint32_t> SectionSymbolIndices;
unsigned SymbolIndex = SymtabEntries.size();
- for (ObjFile *File : Symtab->ObjectFiles) {
- LLVM_DEBUG(dbgs() << "Symtab entries: " << File->getName() << "\n");
- for (Symbol *Sym : File->getSymbols()) {
- if (Sym->getFile() != File)
- continue;
-
- if (auto *S = dyn_cast<SectionSymbol>(Sym)) {
- StringRef Name = S->getName();
- if (CustomSectionMapping.count(Name) == 0)
- continue;
-
- auto SSI = SectionSymbolIndices.find(Name);
- if (SSI != SectionSymbolIndices.end()) {
- Sym->setOutputSymbolIndex(SSI->second);
- continue;
- }
- SectionSymbolIndices[Name] = SymbolIndex;
- CustomSectionSymbols[Name] = cast<SectionSymbol>(Sym);
+ auto AddSymbol = [&](Symbol *Sym) {
+ if (auto *S = dyn_cast<SectionSymbol>(Sym)) {
+ StringRef Name = S->getName();
+ if (CustomSectionMapping.count(Name) == 0)
+ return;
- Sym->markLive();
+ auto SSI = SectionSymbolIndices.find(Name);
+ if (SSI != SectionSymbolIndices.end()) {
+ Sym->setOutputSymbolIndex(SSI->second);
+ return;
}
- // (Since this is relocatable output, GC is not performed so symbols must
- // be live.)
- assert(Sym->isLive());
- Sym->setOutputSymbolIndex(SymbolIndex++);
- SymtabEntries.emplace_back(Sym);
+ SectionSymbolIndices[Name] = SymbolIndex;
+ CustomSectionSymbols[Name] = cast<SectionSymbol>(Sym);
+
+ Sym->markLive();
}
- }
- // For the moment, relocatable output doesn't contain any synthetic functions,
- // so no need to look through the Symtab for symbols not referenced by
- // Symtab->ObjectFiles.
+ // (Since this is relocatable output, GC is not performed so symbols must
+ // be live.)
+ assert(Sym->isLive());
+ Sym->setOutputSymbolIndex(SymbolIndex++);
+ SymtabEntries.emplace_back(Sym);
+ };
+
+ for (Symbol *Sym : Symtab->getSymbols())
+ if (!Sym->isLazy())
+ AddSymbol(Sym);
+
+ for (ObjFile *File : Symtab->ObjectFiles) {
+ LLVM_DEBUG(dbgs() << "Local symtab entries: " << File->getName() << "\n");
+ for (Symbol *Sym : File->getSymbols())
+ if (Sym->isLocal())
+ AddSymbol(Sym);
+ }
}
uint32_t Writer::lookupType(const WasmSignature &Sig) {
OpenPOWER on IntegriCloud