summaryrefslogtreecommitdiff
path: root/elfutils/libdwfl/dwfl_module_getdwarf.c
diff options
context:
space:
mode:
Diffstat (limited to 'elfutils/libdwfl/dwfl_module_getdwarf.c')
-rw-r--r--elfutils/libdwfl/dwfl_module_getdwarf.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/elfutils/libdwfl/dwfl_module_getdwarf.c b/elfutils/libdwfl/dwfl_module_getdwarf.c
index dbb1d604..14fcd550 100644
--- a/elfutils/libdwfl/dwfl_module_getdwarf.c
+++ b/elfutils/libdwfl/dwfl_module_getdwarf.c
@@ -61,6 +61,10 @@ open_elf (Dwfl_Module *mod, struct dwfl_file *file)
{
if (file->elf == NULL)
{
+ /* CBFAIL uses errno if it's set, so clear it first in case we don't
+ set it with an open failure below. */
+ errno = 0;
+
/* If there was a pre-primed file name left that the callback left
behind, try to open that file name. */
if (file->fd < 0 && file->name != NULL)
@@ -564,7 +568,7 @@ find_debuginfo (Dwfl_Module *mod)
static Dwfl_Error
load_symtab (struct dwfl_file *file, struct dwfl_file **symfile,
Elf_Scn **symscn, Elf_Scn **xndxscn,
- size_t *syments, GElf_Word *strshndx)
+ size_t *syments, int *first_global, GElf_Word *strshndx)
{
bool symtab = false;
Elf_Scn *scn = NULL;
@@ -580,6 +584,7 @@ load_symtab (struct dwfl_file *file, struct dwfl_file **symfile,
*symfile = file;
*strshndx = shdr->sh_link;
*syments = shdr->sh_size / shdr->sh_entsize;
+ *first_global = shdr->sh_info;
if (*xndxscn != NULL)
return DWFL_E_NOERROR;
break;
@@ -840,11 +845,14 @@ find_symtab (Dwfl_Module *mod)
if (mod->symerr != DWFL_E_NOERROR)
return;
+ mod->first_global = -1; /* Unknown, unless explicitly set by load_symtab. */
+
/* First see if the main ELF file has the debugging information. */
Elf_Scn *symscn = NULL, *xndxscn = NULL;
GElf_Word strshndx;
mod->symerr = load_symtab (&mod->main, &mod->symfile, &symscn,
- &xndxscn, &mod->syments, &strshndx);
+ &xndxscn, &mod->syments, &mod->first_global,
+ &strshndx);
switch (mod->symerr)
{
default:
@@ -863,7 +871,8 @@ find_symtab (Dwfl_Module *mod)
case DWFL_E_NOERROR:
mod->symerr = load_symtab (&mod->debug, &mod->symfile, &symscn,
- &xndxscn, &mod->syments, &strshndx);
+ &xndxscn, &mod->syments,
+ &mod->first_global, &strshndx);
break;
case DWFL_E_CB: /* The find_debuginfo hook failed. */
@@ -902,7 +911,7 @@ find_symtab (Dwfl_Module *mod)
return;
}
- /* Cache the data; MOD->syments was set above. */
+ /* Cache the data; MOD->syments and MOD->first_global were set above. */
mod->symstrdata = elf_getdata (elf_getscn (mod->symfile->elf, strshndx),
NULL);