The thing is, many real-world DWARF files have this problem, so the
Really? Do you have examples? Are they generated by current compilers?
message is now only a warning in --strict mode, and such files have
always been deemed safe for consumption by <dwarf>. Alas, the case that
we see here is special:
Dwarf_Die die_mem, *die = dwarf_offdie (dw, 0xab, &die_mem);
Dwarf_Die child;
dwarf_child (die, &child); // this actually passes
So libdw happily gives us a DIE that supposedly lies at 0xb1,
interpreting the first bytes of .debug_abbrev as DIE.
I agree that this is a libdw bug.
I might turn that combination (empty chain + no null entry) into a
hard
error in dwarflint, but that seems rather convoluted. I think this is
something that should be fixed in libdw. I've done that, the result is
on the branch pmachata/dwarf_child_overrun.
I committed it with some cosmetic cleanup.
Thanks,
Roland