From: Jan Kratochvil Date: Mon, 12 Nov 2012 20:36:00 +0000 (+0100) Subject: segment_start segment_end X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5e1a0338e691194bd902d39fb59e18d44f423aa3;p=thirdparty%2Felfutils.git segment_start segment_end --- diff --git a/libdwfl/dwfl_frame_state_core.c b/libdwfl/dwfl_frame_state_core.c index ca4eb934a..4ffd099a6 100644 --- a/libdwfl/dwfl_frame_state_core.c +++ b/libdwfl/dwfl_frame_state_core.c @@ -34,26 +34,6 @@ # define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif -/* Exact copy from libdwfl/segment.c. */ - -static GElf_Addr -segment_start (Dwfl *dwfl, GElf_Addr start) -{ - if (dwfl->segment_align > 1) - start &= -dwfl->segment_align; - return start; -} - -/* Exact copy from libdwfl/segment.c. */ - -static GElf_Addr -segment_end (Dwfl *dwfl, GElf_Addr end) -{ - if (dwfl->segment_align > 1) - end = (end + dwfl->segment_align - 1) & -dwfl->segment_align; - return end; -} - static bool dwfl_frame_state_core_memory_read (Dwarf_Addr addr, Dwarf_Addr *result, void *user_data) @@ -74,8 +54,9 @@ dwfl_frame_state_core_memory_read (Dwarf_Addr addr, Dwarf_Addr *result, if (phdr == NULL || phdr->p_type != PT_LOAD) continue; /* Bias is zero here, a core file itself has no bias. */ - GElf_Addr start = segment_start (dwfl, phdr->p_vaddr); - GElf_Addr end = segment_end (dwfl, phdr->p_vaddr + phdr->p_memsz); + GElf_Addr start = __libdwfl_segment_start (dwfl, phdr->p_vaddr); + GElf_Addr end = __libdwfl_segment_end (dwfl, + phdr->p_vaddr + phdr->p_memsz); unsigned bytes = process->ebl->class == ELFCLASS64 ? 8 : 4; if (addr < start || addr + bytes > end) continue; diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h index 5b2439202..ebcdae548 100644 --- a/libdwfl/libdwflP.h +++ b/libdwfl/libdwflP.h @@ -498,6 +498,10 @@ extern Dwfl_Frame_State_Process * void *memory_read_user_data) internal_function; +/* Align segment START downwards or END upwards addresses according to DWFL. */ +extern GElf_Addr __libdwfl_segment_start (Dwfl *dwfl, GElf_Addr start); +extern GElf_Addr __libdwfl_segment_end (Dwfl *dwfl, GElf_Addr end); + /* Decompression wrappers: decompress whole file into memory. */ extern Dwfl_Error __libdw_gunzip (int fd, off64_t start_offset, void *mapped, size_t mapped_size, diff --git a/libdwfl/segment.c b/libdwfl/segment.c index 496b4fdce..3a2f3497f 100644 --- a/libdwfl/segment.c +++ b/libdwfl/segment.c @@ -28,16 +28,18 @@ #include "libdwflP.h" -static GElf_Addr -segment_start (Dwfl *dwfl, GElf_Addr start) +GElf_Addr +internal_function +__libdwfl_segment_start (Dwfl *dwfl, GElf_Addr start) { if (dwfl->segment_align > 1) start &= -dwfl->segment_align; return start; } -static GElf_Addr -segment_end (Dwfl *dwfl, GElf_Addr end) +GElf_Addr +internal_function +__libdwfl_segment_end (Dwfl *dwfl, GElf_Addr end) { if (dwfl->segment_align > 1) end = (end + dwfl->segment_align - 1) & -dwfl->segment_align; @@ -156,8 +158,8 @@ reify_segments (Dwfl *dwfl) for (Dwfl_Module *mod = dwfl->modulelist; mod != NULL; mod = mod->next) if (! mod->gc) { - const GElf_Addr start = segment_start (dwfl, mod->low_addr); - const GElf_Addr end = segment_end (dwfl, mod->high_addr); + const GElf_Addr start = __libdwfl_segment_start (dwfl, mod->low_addr); + const GElf_Addr end = __libdwfl_segment_end (dwfl, mod->high_addr); bool resized = false; int idx = lookup (dwfl, start, hint); @@ -296,8 +298,9 @@ dwfl_report_segment (Dwfl *dwfl, int ndx, const GElf_Phdr *phdr, GElf_Addr bias, dwfl->lookup_module = NULL; } - GElf_Addr start = segment_start (dwfl, bias + phdr->p_vaddr); - GElf_Addr end = segment_end (dwfl, bias + phdr->p_vaddr + phdr->p_memsz); + GElf_Addr start = __libdwfl_segment_start (dwfl, bias + phdr->p_vaddr); + GElf_Addr end = __libdwfl_segment_end (dwfl, + bias + phdr->p_vaddr + phdr->p_memsz); /* Coalesce into the last one if contiguous and matching. */ if (ndx != dwfl->lookup_tail_ndx