반응형
.map 파일에서 메모리 레이아웃을 그래픽으로 표시하는 방법
나의 gcc 빌드 툴체인은 .map 파일을 생산한다.메모리 맵을 그래픽으로 표시하는 방법
Python에서 대본의 시작은 이렇다.지도 파일을 단면 및 기호 목록(상반부)에 로드한다.그런 다음 HTML을 사용하여 맵을 렌더링(또는 원하는 대로 작업)한다.sections
그리고symbols
목록).
다음 행을 수정하여 스크립트를 제어할 수 있다.
with open('t.map') as f:
colors = ['9C9F84', 'A97D5D', 'F7DCB4', '5C755E']
total_height = 32.0
map210파이를 치다
from __future__ import with_statement
import re
class Section:
def __init__(self, address, size, segment, section):
self.address = address
self.size = size
self.segment = segment
self.section = section
def __str__(self):
return self.section+""
class Symbol:
def __init__(self, address, size, file, name):
self.address = address
self.size = size
self.file = file
self.name = name
def __str__(self):
return self.name
#===============================
# Load the Sections and Symbols
#
sections = []
symbols = []
with open('t.map') as f:
in_sections = True
for line in f:
m = re.search('^([0-9A-Fx]+)\s+([0-9A-Fx]+)\s+((\[[ 0-9]+\])|\w+)\s+(.*?)\s*$', line)
if m:
if in_sections:
sections.append(Section(eval(m.group(1)), eval(m.group(2)), m.group(3), m.group(5)))
else:
symbols.append(Symbol(eval(m.group(1)), eval(m.group(2)), m.group(3), m.group(5)))
else:
if len(sections) > 0:
in_sections = False
#===============================
# Gererate the HTML File
#
colors = ['9C9F84', 'A97D5D', 'F7DCB4', '5C755E']
total_height = 32.0
segments = set()
for s in sections: segments.add(s.segment)
segment_colors = dict()
i = 0
for s in segments:
segment_colors[s] = colors[i % len(colors)]
i += 1
total_size = 0
for s in symbols:
total_size += s.size
sections.sort(lambda a,b: a.address - b.address)
symbols.sort(lambda a,b: a.address - b.address)
def section_from_address(addr):
for s in sections:
if addr >= s.address and addr < (s.address + s.size):
return s
return None
print "<html><head>"
print " <style>a { color: black; text-decoration: none; font-family:monospace }</style>"
print "<body>"
print "<table cellspacing='1px'>"
for sym in symbols:
section = section_from_address(sym.address)
height = (total_height/total_size) * sym.size
font_size = 1.0 if height > 1.0 else height
print "<tr style='background-color:#%s;height:%gem;line-height:%gem;font-size:%gem'><td style='overflow:hidden'>" % \
(segment_colors[section.segment], height, height, font_size)
print "<a href='#%s'>%s</a>" % (sym.name, sym.name)
print "</td></tr>"
print "</table>"
print "</body></html>"
그리고 여기 그것이 출력하는 HTML의 잘못된 렌더링이 있다.
지도 파일에는 일반적으로 표시되지 않는 정보와 함께 지도 파일에 정보를 표시하는 C# 프로그램을 작성했다(사용할 수 있는 정적 기호처럼).binutils
). 여기서 코드를 사용할 수 있다.간단히 말해서, 지도 파일을 분석하고 또한BINUTILS
(가능한 경우) 더 많은 정보를 수집할 수 있다.실행하려면 코드를 다운로드하고 비주얼 스튜디오에서 프로젝트를 실행해야 하며 지도 파일 경로를 찾아 다음Analyze
.
참고: 다음에 대해서만 작동GCC/LD
지도 파일
스크린샷: [
반응형
'Programing' 카테고리의 다른 글
Axios 인터셉터 토큰 헤더가 구성에는 있지만 요청 헤더에는 없음 (0) | 2022.04.23 |
---|---|
Vue.js의 지시어를 사용하여 숫자 값만 수락하는 입력 필드 (0) | 2022.04.23 |
Java에서 돈으로 사용할 데이터 유형을 선택하십시오. (0) | 2022.04.23 |
Java에서 System variable 값을 얻는 방법은? (0) | 2022.04.23 |
C에서 NULL은 0이어야 하는가? (0) | 2022.04.23 |