diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/binary-reader-logging.cc | 18 | ||||
-rw-r--r-- | src/binary-reader-logging.h | 6 | ||||
-rw-r--r-- | src/binary-reader-nop.h | 10 | ||||
-rw-r--r-- | src/binary-reader-objdump.cc | 30 | ||||
-rw-r--r-- | src/binary-reader.cc | 29 | ||||
-rw-r--r-- | src/binary-reader.h | 6 | ||||
-rw-r--r-- | src/common.h | 2 |
7 files changed, 98 insertions, 3 deletions
diff --git a/src/binary-reader-logging.cc b/src/binary-reader-logging.cc index 77ee5736..fb3d3840 100644 --- a/src/binary-reader-logging.cc +++ b/src/binary-reader-logging.cc @@ -550,6 +550,22 @@ Result BinaryReaderLogging::OnDylinkNeeded(string_view so_name) { return reader_->OnDylinkNeeded(so_name); } +Result BinaryReaderLogging::OnDylinkExport(string_view name, uint32_t flags) { + LOGF("OnDylinkExport(name: " PRIstringview ", flags: 0x%x)\n", + WABT_PRINTF_STRING_VIEW_ARG(name), flags); + return reader_->OnDylinkExport(name, flags); +} + +Result BinaryReaderLogging::OnDylinkImport(string_view module, + string_view name, + uint32_t flags) { + LOGF("OnDylinkImport(module: " PRIstringview ", name: " PRIstringview + ", flags: 0x%x)\n", + WABT_PRINTF_STRING_VIEW_ARG(module), WABT_PRINTF_STRING_VIEW_ARG(name), + flags); + return reader_->OnDylinkImport(module, name, flags); +} + Result BinaryReaderLogging::OnRelocCount(Index count, Index section_index) { LOGF("OnRelocCount(count: %" PRIindex ", section: %" PRIindex ")\n", count, @@ -882,6 +898,8 @@ DEFINE_INDEX_INDEX(OnInitExprRefFunc, "index", "func_index") DEFINE_BEGIN(BeginDylinkSection) DEFINE_INDEX(OnDylinkNeededCount) +DEFINE_INDEX(OnDylinkExportCount) +DEFINE_INDEX(OnDylinkImportCount) DEFINE_END(EndDylinkSection) DEFINE_BEGIN(BeginLinkingSection) diff --git a/src/binary-reader-logging.h b/src/binary-reader-logging.h index 423a321c..e15801b5 100644 --- a/src/binary-reader-logging.h +++ b/src/binary-reader-logging.h @@ -324,6 +324,12 @@ class BinaryReaderLogging : public BinaryReaderDelegate { uint32_t table_align) override; Result OnDylinkNeededCount(Index count) override; Result OnDylinkNeeded(string_view needed) override; + Result OnDylinkImportCount(Index count) override; + Result OnDylinkExportCount(Index count) override; + Result OnDylinkImport(string_view module, + string_view name, + uint32_t flags) override; + Result OnDylinkExport(string_view name, uint32_t flags) override; Result EndDylinkSection() override; Result BeginLinkingSection(Offset size) override; diff --git a/src/binary-reader-nop.h b/src/binary-reader-nop.h index f22b05ad..d7c46d31 100644 --- a/src/binary-reader-nop.h +++ b/src/binary-reader-nop.h @@ -465,6 +465,16 @@ class BinaryReaderNop : public BinaryReaderDelegate { } Result OnDylinkNeededCount(Index count) override { return Result::Ok; } Result OnDylinkNeeded(string_view so_name) override { return Result::Ok; } + Result OnDylinkImportCount(Index count) override { return Result::Ok; } + Result OnDylinkExportCount(Index count) override { return Result::Ok; } + Result OnDylinkImport(string_view module, + string_view name, + uint32_t flags) override { + return Result::Ok; + } + Result OnDylinkExport(string_view name, uint32_t flags) override { + return Result::Ok; + } Result EndDylinkSection() override { return Result::Ok; } /* Linking section */ diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc index 241cba4a..7cca4505 100644 --- a/src/binary-reader-objdump.cc +++ b/src/binary-reader-objdump.cc @@ -973,6 +973,12 @@ class BinaryReaderObjdump : public BinaryReaderObjdumpBase { uint32_t table_align_log2) override; Result OnDylinkNeededCount(Index count) override; Result OnDylinkNeeded(string_view so_name) override; + Result OnDylinkImportCount(Index count) override; + Result OnDylinkExportCount(Index count) override; + Result OnDylinkImport(string_view module, + string_view name, + uint32_t flags) override; + Result OnDylinkExport(string_view name, uint32_t flags) override; Result OnRelocCount(Index count, Index section_index) override; Result OnReloc(RelocType type, @@ -1770,6 +1776,30 @@ Result BinaryReaderObjdump::OnDylinkNeededCount(Index count) { return Result::Ok; } +Result BinaryReaderObjdump::OnDylinkImportCount(Index count) { + PrintDetails(" - imports[%u]:\n", count); + return Result::Ok; +} + +Result BinaryReaderObjdump::OnDylinkExportCount(Index count) { + PrintDetails(" - exports[%u]:\n", count); + return Result::Ok; +} + +Result BinaryReaderObjdump::OnDylinkExport(string_view name, uint32_t flags) { + PrintDetails(" - " PRIstringview, WABT_PRINTF_STRING_VIEW_ARG(name)); + return PrintSymbolFlags(flags); +} + +Result BinaryReaderObjdump::OnDylinkImport(string_view module, + string_view name, + uint32_t flags) { + PrintDetails(" - " PRIstringview "." PRIstringview, + WABT_PRINTF_STRING_VIEW_ARG(module), + WABT_PRINTF_STRING_VIEW_ARG(name)); + return PrintSymbolFlags(flags); +} + Result BinaryReaderObjdump::OnDylinkNeeded(string_view so_name) { PrintDetails(" - " PRIstringview "\n", WABT_PRINTF_STRING_VIEW_ARG(so_name)); return Result::Ok; diff --git a/src/binary-reader.cc b/src/binary-reader.cc index 45d70f1a..d8dcce70 100644 --- a/src/binary-reader.cc +++ b/src/binary-reader.cc @@ -1969,6 +1969,7 @@ Result BinaryReader::ReadDylink0Section(Offset section_size) { ReadEndRestoreGuard guard(this); read_end_ = subsection_end; + uint32_t count; switch (static_cast<DylinkEntryType>(dylink_type)) { case DylinkEntryType::MemInfo: { uint32_t mem_size; @@ -1983,8 +1984,7 @@ Result BinaryReader::ReadDylink0Section(Offset section_size) { CALLBACK(OnDylinkInfo, mem_size, mem_align, table_size, table_align); break; } - case DylinkEntryType::Needed: { - uint32_t count; + case DylinkEntryType::Needed: CHECK_RESULT(ReadU32Leb128(&count, "needed_dynlibs")); CALLBACK(OnDylinkNeededCount, count); while (count--) { @@ -1993,7 +1993,30 @@ Result BinaryReader::ReadDylink0Section(Offset section_size) { CALLBACK(OnDylinkNeeded, so_name); } break; - } + case DylinkEntryType::ImportInfo: + CHECK_RESULT(ReadU32Leb128(&count, "count")); + CALLBACK(OnDylinkImportCount, count); + for (Index i = 0; i < count; ++i) { + uint32_t flags = 0; + string_view module; + string_view field; + CHECK_RESULT(ReadStr(&module, "module")); + CHECK_RESULT(ReadStr(&field, "field")); + CHECK_RESULT(ReadU32Leb128(&flags, "flags")); + CALLBACK(OnDylinkImport, module, field, flags); + } + break; + case DylinkEntryType::ExportInfo: + CHECK_RESULT(ReadU32Leb128(&count, "count")); + CALLBACK(OnDylinkExportCount, count); + for (Index i = 0; i < count; ++i) { + uint32_t flags = 0; + string_view name; + CHECK_RESULT(ReadStr(&name, "name")); + CHECK_RESULT(ReadU32Leb128(&flags, "flags")); + CALLBACK(OnDylinkExport, name, flags); + } + break; default: // Unknown subsection, skip it. state_.offset = subsection_end; diff --git a/src/binary-reader.h b/src/binary-reader.h index 2871d80f..ce090622 100644 --- a/src/binary-reader.h +++ b/src/binary-reader.h @@ -395,6 +395,12 @@ class BinaryReaderDelegate { uint32_t mem_align_log2, uint32_t table_size, uint32_t table_align_log2) = 0; + virtual Result OnDylinkImportCount(Index count) = 0; + virtual Result OnDylinkExportCount(Index count) = 0; + virtual Result OnDylinkImport(string_view module, + string_view name, + uint32_t flags) = 0; + virtual Result OnDylinkExport(string_view name, uint32_t flags) = 0; virtual Result OnDylinkNeededCount(Index count) = 0; virtual Result OnDylinkNeeded(string_view so_name) = 0; virtual Result EndDylinkSection() = 0; diff --git a/src/common.h b/src/common.h index de5e44af..312726ee 100644 --- a/src/common.h +++ b/src/common.h @@ -339,6 +339,8 @@ enum class LinkingEntryType { enum class DylinkEntryType { MemInfo = 1, Needed = 2, + ExportInfo = 3, + ImportInfo = 4, }; enum class SymbolType { |