]> granicus.if.org Git - esp-idf/commitdiff
Merge branch 'feature/idf_size_report_symbols' into 'master'
authorIvan Grokhotkov <ivan@espressif.com>
Fri, 20 Apr 2018 15:55:19 +0000 (23:55 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Fri, 20 Apr 2018 15:55:19 +0000 (23:55 +0800)
Feature/idf-size: report per-archive symbols and their sizes

See merge request idf/esp-idf!1956

1  2 
make/project.mk
tools/idf_size.py

diff --cc make/project.mk
Simple merge
index 90721bf0d207f507a2574b03cc468105581ed153,00fc2fa1385dd7b14676c652ac3cad2fd7a2825d..1893082ffb5568c901c87145595e38681688f470
@@@ -205,31 -220,50 +221,53 @@@ def print_detailed_sizes(sections, key
                  "& 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()