MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / parse_dylink_section

Method parse_dylink_section

tools/webassembly.py:316–386  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

314
315 @memoize
316 def parse_dylink_section(self):
317 dylink_section = next(self.sections())
318 assert dylink_section.type == SecType.CUSTOM
319 self.seek(dylink_section.offset)
320 # section name
321 needed = []
322 export_info = {}
323 import_info = {}
324 runtime_paths = []
325 self.read_string() # name
326
327 if dylink_section.name == 'dylink':
328 mem_size = self.read_uleb()
329 mem_align = self.read_uleb()
330 table_size = self.read_uleb()
331 table_align = self.read_uleb()
332
333 needed_count = self.read_uleb()
334 while needed_count:
335 libname = self.read_string()
336 needed.append(libname)
337 needed_count -= 1
338 elif dylink_section.name == 'dylink.0':
339 section_end = dylink_section.offset + dylink_section.size
340 while self.tell() < section_end:
341 subsection_type = self.read_uleb()
342 subsection_size = self.read_uleb()
343 end = self.tell() + subsection_size
344 match subsection_type:
345 case DylinkType.MEM_INFO:
346 mem_size = self.read_uleb()
347 mem_align = self.read_uleb()
348 table_size = self.read_uleb()
349 table_align = self.read_uleb()
350 case DylinkType.NEEDED:
351 needed_count = self.read_uleb()
352 while needed_count:
353 libname = self.read_string()
354 needed.append(libname)
355 needed_count -= 1
356 case DylinkType.EXPORT_INFO:
357 count = self.read_uleb()
358 while count:
359 sym = self.read_string()
360 flags = self.read_uleb()
361 export_info[sym] = flags
362 count -= 1
363 case DylinkType.IMPORT_INFO:
364 count = self.read_uleb()
365 while count:
366 module = self.read_string()
367 field = self.read_string()
368 flags = self.read_uleb()
369 import_info.setdefault(module, {})
370 import_info[module][field] = flags
371 count -= 1
372 case DylinkType.RUNTIME_PATH:
373 count = self.read_uleb()

Callers 3

process_dynamic_libsFunction · 0.80
parse_dylink_sectionFunction · 0.80
get_runtime_pathsMethod · 0.80

Calls 9

sectionsMethod · 0.95
seekMethod · 0.95
read_stringMethod · 0.95
read_ulebMethod · 0.95
tellMethod · 0.95
skipMethod · 0.95
appendMethod · 0.80
printFunction · 0.70
nextFunction · 0.50

Tested by 1

get_runtime_pathsMethod · 0.64