summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/binary-reader-logging.cc14
-rw-r--r--src/binary-reader-logging.h3
-rw-r--r--src/binary-reader-nop.h7
-rw-r--r--src/binary-reader-objdump.cc19
-rw-r--r--src/binary-reader.cc21
-rw-r--r--src/binary-reader.h5
-rw-r--r--src/common.h5
7 files changed, 74 insertions, 0 deletions
diff --git a/src/binary-reader-logging.cc b/src/binary-reader-logging.cc
index 2852ad66..332f947e 100644
--- a/src/binary-reader-logging.cc
+++ b/src/binary-reader-logging.cc
@@ -574,6 +574,19 @@ Result BinaryReaderLogging::OnInitFunction(uint32_t priority,
return reader_->OnInitFunction(priority, func_index);
}
+Result BinaryReaderLogging::OnComdatBegin(string_view name,
+ uint32_t flags,
+ Index count) {
+ LOGF("OnComdatBegin(" PRIstringview ", flags: %d, count: %" PRIindex ")\n",
+ WABT_PRINTF_STRING_VIEW_ARG(name), flags, count);
+ return reader_->OnComdatBegin(name, flags, count);
+}
+
+Result BinaryReaderLogging::OnComdatEntry(ComdatType kind, Index index) {
+ LOGF("OnComdatEntry(kind: %d, index: %" PRIindex ")\n", kind, index);
+ return reader_->OnComdatEntry(kind, index);
+}
+
#define DEFINE_BEGIN(name) \
Result BinaryReaderLogging::name(Offset size) { \
LOGF(#name "(%" PRIzd ")\n", size); \
@@ -771,6 +784,7 @@ DEFINE_BEGIN(BeginLinkingSection)
DEFINE_INDEX(OnSymbolCount)
DEFINE_INDEX(OnSegmentInfoCount)
DEFINE_INDEX(OnInitFunctionCount)
+DEFINE_INDEX(OnComdatCount)
DEFINE_END(EndLinkingSection)
DEFINE_BEGIN(BeginEventSection);
diff --git a/src/binary-reader-logging.h b/src/binary-reader-logging.h
index 0177163e..9d938e58 100644
--- a/src/binary-reader-logging.h
+++ b/src/binary-reader-logging.h
@@ -318,6 +318,9 @@ class BinaryReaderLogging : public BinaryReaderDelegate {
uint32_t flags) override;
Result OnInitFunctionCount(Index count) override;
Result OnInitFunction(uint32_t priority, Index function_index) override;
+ Result OnComdatCount(Index count) override;
+ Result OnComdatBegin(string_view name, uint32_t flags, Index count) override;
+ Result OnComdatEntry(ComdatType kind, Index index) override;
Result EndLinkingSection() override;
Result BeginEventSection(Offset size) override;
diff --git a/src/binary-reader-nop.h b/src/binary-reader-nop.h
index 69a90736..c83f362b 100644
--- a/src/binary-reader-nop.h
+++ b/src/binary-reader-nop.h
@@ -450,6 +450,13 @@ class BinaryReaderNop : public BinaryReaderDelegate {
Result OnInitFunction(uint32_t priority, Index function_index) override {
return Result::Ok;
}
+ Result OnComdatCount(Index count) override { return Result::Ok; }
+ Result OnComdatBegin(string_view name, uint32_t flags, Index count) override {
+ return Result::Ok;
+ }
+ Result OnComdatEntry(ComdatType kind, Index index) 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 66c858ed..f59764ef 100644
--- a/src/binary-reader-objdump.cc
+++ b/src/binary-reader-objdump.cc
@@ -857,6 +857,10 @@ class BinaryReaderObjdump : public BinaryReaderObjdumpBase {
uint32_t flags) override;
Result OnInitFunctionCount(Index count) override;
Result OnInitFunction(uint32_t priority, Index function_index) override;
+ Result OnComdatCount(Index count) override;
+ Result OnComdatBegin(string_view name, uint32_t flags, Index count) override;
+ Result OnComdatEntry(ComdatType kind, Index index) override;
+ Result EndLinkingSection() override { return Result::Ok; }
Result OnEventCount(Index count) override;
Result OnEventType(Index index, Index sig_index) override;
@@ -1636,6 +1640,21 @@ Result BinaryReaderObjdump::OnInitFunction(uint32_t priority,
PrintDetails(" - %d: priority=%d\n", function_index, priority);
return Result::Ok;
}
+Result BinaryReaderObjdump::OnComdatCount(Index count) {
+ PrintDetails(" - comdat groups functions [count=%d]\n", count);
+ return Result::Ok;
+}
+
+Result BinaryReaderObjdump::OnComdatBegin(string_view name, uint32_t flags, Index count) {
+ PrintDetails(" - " PRIstringview ": [count=%d]\n",
+ WABT_PRINTF_STRING_VIEW_ARG(name), count);
+ return Result::Ok;
+}
+
+Result BinaryReaderObjdump::OnComdatEntry(ComdatType kind, Index index) {
+ PrintDetails(" - kind=%d index=%" PRIindex "\n", kind, index);
+ return Result::Ok;
+}
Result BinaryReaderObjdump::OnEventCount(Index count) {
return OnCount(count);
diff --git a/src/binary-reader.cc b/src/binary-reader.cc
index 893be276..038d54c2 100644
--- a/src/binary-reader.cc
+++ b/src/binary-reader.cc
@@ -1748,6 +1748,27 @@ Result BinaryReader::ReadLinkingSection(Offset section_size) {
CALLBACK(OnInitFunction, priority, func);
}
break;
+ case LinkingEntryType::ComdatInfo:
+ CHECK_RESULT(ReadU32Leb128(&count, "count"));
+ CALLBACK(OnComdatCount, count);
+ while (count--) {
+ uint32_t flags;
+ uint32_t entry_count;
+ string_view name;
+ CHECK_RESULT(ReadStr(&name, "comdat name"));
+ CHECK_RESULT(ReadU32Leb128(&flags, "flags"));
+ CHECK_RESULT(ReadU32Leb128(&entry_count, "entry count"));
+ CALLBACK(OnComdatBegin, name, flags, entry_count);
+ while (entry_count--) {
+ uint32_t kind;
+ uint32_t index;
+ CHECK_RESULT(ReadU32Leb128(&kind, "kind"));
+ CHECK_RESULT(ReadU32Leb128(&index, "index"));
+ ComdatType comdat_type = static_cast<ComdatType>(kind);
+ CALLBACK(OnComdatEntry, comdat_type, index);
+ }
+ }
+ break;
default:
// Unknown subsection, skip it.
state_.offset = subsection_end;
diff --git a/src/binary-reader.h b/src/binary-reader.h
index bde3d463..42bbe9c6 100644
--- a/src/binary-reader.h
+++ b/src/binary-reader.h
@@ -383,6 +383,11 @@ class BinaryReaderDelegate {
uint32_t flags) = 0;
virtual Result OnInitFunctionCount(Index count) = 0;
virtual Result OnInitFunction(uint32_t priority, Index function_index) = 0;
+ virtual Result OnComdatCount(Index count) = 0;
+ virtual Result OnComdatBegin(string_view name,
+ uint32_t flags,
+ Index count) = 0;
+ virtual Result OnComdatEntry(ComdatType kind, Index index) = 0;
virtual Result EndLinkingSection() = 0;
/* Event section */
diff --git a/src/common.h b/src/common.h
index 476431c9..7554e40f 100644
--- a/src/common.h
+++ b/src/common.h
@@ -258,6 +258,11 @@ enum class SymbolType {
Event = 4,
};
+enum class ComdatType {
+ Data = 0x0,
+ Function = 0x1,
+};
+
#define WABT_SYMBOL_FLAG_UNDEFINED 0x10
#define WABT_SYMBOL_MASK_VISIBILITY 0x4
#define WABT_SYMBOL_MASK_BINDING 0x3