summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDominic Chen <d.c.ddcc@gmail.com>2016-07-13 09:03:35 -0700
committerDerek Schuff <dschuff@chromium.org>2016-07-13 09:03:35 -0700
commit1a07fc4cc4f729b116d41e6ea4a6a22207af53b8 (patch)
tree57af95c5753e61c44aa8dac9847fe79850ab65f9 /src
parenta5e2d3a40690e2a258e7e7b13edd6ba37230a7de (diff)
downloadbinaryen-1a07fc4cc4f729b116d41e6ea4a6a22207af53b8.tar.gz
binaryen-1a07fc4cc4f729b116d41e6ea4a6a22207af53b8.tar.bz2
binaryen-1a07fc4cc4f729b116d41e6ea4a6a22207af53b8.zip
Handle aliases without size (e.g. weak symbol), add redefinition warnings (#630)
Diffstat (limited to 'src')
-rw-r--r--src/s2wasm.h19
-rw-r--r--src/wasm-linker.cpp1
2 files changed, 8 insertions, 12 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h
index 8f429f96c..8595bdb44 100644
--- a/src/s2wasm.h
+++ b/src/s2wasm.h
@@ -391,7 +391,8 @@ class S2WasmBuilder {
} else if (match("=")) {
Name alias = getAtSeparated();
mustMatch("@FUNCTION");
- info->aliasedSymbols.insert({name, LinkerObject::SymbolAlias(alias, LinkerObject::Relocation::kFunction, 0)});
+ auto ret = info->aliasedSymbols.insert({name, LinkerObject::SymbolAlias(alias, LinkerObject::Relocation::kFunction, 0)});
+ if (!ret.second) std::cerr << "Unsupported data alias redefinition: " << name << ", skipping...\n";
} else {
abort_on("unknown directive");
}
@@ -412,15 +413,6 @@ class S2WasmBuilder {
s++;
offset = getInt();
}
- skipWhitespace();
-
- // get the data size
- mustMatch(".size");
- mustMatch(lhs.str);
- mustMatch(",");
- wasm::Address size = atoi(getStr().str);
- WASM_UNUSED(size);
- skipWhitespace();
// check if the rhs is already an alias
const auto alias = symbolInfo->aliasedSymbols.find(rhs);
@@ -430,8 +422,9 @@ class S2WasmBuilder {
}
// add the new alias
- symbolInfo->aliasedSymbols.insert({lhs, LinkerObject::SymbolAlias(rhs,
+ auto ret = symbolInfo->aliasedSymbols.insert({lhs, LinkerObject::SymbolAlias(rhs,
LinkerObject::Relocation::kData, offset)});
+ if (!ret.second) std::cerr << "Unsupported function alias redefinition: " << lhs << ", skipping...\n";
}
}
}
@@ -470,7 +463,9 @@ class S2WasmBuilder {
WASM_UNUSED(rhs);
skipWhitespace();
- mustMatch(".size");
+ // if no size attribute (e.g. weak symbol), skip
+ if (!match(".size")) return;
+
mustMatch(lhs.str);
mustMatch(",");
Name size = getStr();
diff --git a/src/wasm-linker.cpp b/src/wasm-linker.cpp
index a2e88cfb3..628e24ecc 100644
--- a/src/wasm-linker.cpp
+++ b/src/wasm-linker.cpp
@@ -123,6 +123,7 @@ void Linker::layout() {
}
};
for (auto& relocation : out.relocations) {
+ // TODO: Handle weak symbols properly, instead of always taking the weak definition.
auto *alias = out.getAlias(relocation->symbol, relocation->kind);
Name name = relocation->symbol;