google / bloaty

Bloaty: a size profiler for binaries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

crash on reversed high_pc/low_pc with -d compileunits

bence42 opened this issue · comments

bloaty crashes when the high_pc is of a DIE is greater than the low_pc.
Also when the high_pc is 0. Both of these happen with GHS arm 2022 compiler

bloaty version: 22a83c0
cmd: bloaty -d compileunits bar.elf
compiler: GHS arm 2022

(gdb) bt
#0  0x00007fb272262662 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x0000560bd423625a in bloaty::Throw (str=0x560bd459b874 "Failed to open file.", line=974) at /home/zbb2bp/mnt/ws/others/bloaty/src/util.cc:23
#2  0x0000560bd41e0692 in bloaty::MmapInputFileFactory::OpenFile (this=0x7fff880a7528, filename="build/target_r5f/bin/perception.elf") at /home/zbb2bp/mnt/ws/others/bloaty/src/bloaty.cc:974
#3  0x0000560bd41e32df in bloaty::Bloaty::GetObjectFile (this=0x7fff880a7300, filename="build/target_r5f/bin/perception.elf") at /home/zbb2bp/mnt/ws/others/bloaty/src/bloaty.cc:1552
#4  0x0000560bd41e3563 in bloaty::Bloaty::AddFilename (this=0x7fff880a7300, filename="build/target_r5f/bin/perception.elf", is_base=false) at /home/zbb2bp/mnt/ws/others/bloaty/src/bloaty.cc:1575
#5  0x0000560bd41e7601 in bloaty::BloatyDoMain (options=..., file_factory=..., output=0x7fff880a7640) at /home/zbb2bp/mnt/ws/others/bloaty/src/bloaty.cc:2252
#6  0x0000560bd41e7a39 in bloaty::BloatyMain (options=..., file_factory=..., output=0x7fff880a7640, error=0x7fff880a7550) at /home/zbb2bp/mnt/ws/others/bloaty/src/bloaty.cc:2290
#7  0x0000560bd41da82e in main (argc=1, argv=0x7fff880a7818) at /home/zbb2bp/mnt/ws/others/bloaty/src/main.cc:36

at the crash the high_pc was 0x10222c0c, so I've checked how the binary looked, and it indeed has this strange reversed high/low pc:

$ readelf --debug-dump=info bar.elf  | grep -i -B2 10222c0c
 <5><cdea7>: Abbrev Number: 34 (DW_TAG_lexical_block)
    <cdea8>   DW_AT_low_pc      : 0x10222c0e
    <cdeac>   DW_AT_high_pc     : 0x10222c0c

I'm not sure if I can provide a dummy binary that showcases this strange reversed pc for a dwarf tag.