aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/WasmObjectFile.cpp
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2024-07-12 13:26:52 -0700
committerGitHub <noreply@github.com>2024-07-12 13:26:52 -0700
commit22b7b84860d39da71964c9b329937f2ee1d875ba (patch)
tree28e6110b9779b64f1aae86b0b87c88f0e28544c9 /llvm/lib/Object/WasmObjectFile.cpp
parentef8207b579e8b1c242a1c37e00b1615ef95f2220 (diff)
downloadllvm-22b7b84860d39da71964c9b329937f2ee1d875ba.zip
llvm-22b7b84860d39da71964c9b329937f2ee1d875ba.tar.gz
llvm-22b7b84860d39da71964c9b329937f2ee1d875ba.tar.bz2
[lld][WebAssembly] Report undefined symbols in -shared/-pie builds (#75242)
Previously we would ignore all undefined symbols when using `-shared` or `-pie`. All undefined symbols would be treated as imports regardless of whether those symbols we defined in any shared library. With this change we now track symbol in shared libraries and report undefined symbols in the main program by default. The old behavior is still available via the `--unresolved-symbols=import-dynamic` command line flag. This rationale for allowing this type of breaking change is that `-pie` and `-shared` are both still experimental will warn as such, unless `--experimental-pic` is passed. As part of this change the linker now models shared library symbols via new SharedFunctionSymbol and SharedDataSymbol types. I've also added a new `--no-shlib-sigcheck` option that bypassed the checking of functions signature in shared libraries. This is specifically required by emscripten the case where the imports/exports of shared libraries have been modified by via JS type legalization (this is only needed when targeting old JS engines where bigint is not yet available See https://github.com/emscripten-core/emscripten/issues/18198
Diffstat (limited to 'llvm/lib/Object/WasmObjectFile.cpp')
-rw-r--r--llvm/lib/Object/WasmObjectFile.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index 2338195..f244099 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -509,11 +509,14 @@ Error WasmObjectFile::parseNameSection(ReadContext &Ctx) {
llvm::DenseSet<uint64_t> SeenGlobals;
llvm::DenseSet<uint64_t> SeenSegments;
- // If there is symbol info from the export section, this info will supersede
- // it, but not info from a linking section
- if (!HasLinkingSection) {
+ // If we have linking section (symbol table) or if we are parsing a DSO
+ // then we don't use the name section for symbol information.
+ bool PopulateSymbolTable = !HasLinkingSection && !HasDylinkSection;
+
+ // If we are using the name section for symbol information then it will
+ // supersede any symbols created by the export section.
+ if (PopulateSymbolTable)
Symbols.clear();
- }
while (Ctx.Ptr < Ctx.End) {
uint8_t Type = readUint8(Ctx);
@@ -589,7 +592,7 @@ Error WasmObjectFile::parseNameSection(ReadContext &Ctx) {
Index, 0, DataSegments[Index].Data.Content.size()};
}
DebugNames.push_back(wasm::WasmDebugName{nameType, Index, Name});
- if (!HasLinkingSection)
+ if (PopulateSymbolTable)
Symbols.emplace_back(Info, GlobalType, TableType, Signature);
}
break;