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.c60
1 files changed, 11 insertions, 49 deletions
diff --git a/elfutils/libdwfl/dwfl_module_getdwarf.c b/elfutils/libdwfl/dwfl_module_getdwarf.c
index 652383be..06cb4917 100644
--- a/elfutils/libdwfl/dwfl_module_getdwarf.c
+++ b/elfutils/libdwfl/dwfl_module_getdwarf.c
@@ -1,5 +1,5 @@
/* Find debugging and symbol information for a module in libdwfl.
- Copyright (C) 2005, 2006, 2007, 2008 Red Hat, Inc.
+ Copyright (C) 2005, 2006, 2007, 2008, 2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -69,10 +69,11 @@ open_elf (Dwfl_Module *mod, struct dwfl_file *file)
if (file->fd < 0)
return CBFAIL;
- file->elf = elf_begin (file->fd, ELF_C_READ_MMAP_PRIVATE, NULL);
+ Dwfl_Error error = __libdw_open_file (&file->fd, &file->elf, true, false);
+ if (error != DWFL_E_NOERROR)
+ return error;
}
-
- if (unlikely (elf_kind (file->elf) != ELF_K_ELF))
+ else if (unlikely (elf_kind (file->elf) != ELF_K_ELF))
{
close (file->fd);
file->fd = -1;
@@ -119,8 +120,9 @@ open_elf (Dwfl_Module *mod, struct dwfl_file *file)
/* Find the main ELF file for this module and open libelf on it.
When we return success, MOD->main.elf and MOD->main.bias are set up. */
-static void
-find_file (Dwfl_Module *mod)
+void
+internal_function
+__libdwfl_getelf (Dwfl_Module *mod)
{
if (mod->main.elf != NULL /* Already done. */
|| mod->elferr != DWFL_E_NOERROR) /* Cached failure. */
@@ -495,7 +497,7 @@ find_symtab (Dwfl_Module *mod)
|| mod->symerr != DWFL_E_NOERROR) /* Cached previous failure. */
return;
- find_file (mod);
+ __libdwfl_getelf (mod);
mod->symerr = mod->elferr;
if (mod->symerr != DWFL_E_NOERROR)
return;
@@ -591,7 +593,7 @@ __libdwfl_module_getebl (Dwfl_Module *mod)
{
if (mod->ebl == NULL)
{
- find_file (mod);
+ __libdwfl_getelf (mod);
if (mod->elferr != DWFL_E_NOERROR)
return mod->elferr;
@@ -659,7 +661,7 @@ find_dw (Dwfl_Module *mod)
|| mod->dwerr != DWFL_E_NOERROR) /* Cached previous failure. */
return;
- find_file (mod);
+ __libdwfl_getelf (mod);
mod->dwerr = mod->elferr;
if (mod->dwerr != DWFL_E_NOERROR)
return;
@@ -700,46 +702,6 @@ find_dw (Dwfl_Module *mod)
mod->dwerr = __libdwfl_canon_error (mod->dwerr);
}
-
-Elf *
-dwfl_module_getelf (Dwfl_Module *mod, GElf_Addr *loadbase)
-{
- if (mod == NULL)
- return NULL;
-
- find_file (mod);
- if (mod->elferr == DWFL_E_NOERROR)
- {
- if (mod->e_type == ET_REL && ! mod->main.relocated)
- {
- /* Before letting them get at the Elf handle,
- apply all the relocations we know how to. */
-
- mod->main.relocated = true;
- if (likely (__libdwfl_module_getebl (mod) == DWFL_E_NOERROR))
- {
- (void) __libdwfl_relocate (mod, mod->main.elf, false);
-
- if (mod->debug.elf == mod->main.elf)
- mod->debug.relocated = true;
- else if (mod->debug.elf != NULL && ! mod->debug.relocated)
- {
- mod->debug.relocated = true;
- (void) __libdwfl_relocate (mod, mod->debug.elf, false);
- }
- }
- }
-
- *loadbase = mod->main.bias;
- return mod->main.elf;
- }
-
- __libdwfl_seterrno (mod->elferr);
- return NULL;
-}
-INTDEF (dwfl_module_getelf)
-
-
Dwarf *
dwfl_module_getdwarf (Dwfl_Module *mod, Dwarf_Addr *bias)
{