[Dwarf-Discuss] target address dependency of the FDE header in DWARF CFI
David Anderson
davea42@earthlink.net
Sat Dec 10 16:40:43 GMT 2011
On 12/10/2011 05:16 AM, Eli Bendersky wrote:
>
> But what about a parser library, decoupled from actual execution? I
> looked at the code of libdwarf and after some digging it appears that
> it uses the EI_CLASS of the enclosing ELF object. If it's ELFCLASS64,
> it assumes a 8-byte target address size, otherwise 4 bytes.
>
> I wonder if this is indeed the right way to go. I learned that the
> DWARF format is quite distinct from target address size. That is, CUs
> with 8-byte address size can appear in DWARF32 sections. But perhaps
> the ELF class is more telling.
The code you looked at in libdwarf is the default address size, the best
guess available before
any CUs are read. When a CU is read from .debug_info (assuming there
is a .debug_info...)
the address size from the CU is picked up and replaces the default (for
that CU only).
The CU specific address_size is used for that CU's CIE/FDE set. See
de_pointer_size, cc_address_size
(sorry for the naming disconnect, I should make that more regular), and
ci_address_size in libdwarf.
When a DWARF4 .debug_frame is read and there is no CU-specific
address_size known the
address size from .debug_frame is used.
I happen to have a test object with .debug_frame and no .debug_info (and
the Elf default address_size
does *not* match the address_size of the .debug_frame!) so I added code
so the libdwarf caller
can set the address_size .... of course the only way to know to make
that call is via a human
realizing the situation. But at least that made it possible that a
determined human could use
dwarfdump/libdwarf on an object file like the one I mention here.
If you notice bugs/infelicities/omissions in libdwarf or dwarfdump,
please do let me know. Thanks.
I just noticed I failed to add support for DW_LNE_set_discriminator
(DWARF4) so I'm working on that 'as we speak'.
DavidAnderson
--
Benford's Corollary to Clarke's Law: "Any technology distinguishable from magic is insufficiently advanced."
More information about the Dwarf-discuss
mailing list