Skip to content

Commit 164346a

Browse files
authored
Parse IMPORT_INFO dylink section (#15778)
This section signals which imports are weak. We don't do anything with this information (yet) but this change avoids the output of the warning to stdout.
1 parent 0fd050a commit 164346a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tools/webassembly.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ class DylinkType(IntEnum):
7272
MEM_INFO = 1
7373
NEEDED = 2
7474
EXPORT_INFO = 3
75+
IMPORT_INFO = 4
7576

7677

7778
Section = namedtuple('Section', ['type', 'size', 'offset'])
7879
Limits = namedtuple('Limits', ['flags', 'initial', 'maximum'])
7980
Import = namedtuple('Import', ['kind', 'module', 'field'])
8081
Export = namedtuple('Export', ['name', 'kind', 'index'])
81-
Dylink = namedtuple('Dylink', ['mem_size', 'mem_align', 'table_size', 'table_align', 'needed', 'export_info'])
82+
Dylink = namedtuple('Dylink', ['mem_size', 'mem_align', 'table_size', 'table_align', 'needed', 'export_info', 'import_info'])
8283

8384

8485
class Module:
@@ -144,6 +145,7 @@ def parse_dylink_section(self):
144145
section_name = self.readString()
145146
needed = []
146147
export_info = {}
148+
import_info = {}
147149

148150
if section_name == 'dylink':
149151
mem_size = self.readULEB()
@@ -180,6 +182,15 @@ def parse_dylink_section(self):
180182
flags = self.readULEB()
181183
export_info[sym] = flags
182184
count -= 1
185+
elif subsection_type == DylinkType.IMPORT_INFO:
186+
count = self.readULEB()
187+
while count:
188+
module = self.readString()
189+
field = self.readString()
190+
flags = self.readULEB()
191+
import_info.setdefault(module, {})
192+
import_info[module][field] = flags
193+
count -= 1
183194
else:
184195
print(f'unknown subsection: {subsection_type}')
185196
# ignore unknown subsections
@@ -188,7 +199,7 @@ def parse_dylink_section(self):
188199
else:
189200
utils.exit_with_error('error parsing shared library')
190201

191-
return Dylink(mem_size, mem_align, table_size, table_align, needed, export_info)
202+
return Dylink(mem_size, mem_align, table_size, table_align, needed, export_info, import_info)
192203

193204
def get_exports(self):
194205
export_section = next((s for s in self.sections() if s.type == SecType.EXPORT), None)

0 commit comments

Comments
 (0)