summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWink Saville <wink@saville.com>2017-05-18 14:29:12 -0700
committerSam Clegg <sbc@chromium.org>2017-05-18 14:29:12 -0700
commitc5b833e68b52dfc67b582b6f7fa60b55074d3aa8 (patch)
treee30db09ec80d495448d29d82b1ccc0a5df3ec359 /src
parenta9a997b417f493615bd51b82670e9c920b7ab439 (diff)
downloadwabt-c5b833e68b52dfc67b582b6f7fa60b55074d3aa8.tar.gz
wabt-c5b833e68b52dfc67b582b6f7fa60b55074d3aa8.tar.bz2
wabt-c5b833e68b52dfc67b582b6f7fa60b55074d3aa8.zip
Allow any module name (#440)
Currently a module name must be `__extern` with this change any module name is allowed.
Diffstat (limited to 'src')
-rw-r--r--src/binary-reader-linker.cc15
-rw-r--r--src/tools/wasm-link.cc4
-rw-r--r--src/wasm-link.h4
3 files changed, 6 insertions, 17 deletions
diff --git a/src/binary-reader-linker.cc b/src/binary-reader-linker.cc
index 5dd801a3..e85320b1 100644
--- a/src/binary-reader-linker.cc
+++ b/src/binary-reader-linker.cc
@@ -34,9 +34,6 @@ class BinaryReaderLinker : public BinaryReaderNop {
Result BeginSection(BinarySection section_type, Offset size) override;
- Result OnImport(Index index,
- StringSlice module_name,
- StringSlice field_name) override;
Result OnImportFunc(Index import_index,
StringSlice module_name,
StringSlice field_name,
@@ -127,16 +124,6 @@ Result BinaryReaderLinker::OnReloc(RelocType type,
return Result::Ok;
}
-Result BinaryReaderLinker::OnImport(Index index,
- StringSlice module_name,
- StringSlice field_name) {
- if (!string_slice_eq_cstr(&module_name, WABT_LINK_MODULE_NAME)) {
- WABT_FATAL("unsupported import module: " PRIstringslice,
- WABT_PRINTF_STRING_SLICE_ARG(module_name));
- }
- return Result::Ok;
-}
-
Result BinaryReaderLinker::OnImportFunc(Index import_index,
StringSlice module_name,
StringSlice field_name,
@@ -144,6 +131,7 @@ Result BinaryReaderLinker::OnImportFunc(Index import_index,
Index sig_index) {
binary->function_imports.emplace_back();
FunctionImport* import = &binary->function_imports.back();
+ import->module_name = module_name;
import->name = field_name;
import->sig_index = sig_index;
import->active = true;
@@ -159,6 +147,7 @@ Result BinaryReaderLinker::OnImportGlobal(Index import_index,
bool mutable_) {
binary->global_imports.emplace_back();
GlobalImport* import = &binary->global_imports.back();
+ import->module_name = module_name;
import->name = field_name;
import->type = type;
import->mutable_ = mutable_;
diff --git a/src/tools/wasm-link.cc b/src/tools/wasm-link.cc
index 057266c8..6d4b1fbd 100644
--- a/src/tools/wasm-link.cc
+++ b/src/tools/wasm-link.cc
@@ -384,7 +384,7 @@ static void write_memory_section(Context* ctx,
static void write_function_import(Context* ctx,
FunctionImport* import,
Index offset) {
- write_c_str(&ctx->stream, WABT_LINK_MODULE_NAME, "import module name");
+ write_slice(&ctx->stream, import->module_name, "import module name");
write_slice(&ctx->stream, import->name, "import field name");
ctx->stream.WriteU8Enum(ExternalKind::Func, "import kind");
write_u32_leb128(&ctx->stream, import->sig_index + offset,
@@ -392,7 +392,7 @@ static void write_function_import(Context* ctx,
}
static void write_global_import(Context* ctx, GlobalImport* import) {
- write_c_str(&ctx->stream, WABT_LINK_MODULE_NAME, "import module name");
+ write_slice(&ctx->stream, import->module_name, "import module name");
write_slice(&ctx->stream, import->name, "import field name");
ctx->stream.WriteU8Enum(ExternalKind::Global, "import kind");
write_type(&ctx->stream, import->type);
diff --git a/src/wasm-link.h b/src/wasm-link.h
index ce5b8a2f..2fdc33ac 100644
--- a/src/wasm-link.h
+++ b/src/wasm-link.h
@@ -23,14 +23,13 @@
#include "binary.h"
#include "common.h"
-#define WABT_LINK_MODULE_NAME "__extern"
-
namespace wabt {
namespace link {
struct LinkerInputBinary;
struct FunctionImport {
+ StringSlice module_name;
StringSlice name;
Index sig_index;
bool active; /* Is this import present in the linked binary */
@@ -40,6 +39,7 @@ struct FunctionImport {
};
struct GlobalImport {
+ StringSlice module_name;
StringSlice name;
Type type;
bool mutable_;