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

Function get_section_strings

tools/extract_metadata.py:197–225  ·  view source on GitHub ↗
(module, export_map, section_name)

Source from the content-addressed store, hash-verified

195
196
197def get_section_strings(module, export_map, section_name):
198 start_name = f'__start_{section_name}'
199 stop_name = f'__stop_{section_name}'
200 if start_name not in export_map or stop_name not in export_map:
201 logger.debug(f'no start/stop symbols found for section: {section_name}')
202 return {}
203
204 start = export_map[start_name]
205 end = export_map[stop_name]
206 start_global = module.get_global(start.index)
207 end_global = module.get_global(end.index)
208 start_addr = to_unsigned(get_global_value(start_global))
209 end_addr = to_unsigned(get_global_value(end_global))
210
211 seg = find_segment_with_address(module, start_addr)
212 if not seg:
213 exit_with_error(f'unable to find segment starting at __start_{section_name}: {start_addr}')
214 seg, seg_offset = seg
215
216 asm_strings = {}
217 str_start = seg_offset
218 data = module.read_at(seg.offset, seg.size)
219 size = end_addr - start_addr
220 end = seg_offset + size
221 while str_start < end:
222 str_end = data.find(b'\0', str_start)
223 asm_strings[start_addr - seg_offset + str_start] = data_to_string(data[str_start:str_end])
224 str_start = str_end + 1
225 return asm_strings
226
227
228def get_main_reads_params(module, export_map):

Callers 1

extract_metadataFunction · 0.85

Calls 8

to_unsignedFunction · 0.85
get_global_valueFunction · 0.85
exit_with_errorFunction · 0.85
data_to_stringFunction · 0.85
get_globalMethod · 0.80
read_atMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected