memtab.parsers.map module¶
Overview¶
The Map File Parser is a module that parses linker map files and extracts information about memory regions, sections, and symbols in a format compatible with memtab’s symbols dictionary.
Linker map files contain detailed information about how a program’s code and data are laid out in memory. The MapFileParser class analyzes these files to extract this information in a structured way.
This tool was developed specifically for parsing GNU linker map files generated by arm-none-eabi-ld, but it can be adapted for other linkers with similar formats.
Usage¶
To use the Map File Parser:
from memtab import MapFileParser
# Parse a map file
parser = MapFileParser("/path/to/your/map/file.map")
# Access parsed data
memory_regions = parser.get_memory_regions()
sections = parser.get_sections()
symbols = parser.get_symbols_dict()
Features¶
Parses memory regions with their origins, lengths, and attributes
Extracts sections with their addresses and sizes
Extracts symbols with their addresses, sizes, and memory types
Assigns regions to symbols based on their addresses
Provides data in a format compatible with memtab’s symbols dictionary
Integration with memtab¶
The MapFileParser class is designed to work seamlessly with memtab. The symbols extracted by the parser can be used in the same way as the symbols dictionary in memtab.py.
References:¶
- class memtab.parsers.map.MapFileParser(map_file_path)¶
Bases:
MemtabParserParser for .map files generated by linkers like GNU LD.
This class parses a .map file and extracts memory regions, sections, and symbols into a structure compatible with memtab’s symbols dictionary.
- command = 'map'¶
- gnu_map_file_headers = {'Archive member included to satisfy reference by file (symbol)': <function MapFileParser.__process_archives>, 'Discarded input sections': <function MapFileParser.__process_discarded>, 'Linker script and memory map': <function MapFileParser.__process_map>, 'Memory Configuration': <function MapFileParser.__process_memory_config>}¶
- parse_output_into_results()¶
Parse the map file to extract memory regions, sections, and symbols.
- Return type:
None
- run_system_command()¶
Run a system command and optionally cache the results.
- Return type:
None