<p>My gcc build toolchain produces a .map file. How do I display the memory map graphically?</p>

[{'answer_id': 112078, 'author': 'Frank Krueger', 'author_id': 338, 'author_profile': 'https://Stackoverflow.com/users/338', 'pm_score': 6, 'selected': True, 'text': '<p>Here\'s the beginnings of a script in Python. It loads the map file into a list of Sections and Symbols (first half). It then renders the map using HTML (or do whatever you want with the <code>sections</code> and <code>symbols</code> lists).</p>\n\n<p>You can control the script by modifying these lines:</p>\n\n<pre><code>with open(\'t.map\') as f:\ncolors = [\'9C9F84\', \'A97D5D\', \'F7DCB4\', \'5C755E\']\ntotal_height = 32.0\n</code></pre>\n\n<p>map2html.py</p>\n\n<pre><code>from __future__ import with_statement\nimport re\n\nclass Section:\n    def __init__(self, address, size, segment, section):\n        self.address = address\n        self.size = size\n        self.segment = segment\n        self.section = section\n    def __str__(self):\n        return self.section+""\n\nclass Symbol:\n    def __init__(self, address, size, file, name):\n        self.address = address\n        self.size = size\n        self.file = file\n        self.name = name\n    def __str__(self):\n        return self.name\n\n#===============================\n# Load the Sections and Symbols\n#\nsections = []\nsymbols = []\n\nwith open(\'t.map\') as f:\n    in_sections = True\n    for line in f:\n        m = re.search(\'^([0-9A-Fx]+)\\s+([0-9A-Fx]+)\\s+((\\[[ 0-9]+\\])|\\w+)\\s+(.*?)\\s*$\', line)\n        if m:\n            if in_sections:\n                sections.append(Section(eval(m.group(1)), eval(m.group(2)), m.group(3), m.group(5)))\n            else:\n                symbols.append(Symbol(eval(m.group(1)), eval(m.group(2)), m.group(3), m.group(5)))\n        else:\n            if len(sections) &gt; 0:\n                in_sections = False\n\n\n#===============================\n# Gererate the HTML File\n#\n\ncolors = [\'9C9F84\', \'A97D5D\', \'F7DCB4\', \'5C755E\']\ntotal_height = 32.0\n\nsegments = set()\nfor s in sections: segments.add(s.segment)\nsegment_colors = dict()\ni = 0\nfor s in segments:\n    segment_colors[s] = colors[i % len(colors)]\n    i += 1\n\ntotal_size = 0\nfor s in symbols:\n    total_size += s.size\n\nsections.sort(lambda a,b: a.address - b.address)\nsymbols.sort(lambda a,b: a.address - b.address)\n\ndef section_from_address(addr):\n    for s in sections:\n        if addr &gt;= s.address and addr &lt; (s.address + s.size):\n            return s\n    return None\n\nprint "&lt;html&gt;&lt;head&gt;"\nprint "  &lt;style&gt;a { color: black; text-decoration: none; font-family:monospace }&lt;/style&gt;"\nprint "&lt;body&gt;"\nprint "&lt;table cellspacing=\'1px\'&gt;"\nfor sym in symbols:\n    section = section_from_address(sym.address)\n    height = (total_height/total_size) * sym.size\n    font_size = 1.0 if height &gt; 1.0 else height\n    print "&lt;tr style=\'background-color:#%s;height:%gem;line-height:%gem;font-size:%gem\'&gt;&lt;td style=\'overflow:hidden\'&gt;" % \\\n        (segment_colors[section.segment], height, height, font_size)\n    print "&lt;a href=\'#%s\'&gt;%s&lt;/a&gt;" % (sym.name, sym.name)\n    print "&lt;/td&gt;&lt;/tr&gt;"\nprint "&lt;/table&gt;"\nprint "&lt;/body&gt;&lt;/html&gt;"\n</code></pre>\n\n<p>And here\'s a bad rendering of the HTML it outputs:</p>\n\n<p><img src="https://i.imgur.com/jsGhtBn.png" alt="Map"></p>\n'}, {'answer_id': 35893722, 'author': 'Sredni', 'author_id': 1761205, 'author_profile': 'https://Stackoverflow.com/users/1761205', 'pm_score': 3, 'selected': False, 'text': '<p>I\'ve written a C# program to display the information in a Map file along with information not usually present in the map file (like static symbols provided you can use <code>binutils</code>). The code is available <a href="https://github.com/govind-mukundan/MapViewer" rel="nofollow noreferrer">here</a>. In short it parses the map file and also uses <code>BINUTILS</code> (if available) to gather more information. To run it you need to download the code and run the project under visual studio, browse to the map file path and click <code>Analyze</code>.</p>\n\n<p>Note: Only works for <code>GCC/LD</code> map files</p>\n\n<p>Screenshot:\n[<img src="https://i.stack.imgur.com/W9uZ9.png" alt="3]"></p>\n'}]
['https://Stackoverflow.com/questions/48426', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/445087/']