diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2013-11-13 19:58:06 +0100 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2013-11-13 19:58:06 +0100 |
commit | 5dca2b62db78163535aa5c7ee5fbda32f1087d6f (patch) | |
tree | 58f112aef40ff08ce8c088e45706cafde9e1769a | |
parent | 875cad8234a6fcbbe90686d10f135ad029ff8206 (diff) | |
download | elfutils-5dca2b62db78163535aa5c7ee5fbda32f1087d6f.tar.gz |
Fix dwfl_module_addrsym for minidebuginfo
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
-rw-r--r-- | libdwfl/ChangeLog | 9 | ||||
-rw-r--r-- | libdwfl/dwfl_module_addrsym.c | 26 |
2 files changed, 28 insertions, 7 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 467b4869..282f0112 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,12 @@ +2013-11-13 Jan Kratochvil <jan.kratochvil@redhat.com> + + Fix dwfl_module_addrsym for minidebuginfo. + * dwfl_module_addrsym.c (dwfl_module_addrsym): New variable + addr_symfile. + (dwfl_module_addrsym) (same_section): Use it. + (dwfl_module_addrsym) (i_to_symfile): New function. + (dwfl_module_addrsym) (search_table): Use it. + 2013-11-07 Jan Kratochvil <jan.kratochvil@redhat.com> Mark Wielaard <mjw@redhat.com> diff --git a/libdwfl/dwfl_module_addrsym.c b/libdwfl/dwfl_module_addrsym.c index 732b6983..3d199437 100644 --- a/libdwfl/dwfl_module_addrsym.c +++ b/libdwfl/dwfl_module_addrsym.c @@ -41,6 +41,7 @@ dwfl_module_addrsym (Dwfl_Module *mod, GElf_Addr addr, /* Return true iff we consider ADDR to lie in the same section as SYM. */ GElf_Word addr_shndx = SHN_UNDEF; + struct dwfl_file *addr_symfile = NULL; inline bool same_section (const GElf_Sym *sym, struct dwfl_file *symfile, GElf_Word shndx) { @@ -49,11 +50,12 @@ dwfl_module_addrsym (Dwfl_Module *mod, GElf_Addr addr, return sym->st_value == addr; /* Figure out what section ADDR lies in. */ - if (addr_shndx == SHN_UNDEF) + if (addr_shndx == SHN_UNDEF || addr_symfile != symfile) { GElf_Addr mod_addr = dwfl_deadjust_st_value (mod, symfile, addr); Elf_Scn *scn = NULL; addr_shndx = SHN_ABS; + addr_symfile = symfile; while ((scn = elf_nextscn (symfile->elf, scn)) != NULL) { GElf_Shdr shdr_mem; @@ -68,7 +70,7 @@ dwfl_module_addrsym (Dwfl_Module *mod, GElf_Addr addr, } } - return shndx == addr_shndx; + return shndx == addr_shndx && addr_symfile == symfile; } /* Keep track of the closest symbol we have seen so far. @@ -84,6 +86,20 @@ 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) { @@ -136,11 +152,7 @@ dwfl_module_addrsym (Dwfl_Module *mod, GElf_Addr addr, } else if (closest_name == NULL && sym.st_value >= min_label - && same_section (&sym, - ((size_t) i < mod->syments - ? mod->symfile - : &mod->aux_sym), - shndx)) + && same_section (&sym, i_to_symfile (i), shndx)) { /* Handwritten assembly symbols sometimes have no st_size. If no symbol with proper size includes |