diff options
Diffstat (limited to 'src/binary-reader-objdump.cc')
-rw-r--r-- | src/binary-reader-objdump.cc | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc index 649358d6..0d3d1188 100644 --- a/src/binary-reader-objdump.cc +++ b/src/binary-reader-objdump.cc @@ -58,6 +58,7 @@ class BinaryReaderObjdumpBase : public BinaryReaderNop { string_view GetEventName(Index index) const; string_view GetSymbolName(Index index) const; string_view GetSegmentName(Index index) const; + string_view GetTableName(Index index) const; void PrintRelocation(const Reloc& reloc, Offset offset) const; Offset GetSectionStart(BinarySection section_code) const { return section_starts_[static_cast<size_t>(section_code)]; @@ -152,6 +153,10 @@ string_view BinaryReaderObjdumpBase::GetSegmentName(Index index) const { return objdump_state_->segment_names.Get(index); } +string_view BinaryReaderObjdumpBase::GetTableName(Index index) const { + return objdump_state_->table_names.Get(index); +} + string_view BinaryReaderObjdumpBase::GetSymbolName(Index symbol_index) const { if (symbol_index >= objdump_state_->symtab.size()) return "<illegal_symbol_index>"; @@ -167,6 +172,8 @@ string_view BinaryReaderObjdumpBase::GetSymbolName(Index symbol_index) const { return GetSectionName(sym.index); case SymbolType::Event: return GetEventName(sym.index); + case SymbolType::Table: + return GetTableName(sym.index); } WABT_UNREACHABLE; } @@ -283,6 +290,18 @@ class BinaryReaderObjdumpPrepass : public BinaryReaderObjdumpBase { return Result::Ok; } + Result OnTableSymbol(Index index, + uint32_t flags, + string_view name, + Index table_index) override { + if (!name.empty()) { + SetTableName(table_index, name); + } + objdump_state_->symtab[index] = {SymbolType::Table, name.to_string(), + table_index}; + return Result::Ok; + } + Result OnImportFunc(Index import_index, string_view module_name, string_view field_name, @@ -351,6 +370,7 @@ class BinaryReaderObjdumpPrepass : public BinaryReaderObjdumpBase { void SetFunctionName(Index index, string_view name); void SetGlobalName(Index index, string_view name); void SetEventName(Index index, string_view name); + void SetTableName(Index index, string_view name); void SetSegmentName(Index index, string_view name); }; @@ -367,6 +387,10 @@ void BinaryReaderObjdumpPrepass::SetEventName(Index index, string_view name) { objdump_state_->event_names.Set(index, name); } +void BinaryReaderObjdumpPrepass::SetTableName(Index index, string_view name) { + objdump_state_->table_names.Set(index, name); +} + void BinaryReaderObjdumpPrepass::SetSegmentName(Index index, string_view name) { objdump_state_->segment_names.Set(index, name); } @@ -891,6 +915,10 @@ class BinaryReaderObjdump : public BinaryReaderObjdumpBase { uint32_t flags, string_view name, Index event_index) override; + Result OnTableSymbol(Index index, + uint32_t flags, + string_view name, + Index table_index) override; Result OnSegmentInfoCount(Index count) override; Result OnSegmentInfo(Index index, string_view name, @@ -1781,11 +1809,23 @@ Result BinaryReaderObjdump::OnEventSymbol(Index index, if (name.empty()) { name = GetEventName(event_index); } - PrintDetails(" - [%d] E <" PRIstringview "> event=%" PRIindex, index, + PrintDetails(" - %d: E <" PRIstringview "> event=%" PRIindex, index, WABT_PRINTF_STRING_VIEW_ARG(name), event_index); return PrintSymbolFlags(flags); } +Result BinaryReaderObjdump::OnTableSymbol(Index index, + uint32_t flags, + string_view name, + Index table_index) { + if (name.empty()) { + name = GetTableName(table_index); + } + PrintDetails(" - %d: T <" PRIstringview "> table=%" PRIindex, index, + WABT_PRINTF_STRING_VIEW_ARG(name), table_index); + return PrintSymbolFlags(flags); +} + Result BinaryReaderObjdump::OnSegmentInfoCount(Index count) { PrintDetails(" - segment info [count=%d]\n", count); return Result::Ok; |