summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/binary-reader-logging.cc10
-rw-r--r--src/binary-reader-logging.h4
-rw-r--r--src/binary-reader-nop.h6
-rw-r--r--src/binary-reader-objdump.cc51
-rw-r--r--src/binary-reader-objdump.h1
-rw-r--r--src/binary-reader.cc25
-rw-r--r--src/binary-reader.h4
-rw-r--r--src/common.h4
8 files changed, 99 insertions, 6 deletions
diff --git a/src/binary-reader-logging.cc b/src/binary-reader-logging.cc
index db139c55..2a145cec 100644
--- a/src/binary-reader-logging.cc
+++ b/src/binary-reader-logging.cc
@@ -538,6 +538,16 @@ Result BinaryReaderLogging::OnSectionSymbol(Index index,
return reader_->OnSectionSymbol(index, flags, section_index);
}
+Result BinaryReaderLogging::OnEventSymbol(Index index,
+ uint32_t flags,
+ string_view name,
+ Index event_index) {
+ LOGF("OnEventSymbol(name: " PRIstringview " flags: 0x%x index: %" PRIindex
+ ")\n",
+ WABT_PRINTF_STRING_VIEW_ARG(name), flags, event_index);
+ return reader_->OnEventSymbol(index, flags, name, event_index);
+}
+
Result BinaryReaderLogging::OnSegmentInfo(Index index,
string_view name,
uint32_t alignment,
diff --git a/src/binary-reader-logging.h b/src/binary-reader-logging.h
index 03fb75a4..fd5cd69d 100644
--- a/src/binary-reader-logging.h
+++ b/src/binary-reader-logging.h
@@ -302,6 +302,10 @@ class BinaryReaderLogging : public BinaryReaderDelegate {
Result OnSectionSymbol(Index index,
uint32_t flags,
Index section_index) override;
+ Result OnEventSymbol(Index index,
+ uint32_t flags,
+ string_view name,
+ Index event_index) override;
Result OnSegmentInfoCount(Index count) override;
Result OnSegmentInfo(Index index,
string_view name,
diff --git a/src/binary-reader-nop.h b/src/binary-reader-nop.h
index 42605e19..e9e6ea9a 100644
--- a/src/binary-reader-nop.h
+++ b/src/binary-reader-nop.h
@@ -426,6 +426,12 @@ class BinaryReaderNop : public BinaryReaderDelegate {
Index section_index) override {
return Result::Ok;
}
+ Result OnEventSymbol(Index index,
+ uint32_t flags,
+ string_view name,
+ Index event_index) override {
+ return Result::Ok;
+ }
Result OnSegmentInfoCount(Index count) override { return Result::Ok; }
Result OnSegmentInfo(Index index,
string_view name,
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc
index 5ae59ffb..4e6cd1e8 100644
--- a/src/binary-reader-objdump.cc
+++ b/src/binary-reader-objdump.cc
@@ -49,6 +49,7 @@ class BinaryReaderObjdumpBase : public BinaryReaderNop {
const char* GetFunctionName(Index index) const;
const char* GetGlobalName(Index index) const;
const char* GetSectionName(Index index) const;
+ const char* GetEventName(Index index) const;
string_view GetSymbolName(Index symbol_index) const;
void PrintRelocation(const Reloc& reloc, Offset offset) const;
Offset GetSectionStart(BinarySection section_code) const {
@@ -145,6 +146,15 @@ const char* BinaryReaderObjdumpBase::GetSectionName(Index index) const {
return objdump_state_->section_names[index].c_str();
}
+const char* BinaryReaderObjdumpBase::GetEventName(Index index) const {
+ if (index >= objdump_state_->event_names.size() ||
+ objdump_state_->event_names[index].empty()) {
+ return nullptr;
+ }
+
+ return objdump_state_->event_names[index].c_str();
+}
+
string_view BinaryReaderObjdumpBase::GetSymbolName(Index symbol_index) const {
assert(symbol_index < objdump_state_->symtab.size());
ObjdumpSymbol& sym = objdump_state_->symtab[symbol_index];
@@ -157,6 +167,8 @@ string_view BinaryReaderObjdumpBase::GetSymbolName(Index symbol_index) const {
return GetGlobalName(sym.index);
case SymbolType::Section:
return GetSectionName(sym.index);
+ case SymbolType::Event:
+ return GetEventName(sym.index);
}
WABT_UNREACHABLE;
}
@@ -250,6 +262,18 @@ class BinaryReaderObjdumpPrepass : public BinaryReaderObjdumpBase {
return Result::Ok;
}
+ Result OnEventSymbol(Index index,
+ uint32_t flags,
+ string_view name,
+ Index event_index) override {
+ if (!name.empty()) {
+ SetEventName(event_index, name);
+ }
+ objdump_state_->symtab[index] = {SymbolType::Event, name.to_string(),
+ event_index};
+ return Result::Ok;
+ }
+
Result OnImportFunc(Index import_index,
string_view module_name,
string_view field_name,
@@ -297,6 +321,7 @@ class BinaryReaderObjdumpPrepass : public BinaryReaderObjdumpBase {
protected:
void SetFunctionName(Index index, string_view name);
void SetGlobalName(Index index, string_view name);
+ void SetEventName(Index index, string_view name);
};
void BinaryReaderObjdumpPrepass::SetFunctionName(Index index,
@@ -312,6 +337,12 @@ void BinaryReaderObjdumpPrepass::SetGlobalName(Index index, string_view name) {
objdump_state_->global_names[index] = name.to_string();
}
+void BinaryReaderObjdumpPrepass::SetEventName(Index index, string_view name) {
+ if (objdump_state_->event_names.size() <= index)
+ objdump_state_->event_names.resize(index + 1);
+ objdump_state_->event_names[index] = name.to_string();
+}
+
Result BinaryReaderObjdumpPrepass::OnReloc(RelocType type,
Offset offset,
Index index,
@@ -792,6 +823,10 @@ class BinaryReaderObjdump : public BinaryReaderObjdumpBase {
Result OnSectionSymbol(Index index,
uint32_t flags,
Index section_index) override;
+ Result OnEventSymbol(Index index,
+ uint32_t flags,
+ string_view name,
+ Index event_index) override;
Result OnSegmentInfoCount(Index count) override;
Result OnSegmentInfo(Index index,
string_view name,
@@ -1504,6 +1539,22 @@ Result BinaryReaderObjdump::OnSectionSymbol(Index index,
return Result::Ok;
}
+Result BinaryReaderObjdump::OnEventSymbol(Index index,
+ uint32_t flags,
+ string_view name,
+ Index event_index) {
+ std::string sym_name = name.to_string();
+ if (sym_name.empty()) {
+ if (const char* Name = GetEventName(event_index)) {
+ sym_name = Name;
+ }
+ }
+ PrintDetails(" - [%d] E <" PRIstringview "> event=%" PRIindex, index,
+ WABT_PRINTF_STRING_VIEW_ARG(sym_name), event_index);
+ PrintSymbolFlags(flags);
+ return Result::Ok;
+}
+
Result BinaryReaderObjdump::OnSegmentInfoCount(Index count) {
PrintDetails(" - segment info [count=%d]\n", count);
return Result::Ok;
diff --git a/src/binary-reader-objdump.h b/src/binary-reader-objdump.h
index 1b0483d7..190cd0de 100644
--- a/src/binary-reader-objdump.h
+++ b/src/binary-reader-objdump.h
@@ -64,6 +64,7 @@ struct ObjdumpState {
std::vector<std::string> function_names;
std::vector<std::string> global_names;
std::vector<std::string> section_names;
+ std::vector<std::string> event_names;
std::vector<ObjdumpSymbol> symtab;
};
diff --git a/src/binary-reader.cc b/src/binary-reader.cc
index 76956621..f5512ecd 100644
--- a/src/binary-reader.cc
+++ b/src/binary-reader.cc
@@ -383,6 +383,9 @@ bool BinaryReader::IsConcreteType(Type type) {
case Type::V128:
return options_.features.simd_enabled();
+ case Type::ExceptRef:
+ return options_.features.exceptions_enabled();
+
case Type::Anyref:
return options_.features.reference_types_enabled();
@@ -1675,15 +1678,25 @@ Result BinaryReader::ReadLinkingSection(Offset section_size) {
CALLBACK(OnSymbol, i, sym_type, flags);
switch (sym_type) {
case SymbolType::Function:
- case SymbolType::Global: {
+ case SymbolType::Global:
+ case SymbolType::Event: {
uint32_t index = 0;
CHECK_RESULT(ReadU32Leb128(&index, "index"));
- if ((flags & WABT_SYMBOL_FLAG_UNDEFINED) == 0)
+ if ((flags & WABT_SYMBOL_FLAG_UNDEFINED) == 0 ||
+ (flags & WASM_SYMBOL_EXPLICIT_NAME) != 0)
CHECK_RESULT(ReadStr(&name, "symbol name"));
- if (sym_type == SymbolType::Function) {
- CALLBACK(OnFunctionSymbol, i, flags, name, index);
- } else {
- CALLBACK(OnGlobalSymbol, i, flags, name, index);
+ switch (sym_type) {
+ case SymbolType::Function:
+ CALLBACK(OnFunctionSymbol, i, flags, name, index);
+ break;
+ case SymbolType::Global:
+ CALLBACK(OnGlobalSymbol, i, flags, name, index);
+ break;
+ case SymbolType::Event:
+ CALLBACK(OnEventSymbol, i, flags, name, index);
+ break;
+ default:
+ WABT_UNREACHABLE;
}
break;
}
diff --git a/src/binary-reader.h b/src/binary-reader.h
index 861c592f..d3751fae 100644
--- a/src/binary-reader.h
+++ b/src/binary-reader.h
@@ -369,6 +369,10 @@ class BinaryReaderDelegate {
virtual Result OnSectionSymbol(Index index,
uint32_t flags,
Index section_index) = 0;
+ virtual Result OnEventSymbol(Index index,
+ uint32_t flags,
+ string_view name,
+ Index event_index) = 0;
virtual Result OnSegmentInfoCount(Index count) = 0;
virtual Result OnSegmentInfo(Index index,
string_view name,
diff --git a/src/common.h b/src/common.h
index 913693fc..37cec3b9 100644
--- a/src/common.h
+++ b/src/common.h
@@ -253,11 +253,13 @@ enum class SymbolType {
Data = 1,
Global = 2,
Section = 3,
+ Event = 4,
};
#define WABT_SYMBOL_FLAG_UNDEFINED 0x10
#define WABT_SYMBOL_MASK_VISIBILITY 0x4
#define WABT_SYMBOL_MASK_BINDING 0x3
+#define WASM_SYMBOL_EXPLICIT_NAME 0x40
enum class SymbolVisibility {
Default = 0,
@@ -333,6 +335,8 @@ static WABT_INLINE const char* GetSymbolTypeName(SymbolType type) {
return "data";
case SymbolType::Section:
return "section";
+ case SymbolType::Event:
+ return "event";
}
WABT_UNREACHABLE;
}