diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/binary-reader-logging.cc | 11 | ||||
-rw-r--r-- | src/binary-reader-logging.h | 7 | ||||
-rw-r--r-- | src/binary-reader-nop.h | 7 | ||||
-rw-r--r-- | src/binary-reader-objdump.cc | 19 | ||||
-rw-r--r-- | src/binary-reader.cc | 15 | ||||
-rw-r--r-- | src/binary-reader.h | 5 | ||||
-rw-r--r-- | src/common.h | 1 |
7 files changed, 64 insertions, 1 deletions
diff --git a/src/binary-reader-logging.cc b/src/binary-reader-logging.cc index b167e63d..ff169c17 100644 --- a/src/binary-reader-logging.cc +++ b/src/binary-reader-logging.cc @@ -437,6 +437,16 @@ Result BinaryReaderLogging::OnSymbolInfo(string_view name, uint32_t flags) { return reader_->OnSymbolInfo(name, flags); } +Result BinaryReaderLogging::OnSegmentInfo(Index index, + string_view name, + uint32_t alignment, + uint32_t flags) { + LOGF("(OnSegmentInfo %d name: " PRIstringview + ", alignment: %d, flags: 0x%x)\n", + index, WABT_PRINTF_STRING_VIEW_ARG(name), alignment, flags); + return reader_->OnSegmentInfo(index, name, alignment, flags); +} + #define DEFINE_BEGIN(name) \ Result BinaryReaderLogging::name(Offset size) { \ LOGF(#name "(%" PRIzd ")\n", size); \ @@ -603,6 +613,7 @@ DEFINE_INDEX(OnSymbolInfoCount) DEFINE_INDEX(OnStackGlobal) DEFINE_INDEX(OnDataSize) DEFINE_INDEX(OnDataAlignment) +DEFINE_INDEX(OnSegmentInfoCount) DEFINE_END(EndLinkingSection) DEFINE_BEGIN(BeginExceptionSection); diff --git a/src/binary-reader-logging.h b/src/binary-reader-logging.h index 4fc95efb..7b9346d4 100644 --- a/src/binary-reader-logging.h +++ b/src/binary-reader-logging.h @@ -251,10 +251,15 @@ class BinaryReaderLogging : public BinaryReaderDelegate { Result BeginLinkingSection(Offset size) override; Result OnStackGlobal(Index stack_global) override; - Result OnSymbolInfo(string_view name, uint32_t flags) override; Result OnSymbolInfoCount(Index count) override; + Result OnSymbolInfo(string_view name, uint32_t flags) override; Result OnDataSize(uint32_t data_size) override; Result OnDataAlignment(uint32_t data_alignment) override; + Result OnSegmentInfoCount(Index count) override; + Result OnSegmentInfo(Index index, + string_view name, + uint32_t alignment, + uint32_t flags) override; Result EndLinkingSection() override; Result BeginExceptionSection(Offset size) override; diff --git a/src/binary-reader-nop.h b/src/binary-reader-nop.h index b3a24458..5a65f6ae 100644 --- a/src/binary-reader-nop.h +++ b/src/binary-reader-nop.h @@ -358,6 +358,13 @@ class BinaryReaderNop : public BinaryReaderDelegate { Result OnDataAlignment(uint32_t data_alignment) override { return Result::Ok; } + Result OnSegmentInfoCount(Index count) override { return Result::Ok; } + Result OnSegmentInfo(Index index, + string_view name, + uint32_t alignment, + uint32_t flags) override { + return Result::Ok; + } Result EndLinkingSection() override { return Result::Ok; } /* InitExpr - used by elem, data and global sections; these functions are diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc index d77cb8ad..948e705a 100644 --- a/src/binary-reader-objdump.cc +++ b/src/binary-reader-objdump.cc @@ -558,6 +558,11 @@ class BinaryReaderObjdump : public BinaryReaderObjdumpBase { Result OnSymbolInfo(string_view name, uint32_t flags) override; Result OnDataSize(uint32_t data_size) override; Result OnDataAlignment(uint32_t data_alignment) override; + Result OnSegmentInfoCount(Index count) override; + Result OnSegmentInfo(Index index, + string_view name, + uint32_t alignment, + uint32_t flags) override; Result OnExceptionCount(Index count) override; Result OnExceptionType(Index index, TypeVector& sig) override; @@ -1102,6 +1107,20 @@ Result BinaryReaderObjdump::OnSymbolInfo(string_view name, uint32_t flags) { return Result::Ok; } +Result BinaryReaderObjdump::OnSegmentInfoCount(Index count) { + PrintDetails(" - segment info [count=%d]\n", count); + return Result::Ok; +} + +Result BinaryReaderObjdump::OnSegmentInfo(Index index, + string_view name, + uint32_t alignment, + uint32_t flags) { + PrintDetails(" - %d: " PRIstringview " align=%d flags=%#x\n", index, + WABT_PRINTF_STRING_VIEW_ARG(name), alignment, flags); + return Result::Ok; +} + Result BinaryReaderObjdump::OnExceptionCount(Index count) { return OnCount(count); } diff --git a/src/binary-reader.cc b/src/binary-reader.cc index 2ba930e1..06cf9bb4 100644 --- a/src/binary-reader.cc +++ b/src/binary-reader.cc @@ -1276,6 +1276,21 @@ Result BinaryReader::ReadLinkingSection(Offset section_size) { CALLBACK(OnDataAlignment, data_alignment); break; } + case LinkingEntryType::SegmentInfo: { + uint32_t info_count; + CHECK_RESULT(ReadU32Leb128(&info_count, "info count")); + CALLBACK(OnSegmentInfoCount, info_count); + for (Index i = 0; i < info_count; i++) { + string_view name; + uint32_t alignment; + uint32_t flags; + CHECK_RESULT(ReadStr(&name, "segment name")); + CHECK_RESULT(ReadU32Leb128(&alignment, "segment alignment")); + CHECK_RESULT(ReadU32Leb128(&flags, "segment flags")); + CALLBACK(OnSegmentInfo, i, name, alignment, flags); + } + break; + } default: // Unknown subsection, skip it. state_.offset = subsection_end; diff --git a/src/binary-reader.h b/src/binary-reader.h index c0b32393..5d923f3e 100644 --- a/src/binary-reader.h +++ b/src/binary-reader.h @@ -306,6 +306,11 @@ class BinaryReaderDelegate { virtual Result OnSymbolInfo(string_view name, uint32_t flags) = 0; virtual Result OnDataSize(uint32_t data_size) = 0; virtual Result OnDataAlignment(uint32_t data_alignment) = 0; + virtual Result OnSegmentInfoCount(Index count) = 0; + virtual Result OnSegmentInfo(Index index, + string_view name, + uint32_t alignment, + uint32_t flags) = 0; virtual Result EndLinkingSection() = 0; /* Exception section */ diff --git a/src/common.h b/src/common.h index 666e1b88..1709e506 100644 --- a/src/common.h +++ b/src/common.h @@ -235,6 +235,7 @@ enum class LinkingEntryType { SymbolInfo = 2, DataSize = 3, DataAlignment = 4, + SegmentInfo = 5, }; enum class SymbolBinding { |