This is the mail archive of the mailing list for the elfutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: MiniDebugInfo support

On Fri, 2012-12-14 at 20:52 +0100, Jan Kratochvil wrote:
> Maybe libdwfl/ matches such high level feature better.

I think it does since it really is just an extra ELF file that needs to
be matched together with the main ELF file, just like the debug ELF file
needs to be matched up. If the minidebuginfo was really like its name
suggests a debuginfo file then it would have been an almost perfect fit
for libdwfl. But it is slightly different. Basically it only contains
the symtab related sections and the symtab table is not a replacement,
but an extension of the main file dynsym table. So it needs a little
tweaking by introducing a third kind of dwfl_file (main, debug and
aux_sym). But then I think it matches nicely with the rest of the
libdwfl structure.

Since I saw various other tools now support it I created an
implementation for libdwfl too. On the mjw/minisymtab branch you'll find
the implementation. I'll also post the patches to the list. There are
just two (independent) patches.

The first introduces a new ELF input flag for eu-readelf so you can
easily inspect am embedded (compressed) ELF section. It was useful while
writing the second patch and understanding what is really in the
minisymtab ELF image. But I think it is generally useful. We could
bikeshed a little about the proper name of the input flag:

 readelf: Add --elf-section input option to inspect an embedded ELF file.
 Some binaries might have (compressed) embedded ELF files inside a section.
 The default section name for this is .gnu_debugdata.  This normally
 consists of just those sections needed to provide an auxiluary symbol
 table.  But can theoretically contain other (debug) sections.  The new
 --elf-section arguments makes it possible to easily inspect it as if it
 is a normal ELF file.  libdwfl takes care of automatically decompressing
 any data in the section if necessary.
 ELF input selection:
    --elf-section[=SECTION]  Use the named SECTION (default .gnu_debugdata)
                             as (compressed) ELF input data

The second patch adds the aux_sym dwfl_file to Dwfl_Module, makes
find_symtab load it if it is there and we only have a dynsym table, and
tweaks dwfl_module_addrsym () and dwfl_module_getsym () to use it. It
seems to work nicely for me. But I should write some real tests for it.
Testing and feedback appreciated.

 libdwfl: Add minisymtab support.
 Add an auxiliary symbol table dwfl_file aux_sym to Dwfl_Module if all we
 have is the dynsym table.  The main file might contain a .gnu_debugdata
 section. The .gnu_debugdata section is a compressed embedded ELF file
 that contains the text (code) section symbols from the symtab table
 that are not in the main file dynsym table. dwfl_module_getsymtab (),
 dwfl_module_addrsym () and dwfl_module_getsym () will use the auxiliary
 symbol table when available (and no full symtab is available from the
 debug file).
    * libdwflP.h (struct Dwfl_Module): Add aux_sym, aux_symdata,
    aux_syments, aux_symstrdata and aux_symxndxdata.
    (dwfl_adjusted_aux_sym_addr): New function.
    (dwfl_deadjust_aux_sym_addr): Likewise.
    (dwfl_adjusted_st_value): Take and check symfile argument.
    (dwfl_deadjust_st_value): Likewise.
    * dwfl_module_getdwarf.c (find_prelink_address_sync): Take and
    use dwfl_file as argument to set address_sync.
    (find_debuginfo): Call find_prelink_address_sync with debug file.
    (find_aux_sym): New function.
    (find_symtab): Use find_aux_sym if all we have is the dynsym table
    and fill in aux DwflModule fields.
    (dwfl_module_getsymtab): Return syments plus aux_syments.
    * dwfl_module_addrsym.c (dwfl_module_addrsym): Check symfile
    when using same_section.
    * dwfl_module.c (__libdwfl_module_free): Free aux_sym.
    * dwfl_module_getsym.c (dwfl_module_getsym): Use auxsym table
    to retrieve symbol and name if necessary.
    * dwfl_module_info.c (dwfl_module_info): Call dwfl_adjusted_st_value
    with symfile.
    * relocate.c (resolve_symbol): Likewise.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]