summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kratochvil <[email protected]>2013-11-13 20:00:56 +0100
committerJan Kratochvil <[email protected]>2013-11-13 20:00:56 +0100
commit954a7b0f64346339ef12fb9c04cd2912b72c749d (patch)
treebed84b501baf4070809247041ec7e862faea6ed3
parent5dca2b62db78163535aa5c7ee5fbda32f1087d6f (diff)
Provide __libdwfl_module_getsym to get dwfl_file *
Signed-off-by: Jan Kratochvil <[email protected]>
-rw-r--r--libdwfl/ChangeLog11
-rw-r--r--libdwfl/dwfl_module_addrsym.c20
-rw-r--r--libdwfl/dwfl_module_getsym.c15
-rw-r--r--libdwfl/libdwflP.h7
4 files changed, 35 insertions, 18 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 282f0112..95e3cd7c 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,14 @@
+2013-11-06 Jan Kratochvil <[email protected]>
+
+ 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 <[email protected]>
Fix dwfl_module_addrsym for minidebuginfo.
diff --git a/libdwfl/dwfl_module_addrsym.c b/libdwfl/dwfl_module_addrsym.c
index 3d199437..d9eb0a27 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 07127b78..0f5dd37d 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 ff488132..0c862b38 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;