"& rodata",
"Total")
print("%24s %10s %6s %6s %10s %8s %7s" % headings)
- for k in sorted(sizes.keys()):
+ result = {}
+ for k in (sizes.keys()):
v = sizes[k]
+ result[k] = {}
+ result[k]["data"] = v.get(".dram0.data", 0)
+ result[k]["bss"] = v.get(".dram0.bss", 0)
+ result[k]["iram"] = sum(t for (s,t) in v.items() if s.startswith(".iram0"))
+ result[k]["flash_text"] = v.get(".flash.text", 0)
+ result[k]["flash_rodata"] = v.get(".flash.rodata", 0)
+ result[k]["total"] = sum(result[k].values())
+
+ def return_total_size(elem):
+ val = elem[1]
+ return val["total"]
+ for k,v in sorted(result.items(), key=return_total_size, reverse=True):
if ":" in k: # print subheadings for key of format archive:file
sh,k = k.split(":")
- if sh != sub_heading:
- print(sh)
- sub_heading = sh
-
- data = v.get(".dram0.data", 0)
- bss = v.get(".dram0.bss", 0)
- iram = sum(t for (s,t) in v.items() if s.startswith(".iram0"))
- flash_text = v.get(".flash.text", 0)
- flash_rodata = v.get(".flash.rodata", 0)
- total = data + bss + iram + flash_text + flash_rodata
print("%24s %10d %6d %6d %10d %8d %7d" % (k[:24],
- data,
- bss,
- iram,
- flash_text,
- flash_rodata,
- total))
+ v["data"],
+ v["bss"],
+ v["iram"],
+ v["flash_text"],
+ v["flash_rodata"],
+ v["total"]))
+ def print_archive_symbols(sections, archive):
+ interested_sections = [".dram0.data", ".dram0.bss", ".iram0.text", ".iram0.vectors", ".flash.text", ".flash.rodata"]
+ result = {}
+ for t in interested_sections:
+ result[t] = {}
+ for section in sections.values():
+ section_name = section["name"]
+ if section_name not in interested_sections:
+ continue
+ for s in section["sources"]:
+ if archive != s["archive"]:
+ continue
+ s["sym_name"] = re.sub("(.text.|.literal.|.data.|.bss.|.rodata.)", "", s["sym_name"]);
+ result[section_name][s["sym_name"]] = result[section_name].get(s["sym_name"], 0) + s["size"]
+ for t in interested_sections:
+ print "\nSymbols from section:", t
+ section_total = 0
+ for key,val in sorted(result[t].items(), key=lambda (k,v): v, reverse=True):
+ print("%s(%d)"% (key.replace(t + ".", ""), val)),
+ section_total += val
+ print "\nSection total:",section_total
+
if __name__ == "__main__":
main()