bin/dwarf: force big-endian read on TMS320 COFF DWARF sections

TI's cl55 compiler writes COFF files with little-endian file and
section headers, but the data inside DWARF sections (.debug_info,
.debug_abbrev, .debug_frame, .debug_line) is laid out as 16-bit
big-endian words. The DWARF parser was reading the unit length as
LE and getting absurd values, then bailing out with zero
compilation units.

Result: afvl, avgl, afs all returned empty for every
emulateme*.ticoff2.dbg.coff in rizin-testbins even though the
file had a fully-populated .debug_info section, the abbrev
tables parsed cleanly, and the per-architecture DWARF register
mapping (added separately) was available.

Override bf_bigendian() for arch=tms320 so the DWARF endian reader
swaps correctly. The COFF info struct stays in the same
little-endian state it always was; only the dwarf reader's view
flips.

After this fix, cl55-compiled TI COFF v2 binaries with debug info
yield:
  afvl @ dbg.main  -> arg int argc @ ar4
  afs  @ dbg.main  -> int main(int argc);
  avgl             -> 7 globals (uart_address, seckrit, _lock, ...)
  pdf  @ <fn>      -> renders with signatures, named args, reflines,
                      resolved call targets
This commit is contained in:
Anton Kochkov 2026-05-27 11:24:08 +00:00 committed by NOT XVilka
parent 4221d56cb9
commit d81489e40d

View file

@ -31,6 +31,17 @@ RZ_IPI RzBinEndianReader *RzBinEndianReader_from_file(
RzBinFile *binfile, const char *sect_name);
static inline bool bf_bigendian(RzBinFile *bf) {
if (bf && bf->o && bf->o->info && bf->o->info->arch &&
!strcmp(bf->o->info->arch, "tms320")) {
/* TI COFF for TMS320C55x stores DWARF section data as
* 16-bit big-endian words even when the COFF file
* headers are little-endian. Without this override the
* DWARF parser reads the unit length as garbage and
* bails out with zero compilation units, so afvl /
* avgl / afs / pdf return nothing on cl55-built
* binaries. */
return true;
}
return bf->o && bf->o->info && bf->o->info->big_endian;
}