summaryrefslogtreecommitdiff
path: root/src/wasm-linker.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm-linker.h')
-rw-r--r--src/wasm-linker.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/wasm-linker.h b/src/wasm-linker.h
index 3660b3038..76ea62d7d 100644
--- a/src/wasm-linker.h
+++ b/src/wasm-linker.h
@@ -58,6 +58,7 @@ class LinkerObject {
struct SymbolInfo {
std::unordered_set<cashew::IString> implementedFunctions;
std::unordered_set<cashew::IString> undefinedFunctions;
+ std::unordered_set<cashew::IString> importedObjects;
// TODO: it's not clear that this really belongs here.
std::unordered_map<cashew::IString, SymbolAlias> aliasedSymbols;
@@ -70,6 +71,8 @@ class LinkerObject {
}
implementedFunctions.insert(other.implementedFunctions.begin(),
other.implementedFunctions.end());
+ importedObjects.insert(other.importedObjects.begin(),
+ other.importedObjects.end());
aliasedSymbols.insert(other.aliasedSymbols.begin(),
other.aliasedSymbols.end());
}
@@ -86,18 +89,20 @@ class LinkerObject {
globls.push_back(name);
}
- void addRelocation(Relocation::Kind kind, uint32_t* target, Name name, int addend) {
- relocations.emplace_back(new Relocation(kind, target, name, addend));
- }
-
- Relocation* getCurrentRelocation() {
- return relocations.back().get();
+ // This takes ownership of the added Relocation
+ void addRelocation(Relocation* relocation) {
+ relocations.emplace_back(relocation);
}
bool isFunctionImplemented(Name name) {
return symbolInfo.implementedFunctions.count(name) != 0;
}
+ // An object is considered implemented if it is not imported
+ bool isObjectImplemented(Name name) {
+ return symbolInfo.importedObjects.count(name) == 0;
+ }
+
// If name is an alias, return what it points to. Otherwise return name.
Name resolveAlias(Name name, Relocation::Kind kind) {
auto aliased = symbolInfo.aliasedSymbols.find(name);