diff options
Diffstat (limited to 'libdwfl')
| -rw-r--r-- | libdwfl/ChangeLog | 16 | ||||
| -rw-r--r-- | libdwfl/dwfl_build_id_find_elf.c | 5 | ||||
| -rw-r--r-- | libdwfl/dwfl_module_getdwarf.c | 9 | ||||
| -rw-r--r-- | libdwfl/relocate.c | 28 |
4 files changed, 48 insertions, 10 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index f878c0d6..01a2537e 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,19 @@ +2008-02-19 Roland McGrath <[email protected]> + + * relocate.c (relocate_section): Check for an unhandled relocation + type before resolving a reloc's symbol. Lift DWFL_E_BADRELTYPE -> + DWFL_E_UNKNOWN_MACHINE check out of loops. + + * dwfl_module_getdwarf.c (load_dw): Skip relocation if + DEBUGFILE->relocated is already set. + +2008-01-26 Roland McGrath <[email protected]> + + * dwfl_module_getdwarf.c (open_elf): Open FILE->name if it's non-null. + + * dwfl_build_id_find_elf.c (__libdwfl_open_by_build_id): Don't clear + incoming *FILE_NAME at the start. + 2008-01-08 Roland McGrath <[email protected]> * Makefile.am (euinclude): Variable removed. diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c index c6215012..a6e38ce7 100644 --- a/libdwfl/dwfl_build_id_find_elf.c +++ b/libdwfl/dwfl_build_id_find_elf.c @@ -1,5 +1,5 @@ /* Find an ELF file for a module from its build ID. - Copyright (C) 2007 Red Hat, Inc. + Copyright (C) 2007, 2008 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -57,7 +57,8 @@ int internal_function __libdwfl_open_by_build_id (Dwfl_Module *mod, bool debug, char **file_name) { - *file_name = NULL; + /* If *FILE_NAME was primed into the module, leave it there + as the fallback when we have nothing to offer. */ errno = 0; if (mod->build_id_len <= 0) return -1; diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c index 775df731..7dd9b53f 100644 --- a/libdwfl/dwfl_module_getdwarf.c +++ b/libdwfl/dwfl_module_getdwarf.c @@ -1,5 +1,5 @@ /* Find debugging and symbol information for a module in libdwfl. - Copyright (C) 2005, 2006, 2007 Red Hat, Inc. + Copyright (C) 2005, 2006, 2007, 2008 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -61,6 +61,11 @@ open_elf (Dwfl_Module *mod, struct dwfl_file *file) { if (file->elf == NULL) { + /* 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) + file->fd = TEMP_FAILURE_RETRY (open64 (file->name, O_RDONLY)); + if (file->fd < 0) return CBFAIL; @@ -585,7 +590,7 @@ __libdwfl_module_getebl (Dwfl_Module *mod) static Dwfl_Error load_dw (Dwfl_Module *mod, struct dwfl_file *debugfile) { - if (mod->e_type == ET_REL) + if (mod->e_type == ET_REL && !debugfile->relocated) { const Dwfl_Callbacks *const cb = mod->dwfl->callbacks; diff --git a/libdwfl/relocate.c b/libdwfl/relocate.c index 6265f1bf..abacc041 100644 --- a/libdwfl/relocate.c +++ b/libdwfl/relocate.c @@ -1,5 +1,5 @@ /* Relocate debug information. - Copyright (C) 2005, 2006, 2007 Red Hat, Inc. + Copyright (C) 2005, 2006, 2007, 2008 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -306,6 +306,12 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr, Dwfl_Error relocate (GElf_Addr offset, const GElf_Sxword *addend, int rtype, int symndx) { + /* First see if this is a reloc we can handle. + If we are skipping it, don't bother resolving the symbol. */ + Elf_Type type = ebl_reloc_simple_type (mod->ebl, rtype); + if (unlikely (type == ELF_T_NUM)) + return DWFL_E_BADRELTYPE; + /* First, resolve the symbol to an absolute value. */ GElf_Addr value; @@ -342,7 +348,6 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr, DO_TYPE (WORD, Word); DO_TYPE (SWORD, Sword); \ DO_TYPE (XWORD, Xword); DO_TYPE (SXWORD, Sxword) size_t size; - Elf_Type type = ebl_reloc_simple_type (mod->ebl, rtype); switch (type) { #define DO_TYPE(NAME, Name) \ @@ -352,10 +357,6 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr, TYPES; #undef DO_TYPE default: - /* This might be because ebl_openbackend failed to find - any libebl_CPU.so library. Diagnose that clearly. */ - if (ebl_get_elfmachine (mod->ebl) == EM_NONE) - return DWFL_E_UNKNOWN_MACHINE; return DWFL_E_BADRELTYPE; } @@ -437,6 +438,19 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr, return DWFL_E_LIBELF; Dwfl_Error result = DWFL_E_NOERROR; + bool first_badreltype = true; + inline void check_badreltype (void) + { + if (first_badreltype) + { + first_badreltype = false; + if (ebl_get_elfmachine (mod->ebl) == EM_NONE) + /* This might be because ebl_openbackend failed to find + any libebl_CPU.so library. Diagnose that clearly. */ + result = DWFL_E_UNKNOWN_MACHINE; + } + } + size_t nrels = shdr->sh_size / shdr->sh_entsize; size_t complete = 0; if (shdr->sh_type == SHT_REL) @@ -448,6 +462,7 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr, result = relocate (r->r_offset, NULL, GELF_R_TYPE (r->r_info), GELF_R_SYM (r->r_info)); + check_badreltype (); if (partial) switch (result) { @@ -476,6 +491,7 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr, result = relocate (r->r_offset, &r->r_addend, GELF_R_TYPE (r->r_info), GELF_R_SYM (r->r_info)); + check_badreltype (); if (partial) switch (result) { |
