Aggregate sizes by crate and section type.
(entries)
| 380 | |
| 381 | |
| 382 | def aggregate_by_crate(entries): |
| 383 | """Aggregate sizes by crate and section type.""" |
| 384 | crate_sizes = defaultdict(lambda: {"code": 0, "rodata": 0, "data": 0, "total": 0}) |
| 385 | |
| 386 | for section, crate, _symbol, size in entries: |
| 387 | if section == "CODE": |
| 388 | crate_sizes[crate]["code"] += size |
| 389 | elif section == ".rodata": |
| 390 | crate_sizes[crate]["rodata"] += size |
| 391 | elif section in (".data", ".bss", ".data.rel.ro"): |
| 392 | crate_sizes[crate]["data"] += size |
| 393 | else: |
| 394 | continue |
| 395 | crate_sizes[crate]["total"] += size |
| 396 | |
| 397 | return dict(crate_sizes) |
| 398 | |
| 399 | |
| 400 | def build_folded_stacks(entries, category): |