diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | libdw/ChangeLog | 4 | ||||
-rw-r--r-- | libdw/libdw.map | 1 | ||||
-rw-r--r-- | libdwfl/ChangeLog | 10 | ||||
-rw-r--r-- | libdwfl/dwfl_module_addrsym.c | 6 | ||||
-rw-r--r-- | libdwfl/dwfl_module_getdwarf.c | 23 | ||||
-rw-r--r-- | libdwfl/libdwfl.h | 7 | ||||
-rw-r--r-- | libdwfl/libdwflP.h | 1 |
9 files changed, 54 insertions, 3 deletions
@@ -1,3 +1,7 @@ +2013-12-16 Mark Wielaard <[email protected]> + + * NEWS (libdwfl): Add dwfl_module_getsymtab_first_global. + 2013-12-09 Josh Stone <[email protected]> * .gitignore: Add config/ar-lib, installed due to AM_PROG_AR. @@ -1,6 +1,7 @@ Version 0.158 libdwfl: dwfl_core_file_report has new parameter executable. + New function dwfl_module_getsymtab_first_global. Version 0.157 diff --git a/libdw/ChangeLog b/libdw/ChangeLog index aa7b9ca4..8b1e2c08 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,7 @@ +2013-12-16 Mark Wielaard <[email protected]> + + * libdw.map (ELFUTILS_0.158): Add dwfl_module_getsymtab_first_global. + 2013-12-10 Josh Stone <[email protected]> * memory-access.h (get_uleb128_rest_return): Removed. diff --git a/libdw/libdw.map b/libdw/libdw.map index 0438e24c..342cdfee 100644 --- a/libdw/libdw.map +++ b/libdw/libdw.map @@ -286,4 +286,5 @@ ELFUTILS_0.158 { dwfl_module_addrsym_elf; dwfl_module_getsym_elf; + dwfl_module_getsymtab_first_global; } ELFUTILS_0.157; diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index a9238d80..67f1fcff 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,13 @@ +2013-12-16 Mark Wielaard <[email protected]> + + * libdwfl.h (dwfl_module_getsymtab_first_global): New function + definition. + * dwfl_module_getdwarf.c (dwfl_module_getsymtab_first_global): New + function. + * libdwflP.h (dwfl_module_getsymtab_first_global): New internal + function definition. + * dwfl_module_addrsym.c (dwfl_module_addrsym_elf): Use new function. + 2013-12-14 Mark Wielaard <[email protected]> * dwfl_module.c (__libdwfl_module_free): Free mod->reloc_info if diff --git a/libdwfl/dwfl_module_addrsym.c b/libdwfl/dwfl_module_addrsym.c index 320d41f1..9e4f0674 100644 --- a/libdwfl/dwfl_module_addrsym.c +++ b/libdwfl/dwfl_module_addrsym.c @@ -188,9 +188,9 @@ dwfl_module_addrsym_elf (Dwfl_Module *mod, GElf_Addr addr, come first in the symbol table, then all globals. The zeroth, null entry, in the auxiliary table is skipped if there is a main table. */ - int first_global = mod->first_global + mod->aux_first_global; - if (mod->syments > 0 && mod->aux_syments > 0) - first_global--; + int first_global = INTUSE (dwfl_module_getsymtab_first_global) (mod); + if (first_global < 0) + return NULL; search_table (first_global == 0 ? 1 : first_global, syments); /* If we found nothing searching the global symbols, then try the locals. diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c index dd76f257..c4bd7395 100644 --- a/libdwfl/dwfl_module_getdwarf.c +++ b/libdwfl/dwfl_module_getdwarf.c @@ -1266,3 +1266,26 @@ dwfl_module_getsymtab (Dwfl_Module *mod) return -1; } INTDEF (dwfl_module_getsymtab) + +int +dwfl_module_getsymtab_first_global (Dwfl_Module *mod) +{ + if (mod == NULL) + return -1; + + find_symtab (mod); + if (mod->symerr == DWFL_E_NOERROR) + { + /* All local symbols should come before all global symbols. If + we have an auxiliary table make sure all the main locals come + first, then all aux locals, then all main globals and finally all + aux globals. And skip the auxiliary table zero undefined + entry. */ + int skip_aux_zero = (mod->syments > 0 && mod->aux_syments > 0) ? 1 : 0; + return mod->first_global + mod->aux_first_global - skip_aux_zero; + } + + __libdwfl_seterrno (mod->symerr); + return -1; +} +INTDEF (dwfl_module_getsymtab_first_global) diff --git a/libdwfl/libdwfl.h b/libdwfl/libdwfl.h index 3d5bede6..60160b6a 100644 --- a/libdwfl/libdwfl.h +++ b/libdwfl/libdwfl.h @@ -430,6 +430,13 @@ extern Elf *dwfl_module_getelf (Dwfl_Module *, GElf_Addr *bias) or -1 for errors. */ extern int dwfl_module_getsymtab (Dwfl_Module *mod); +/* Return the index of the first global symbol in the module's symbol + table, or -1 for errors. In each symbol table, all symbols with + STB_LOCAL binding precede the weak and global symbols. This + function returns the symbol table index one greater than the last + local symbol. */ +extern int dwfl_module_getsymtab_first_global (Dwfl_Module *mod); + /* Fetch one entry from the module's symbol table. On errors, returns NULL. If successful, fills in *SYM and returns the string for st_name. This works like gelf_getsym except that st_value is always adjusted to diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h index ba1c758d..e2e249de 100644 --- a/libdwfl/libdwflP.h +++ b/libdwfl/libdwflP.h @@ -646,6 +646,7 @@ INTDECL (dwfl_module_getelf) INTDECL (dwfl_module_getsym) INTDECL (dwfl_module_getsym_elf) INTDECL (dwfl_module_getsymtab) +INTDECL (dwfl_module_getsymtab_first_global) INTDECL (dwfl_module_getsrc) INTDECL (dwfl_module_report_build_id) INTDECL (dwfl_report_elf) |