@@ -131,6 +131,7 @@ class BinaryReader {
131
131
Result ReadNameSection (Offset section_size) WABT_WARN_UNUSED;
132
132
Result ReadRelocSection (Offset section_size) WABT_WARN_UNUSED;
133
133
Result ReadDylinkSection (Offset section_size) WABT_WARN_UNUSED;
134
+ Result ReadDylink0Section (Offset section_size) WABT_WARN_UNUSED;
134
135
Result ReadLinkingSection (Offset section_size) WABT_WARN_UNUSED;
135
136
Result ReadCustomSection (Index section_index,
136
137
Offset section_size) WABT_WARN_UNUSED;
@@ -1954,6 +1955,59 @@ Result BinaryReader::ReadRelocSection(Offset section_size) {
1954
1955
return Result::Ok;
1955
1956
}
1956
1957
1958
+ Result BinaryReader::ReadDylink0Section (Offset section_size) {
1959
+ CALLBACK (BeginDylinkSection, section_size);
1960
+
1961
+ while (state_.offset < read_end_) {
1962
+ uint32_t dylink_type;
1963
+ Offset subsection_size;
1964
+ CHECK_RESULT (ReadU32Leb128 (&dylink_type, " type" ));
1965
+ CHECK_RESULT (ReadOffset (&subsection_size, " subsection size" ));
1966
+ size_t subsection_end = state_.offset + subsection_size;
1967
+ ERROR_UNLESS (subsection_end <= read_end_,
1968
+ " invalid sub-section size: extends past end" );
1969
+ ReadEndRestoreGuard guard (this );
1970
+ read_end_ = subsection_end;
1971
+
1972
+ switch (static_cast <DylinkEntryType>(dylink_type)) {
1973
+ case DylinkEntryType::MemInfo: {
1974
+ uint32_t mem_size;
1975
+ uint32_t mem_align;
1976
+ uint32_t table_size;
1977
+ uint32_t table_align;
1978
+
1979
+ CHECK_RESULT (ReadU32Leb128 (&mem_size, " mem_size" ));
1980
+ CHECK_RESULT (ReadU32Leb128 (&mem_align, " mem_align" ));
1981
+ CHECK_RESULT (ReadU32Leb128 (&table_size, " table_size" ));
1982
+ CHECK_RESULT (ReadU32Leb128 (&table_align, " table_align" ));
1983
+ CALLBACK (OnDylinkInfo, mem_size, mem_align, table_size, table_align);
1984
+ break ;
1985
+ }
1986
+ case DylinkEntryType::Needed: {
1987
+ uint32_t count;
1988
+ CHECK_RESULT (ReadU32Leb128 (&count, " needed_dynlibs" ));
1989
+ CALLBACK (OnDylinkNeededCount, count);
1990
+ while (count--) {
1991
+ string_view so_name;
1992
+ CHECK_RESULT (ReadStr (&so_name, " dylib so_name" ));
1993
+ CALLBACK (OnDylinkNeeded, so_name);
1994
+ }
1995
+ break ;
1996
+ }
1997
+ default :
1998
+ // Unknown subsection, skip it.
1999
+ state_.offset = subsection_end;
2000
+ break ;
2001
+ }
2002
+ ERROR_UNLESS (state_.offset == subsection_end,
2003
+ " unfinished sub-section (expected end: 0x%" PRIzx " )" ,
2004
+ subsection_end);
2005
+ }
2006
+
2007
+ CALLBACK0 (EndDylinkSection);
2008
+ return Result::Ok;
2009
+ }
2010
+
1957
2011
Result BinaryReader::ReadDylinkSection (Offset section_size) {
1958
2012
CALLBACK (BeginDylinkSection, section_size);
1959
2013
uint32_t mem_size;
@@ -2153,6 +2207,8 @@ Result BinaryReader::ReadCustomSection(Index section_index,
2153
2207
if (options_.read_debug_names && section_name == WABT_BINARY_SECTION_NAME) {
2154
2208
CHECK_RESULT (ReadNameSection (section_size));
2155
2209
did_read_names_section_ = true ;
2210
+ } else if (section_name == WABT_BINARY_SECTION_DYLINK0) {
2211
+ CHECK_RESULT (ReadDylink0Section (section_size));
2156
2212
} else if (section_name == WABT_BINARY_SECTION_DYLINK) {
2157
2213
CHECK_RESULT (ReadDylinkSection (section_size));
2158
2214
} else if (section_name.rfind (WABT_BINARY_SECTION_RELOC, 0 ) == 0 ) {
0 commit comments