@@ -72,13 +72,14 @@ class DylinkType(IntEnum):
7272 MEM_INFO = 1
7373 NEEDED = 2
7474 EXPORT_INFO = 3
75+ IMPORT_INFO = 4
7576
7677
7778Section = namedtuple ('Section' , ['type' , 'size' , 'offset' ])
7879Limits = namedtuple ('Limits' , ['flags' , 'initial' , 'maximum' ])
7980Import = namedtuple ('Import' , ['kind' , 'module' , 'field' ])
8081Export = 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
8485class 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