Skip to content

Split dwarf.c into per-section files under format/dwarf ##bin - #26932

Merged
trufae merged 5 commits into
radareorg:masterfrom
phix33:dwarf-split-files
Oct 9, 2026
Merged

trufae merged 5 commits into
radareorg:masterfrom
phix33:dwarf-split-files

Conversation

@phix33

@phix33 phix33 commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator
  • Mark this if you consider it ready to merge
  • I've added tests (optional)
  • I wrote some lines in the book (optional)

Description

libr/bin/dwarf.c had grown to 5043 lines holding eleven unrelated parsers. This moves it to libr/bin/format/dwarf/ and splits it by section:

$ wc -l libr/bin/format/dwarf/*.c
   94 abbrev.c     .debug_abbrev
  111 aranges.c    .debug_aranges
  543 dump.c       the id dumps and their name tables
  235 dwarf.c      section lookup and the shared byte readers
  561 eh_frame.c   Itanium LSDA and .eh_frame
  427 index.c      the DWARF 5 str_offsets/addr/loclists_base resolver
 1239 info.c       .debug_info DIEs and compilation units
 1197 line.c       .debug_line
  269 loc.c        .debug_loc
  329 loclists.c   .debug_loclists
  • Every function body is moved verbatim; git diff --color-moved=dimmed-zebra shows only moved blocks plus includes, a private dwarf.h with the READ* macros, the section enum, two typedefs and sixteen R_IPI dwarf_* prototypes, and the static drops those need. The five generically named helpers (get_section, ...) get the dwarf_ prefix first so nothing generic leaves the file; the lib builds with -fvisibility=hidden, so nm -D of libr_bin.so is unchanged.
  • Two small commits land before the move so the split itself is a pure move: abbrev_find replaces three identical bsearch pairs in the CU loops, and get_section_bytes only reads an Elf_Chdr when the object is an ELF, instead of casting whatever bin_obj is to ELFOBJ for any zdebug/SHF_COMPRESSED section (non-ELF compressed sections now return NULL, as the header check already made them).
  • format/dwarf/deps.mk follows format/pdb/deps.mk; meson lists the ten files.
  • The eh_frame/LSDA code keeps its r_bin_dwarf_ names and i/private.h declarations.

id, CL, idx, tl, t and afv after aaa are byte-identical to master on ten DWARF fixtures (2.4 M lines compared), and the load cost is unchanged. The new db/formats/dwarf case pins the SHF_COMPRESSED path on the .debug fixture debuglink already uses (123228 rows); it fails when the decoder is skipped.

@phix33 phix33 changed the title Dwarf split files Split dwarf.c into per-section files under format/dwarf ##bin Oct 8, 2026
@trufae
trufae merged commit 829b3cf into radareorg:master Oct 9, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants