blob: 147f4afc04b667e9ea8a93cbdeb96dd73ed86a8a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#!/usr/bin/env python3
import sys
# video memory - stack
TOP_MEM = 0xc000 - 256
def main():
if len(sys.argv) != 3:
sys.exit("usage: %s load_addr filename.map" % sys.argv[0])
load_addr = int(sys.argv[1])
with open(sys.argv[2], "r") as fd:
lines = fd.readlines()
# warnings
for line in lines:
if "l__INITIALIZED" in line:
init_size = int(line.split()[0], base=16)
if init_size != 0:
print("*WARNING* Initialized data found")
# search for HEAP
for line in lines:
if "s__HEAP" in line:
heap_addr = int(line.split()[0], base=16)
print("""\
***
Max: {} bytes
Current: {} bytes ({} bytes left)
***
""".format(TOP_MEM - load_addr, heap_addr - load_addr,
TOP_MEM - heap_addr - load_addr))
sys.exit(0)
sys.exit("HEAP size not found")
if __name__ == "__main__":
main()
|