]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
segment_start segment_end
authorJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 12 Nov 2012 20:36:00 +0000 (21:36 +0100)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 12 Nov 2012 20:36:00 +0000 (21:36 +0100)
libdwfl/dwfl_frame_state_core.c
libdwfl/libdwflP.h
libdwfl/segment.c

index ca4eb934a935f81c0660c874b7397909ceb3e0d9..4ffd099a6f56b19210eb6230e0c7740f5179fe55 100644 (file)
 # 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;
index 5b24392022ee7b04cc9a38e557175eac8a29e7f6..ebcdae548a8d809bc24109e16faee8c3631ee7f1 100644 (file)
@@ -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,
index 496b4fdce1c640384a82f0c69c19deaa74a30cfc..3a2f3497f58fcc7f872605419fdfafe54f06211d 100644 (file)
 
 #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