From d81489e40dce8645ea0bb4267751754bc8199c61 Mon Sep 17 00:00:00 2001 From: Anton Kochkov Date: Wed, 27 May 2026 11:24:08 +0000 Subject: [PATCH] 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 @ -> renders with signatures, named args, reflines, resolved call targets --- librz/bin/dwarf/dwarf_private.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/librz/bin/dwarf/dwarf_private.h b/librz/bin/dwarf/dwarf_private.h index 33bdb51aa7..006a446218 100644 --- a/librz/bin/dwarf/dwarf_private.h +++ b/librz/bin/dwarf/dwarf_private.h @@ -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; }