Skip to content

Commit

Permalink
SuperSize: Fix crash with dwarf mode
Browse files Browse the repository at this point in the history
that happens when the last symbol in a section has no reported size in
nm.

Bug: 1340597
Change-Id: I5782d6ed8a1277de2059afbcf3db248bf5946aec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3736463
Reviewed-by: Sam Maier <[email protected]>
Commit-Queue: Andrew Grieve <[email protected]>
Auto-Submit: Andrew Grieve <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1019313}
  • Loading branch information
agrieve authored and Chromium LUCI CQ committed Jun 29, 2022
1 parent dff4ccc commit 2b23769
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tools/binary_size/libsupersize/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,15 +664,15 @@ def _AddUnattributedSectionSymbols(raw_symbols, section_ranges, source_path):
raw_symbols, lambda s: s.section_name):
seen_sections.add(section_name)
# Get last Last symbol in group.
sym = None # Needed for pylint.
for sym in group:
pass
end_address = sym.end_address # pylint: disable=undefined-loop-variable
size_from_syms = end_address - section_ranges[section_name][0]
overhead = section_ranges[section_name][1] - size_from_syms
assert overhead >= 0, (
('End of last symbol (%x) in section %s is %d bytes after the end of '
'section from readelf (%x).') % (end_address, section_name, -overhead,
sum(section_ranges[section_name])))
'Last symbol (%s) ends %d bytes after section boundary (%x)' %
(sym, -overhead, sum(section_ranges[section_name])))
if overhead > 0 and section_name not in models.BSS_SECTIONS:
new_syms_by_section[section_name].append(
models.Symbol(section_name,
Expand Down
2 changes: 1 addition & 1 deletion tools/binary_size/libsupersize/nm.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def CreateUniqueSymbols(elf_path, section_ranges):
sym.section_name = section_name

if i + 1 < len(sorted_symbols):
next_addr = sorted_symbols[i + 1].address
next_addr = min(section_end, sorted_symbols[i + 1].address)
else:
next_addr = section_end

Expand Down

0 comments on commit 2b23769

Please sign in to comment.