+2013-11-06 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ 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 <jan.kratochvil@redhat.com>
Fix dwfl_module_addrsym for minidebuginfo.
/* 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)
{
{
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
}
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
#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;
__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)
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;