From: Jan Kratochvil Date: Wed, 13 Nov 2013 19:00:56 +0000 (+0100) Subject: Provide __libdwfl_module_getsym to get dwfl_file * X-Git-Tag: elfutils-0.158~66 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=954a7b0f64346339ef12fb9c04cd2912b72c749d;p=thirdparty%2Felfutils.git Provide __libdwfl_module_getsym to get dwfl_file * Signed-off-by: Jan Kratochvil --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 282f0112b..95e3cd7cc 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,14 @@ +2013-11-06 Jan Kratochvil + + Provide __libdwfl_module_getsym to get dwfl_file *. + * dwfl_module_addrsym.c (dwfl_module_addrsym) (i_to_symfile): Remove. + (dwfl_module_addrsym) (search_table): New variable file. Use + __libdwfl_module_getsym. Use file. + * dwfl_module_getsym.c (dwfl_module_getsym): Rename to ... + (__libdwfl_module_getsym): ... here. Add parameter filep. Set it. + (dwfl_module_getsym): New wrapper. + * libdwflP.h (__libdwfl_module_getsym): New declaration. + 2013-11-13 Jan Kratochvil Fix dwfl_module_addrsym for minidebuginfo. diff --git a/libdwfl/dwfl_module_addrsym.c b/libdwfl/dwfl_module_addrsym.c index 3d1994370..d9eb0a274 100644 --- a/libdwfl/dwfl_module_addrsym.c +++ b/libdwfl/dwfl_module_addrsym.c @@ -86,20 +86,6 @@ dwfl_module_addrsym (Dwfl_Module *mod, GElf_Addr addr, /* Keep track of the lowest address a relevant sizeless symbol could have. */ GElf_Addr min_label = 0; - inline struct dwfl_file *i_to_symfile (int ndx) - { - int skip_aux_zero = (mod->syments > 0 && mod->aux_syments > 0) ? 1 : 0; - if (ndx < mod->first_global) - return mod->symfile; // main symbol table (locals). - else if (ndx < mod->first_global + mod->aux_first_global - skip_aux_zero) - return &mod->aux_sym; // aux symbol table (locals). - else if ((size_t) ndx - < mod->syments + mod->aux_first_global - skip_aux_zero) - return mod->symfile; // main symbol table (globals). - else - return &mod->aux_sym; // aux symbol table (globals). - } - /* Look through the symbol table for a matching symbol. */ inline void search_table (int start, int end) { @@ -107,7 +93,9 @@ dwfl_module_addrsym (Dwfl_Module *mod, GElf_Addr addr, { GElf_Sym sym; GElf_Word shndx; - const char *name = INTUSE(dwfl_module_getsym) (mod, i, &sym, &shndx); + struct dwfl_file *file; + const char *name = __libdwfl_module_getsym (mod, i, &sym, &shndx, + &file); if (name != NULL && name[0] != '\0' && sym.st_shndx != SHN_UNDEF && sym.st_value <= addr @@ -152,7 +140,7 @@ dwfl_module_addrsym (Dwfl_Module *mod, GElf_Addr addr, } else if (closest_name == NULL && sym.st_value >= min_label - && same_section (&sym, i_to_symfile (i), shndx)) + && same_section (&sym, file, shndx)) { /* Handwritten assembly symbols sometimes have no st_size. If no symbol with proper size includes diff --git a/libdwfl/dwfl_module_getsym.c b/libdwfl/dwfl_module_getsym.c index 07127b78b..0f5dd37db 100644 --- a/libdwfl/dwfl_module_getsym.c +++ b/libdwfl/dwfl_module_getsym.c @@ -29,8 +29,10 @@ #include "libdwflP.h" const char * -dwfl_module_getsym (Dwfl_Module *mod, int ndx, - GElf_Sym *sym, GElf_Word *shndxp) +internal_function +__libdwfl_module_getsym (Dwfl_Module *mod, int ndx, + GElf_Sym *sym, GElf_Word *shndxp, + struct dwfl_file **filep) { if (unlikely (mod == NULL)) return NULL; @@ -150,6 +152,15 @@ dwfl_module_getsym (Dwfl_Module *mod, int ndx, __libdwfl_seterrno (DWFL_E_BADSTROFF); return NULL; } + if (filep) + *filep = file; return (const char *) symstrdata->d_buf + sym->st_name; } + +const char * +dwfl_module_getsym (Dwfl_Module *mod, int ndx, + GElf_Sym *sym, GElf_Word *shndxp) +{ + return __libdwfl_module_getsym (mod, ndx, sym, shndxp, NULL); +} INTDEF (dwfl_module_getsym) diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h index ff488132e..0c862b383 100644 --- a/libdwfl/libdwflP.h +++ b/libdwfl/libdwflP.h @@ -421,6 +421,13 @@ extern Dwfl_Error __libdwfl_relocate_value (Dwfl_Module *mod, Elf *elf, GElf_Addr *value) internal_function; +/* See dwfl_module_getsym. *FILEP will be set to the file of *SYM. + FILEP can be NULL. */ +extern const char *__libdwfl_module_getsym (Dwfl_Module *mod, int ndx, + GElf_Sym *sym, GElf_Word *shndxp, + struct dwfl_file **filep) + internal_function; + /* Ensure that MOD->ebl is set up. */ extern Dwfl_Error __libdwfl_module_getebl (Dwfl_Module *mod) internal_function;