Hi,
jankratochvil/move
it just moves the code with no hidden changes so that one can see the real changes in the next patch.
Jan
commit 93c1d85d2ca8f3e1870c03d6e6a2dcc516fa73aa Author: Jan Kratochvil jan.kratochvil@redhat.com Date: Fri Apr 26 17:35:33 2013 +0200
Move code around, not to be checked-in on its own.
Signed-off-by: Jan Kratochvil jan.kratochvil@redhat.com
diff --git a/libdwfl/core-file.c b/libdwfl/core-file.c index 1545ca8..ac2aa8c 100644 --- a/libdwfl/core-file.c +++ b/libdwfl/core-file.c @@ -397,26 +397,6 @@ dwfl_core_file_report (Dwfl *dwfl, Elf *elf) if (unlikely (ndx <= 0)) return ndx;
- /* Now sniff segment contents for modules. */ - int sniffed = 0; - ndx = 0; - do - { - int seg = dwfl_segment_report_module (dwfl, ndx, NULL, - &dwfl_elf_phdr_memory_callback, elf, - core_file_read_eagerly, elf); - if (unlikely (seg < 0)) - return seg; - if (seg > ndx) - { - ndx = seg; - ++sniffed; - } - else - ++ndx; - } - while (ndx < (int) phnum); - /* Next, we should follow the chain from DT_DEBUG. */
const void *auxv = NULL; @@ -454,6 +434,26 @@ dwfl_core_file_report (Dwfl *dwfl, Elf *elf) int listed = dwfl_link_map_report (dwfl, auxv, auxv_size, dwfl_elf_phdr_memory_callback, elf);
+ /* Now sniff segment contents for modules. */ + int sniffed = 0; + ndx = 0; + do + { + int seg = dwfl_segment_report_module (dwfl, ndx, NULL, + &dwfl_elf_phdr_memory_callback, elf, + core_file_read_eagerly, elf); + if (unlikely (seg < 0)) + return seg; + if (seg > ndx) + { + ndx = seg; + ++sniffed; + } + else + ++ndx; + } + while (ndx < (int) phnum); + /* We return the number of modules we found if we found any. If we found none, we return -1 instead of 0 if there was an error rather than just nothing found. If link_map handling diff --git a/libdwfl/dwfl_module_build_id.c b/libdwfl/dwfl_module_build_id.c index 660c733..98cb9f4 100644 --- a/libdwfl/dwfl_module_build_id.c +++ b/libdwfl/dwfl_module_build_id.c @@ -54,28 +54,28 @@ found_build_id (Dwfl_Module *mod, bool set,
#define NO_VADDR ((GElf_Addr) -1l)
-static int -check_notes (Dwfl_Module *mod, bool set, Elf_Data *data, GElf_Addr data_vaddr) -{ - size_t pos = 0; - GElf_Nhdr nhdr; - size_t name_pos; - size_t desc_pos; - while ((pos = gelf_getnote (data, pos, &nhdr, &name_pos, &desc_pos)) > 0) - if (nhdr.n_type == NT_GNU_BUILD_ID - && nhdr.n_namesz == sizeof "GNU" && !memcmp (data->d_buf + name_pos, - "GNU", sizeof "GNU")) - return found_build_id (mod, set, - data->d_buf + desc_pos, nhdr.n_descsz, - data_vaddr == NO_VADDR ? 0 - : data_vaddr + desc_pos); - return 0; -} - int internal_function __libdwfl_find_build_id (Dwfl_Module *mod, bool set, Elf *elf) { + int + check_notes (Dwfl_Module *mod, bool set, Elf_Data *data, GElf_Addr data_vaddr) + { + size_t pos = 0; + GElf_Nhdr nhdr; + size_t name_pos; + size_t desc_pos; + while ((pos = gelf_getnote (data, pos, &nhdr, &name_pos, &desc_pos)) > 0) + if (nhdr.n_type == NT_GNU_BUILD_ID + && nhdr.n_namesz == sizeof "GNU" && !memcmp (data->d_buf + name_pos, + "GNU", sizeof "GNU")) + return found_build_id (mod, set, + data->d_buf + desc_pos, nhdr.n_descsz, + data_vaddr == NO_VADDR ? 0 + : data_vaddr + desc_pos); + return 0; + } + size_t shstrndx = SHN_UNDEF; int result = 0;
diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c index 19f92df..c79a2bf 100644 --- a/libdwfl/link_map.c +++ b/libdwfl/link_map.c @@ -348,43 +348,12 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata, if (name != NULL && name[0] == '\0') name = NULL;
- /* If content-sniffing already reported a module covering - the same area, find that existing module to adjust. - The l_ld address is the only one we know for sure - to be within the module's own segments (its .dynamic). */ - Dwfl_Module *mod = INTUSE(dwfl_addrmodule) (dwfl, l_ld); - if (mod != NULL) - { - /* We have a module. We can give it a better name from l_name. */ - if (name != NULL && mod->name[0] == '[') - { - char *newname = strdup (basename (name)); - if (newname != NULL) - { - free (mod->name); - mod->name = newname; - } - } + /* We have to find the file's phdrs to compute along with l_addr + what its runtime address boundaries are. */
- if (name == NULL && mod->name[0] == '/') - name = mod->name; - - /* If we don't have a file for it already, we can pre-install - the full file name from l_name. Opening the file by this - name will be the fallback when no build ID match is found. - XXX hook for sysroot */ - if (name != NULL && mod->main.name == NULL) - mod->main.name = strdup (name); - } - else if (name != NULL) - { - /* We have to find the file's phdrs to compute along with l_addr - what its runtime address boundaries are. */ - - // XXX hook for sysroot - mod = INTUSE(dwfl_report_elf) (dwfl, basename (name), - name, -1, l_addr); - } + // XXX hook for sysroot + mod = INTUSE(dwfl_report_elf) (dwfl, basename (name), + name, -1, l_addr);
if (mod != NULL) {
elfutils-devel@lists.fedorahosted.org