]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Rename read_ubyte_unaligned_inc to read_addr_unaligned_inc
authorPetr Machata <pmachata@redhat.com>
Fri, 12 Sep 2014 17:03:33 +0000 (19:03 +0200)
committerPetr Machata <pmachata@redhat.com>
Fri, 12 Sep 2014 17:55:53 +0000 (19:55 +0200)
- The behavior of this function has been changed to read only
  address-sized quantities, i.e. the size of 2 is no longer allowed.
  (Size of 1 never was.)  The two outstanding uses, both in readelf.c,
  which actually do use this call to read address-sized units, were
  updated, rejecting fields that indicate weird address sizes.

- The three related calls, read_sbyte_unaligned_inc,
  read_ubyte_unaligned and read_sbyte_unaligned were dropped.  There
  are currently no uses for these calls.

Signed-off-by: Petr Machata <pmachata@redhat.com>
libdw/ChangeLog
libdw/memory-access.h
src/ChangeLog
src/readelf.c

index cc44004eb7d9865ec981d3a74335a96631c170de..410b31ab0709fefe877d4e8113674a6e52bc8545 100644 (file)
@@ -1,3 +1,11 @@
+2014-09-12  Petr Machata  <pmachata@redhat.com>
+
+       * memory-access.h (read_ubyte_unaligned_inc): Allow only 4- and
+       8-byte quantities.  Consequently, rename to...
+       (read_addr_unaligned_inc): ... this.
+       (read_sbyte_unaligned_inc, read_ubyte_unaligned): Drop.
+       (read_sbyte_unaligned): Drop.
+
 2014-09-10  Petr Machata  <pmachata@redhat.com>
 
        * dwarf_getlocation.c (attr_ok): Also accept
index f41f783ddea2aa50993304b346dc5826f386f508..6a4ce885e1b2f931f68bc2ea1e6f3af8962a8a8a 100644 (file)
@@ -219,17 +219,6 @@ read_8sbyte_unaligned_1 (bool other_byte_order, const void *p)
 #endif /* allow unaligned */
 
 
-#define read_ubyte_unaligned(Nbytes, Dbg, Addr) \
-  ((Nbytes) == 2 ? read_2ubyte_unaligned (Dbg, Addr)                         \
-   : (Nbytes) == 4 ? read_4ubyte_unaligned (Dbg, Addr)                       \
-   : read_8ubyte_unaligned (Dbg, Addr))
-
-#define read_sbyte_unaligned(Nbytes, Dbg, Addr) \
-  ((Nbytes) == 2 ? read_2sbyte_unaligned (Dbg, Addr)                         \
-   : (Nbytes) == 4 ? read_4sbyte_unaligned (Dbg, Addr)                       \
-   : read_8sbyte_unaligned (Dbg, Addr))
-
-
 #define read_2ubyte_unaligned_inc(Dbg, Addr) \
   ({ uint16_t t_ = read_2ubyte_unaligned (Dbg, Addr);                        \
      Addr = (__typeof (Addr)) (((uintptr_t) (Addr)) + 2);                    \
@@ -258,14 +247,9 @@ read_8sbyte_unaligned_1 (bool other_byte_order, const void *p)
      t_; })
 
 
-#define read_ubyte_unaligned_inc(Nbytes, Dbg, Addr) \
-  ((Nbytes) == 2 ? read_2ubyte_unaligned_inc (Dbg, Addr)                     \
-   : (Nbytes) == 4 ? read_4ubyte_unaligned_inc (Dbg, Addr)                   \
-   : read_8ubyte_unaligned_inc (Dbg, Addr))
-
-#define read_sbyte_unaligned_inc(Nbytes, Dbg, Addr) \
-  ((Nbytes) == 2 ? read_2sbyte_unaligned_inc (Dbg, Addr)                     \
-   : (Nbytes) == 4 ? read_4sbyte_unaligned_inc (Dbg, Addr)                   \
-   : read_8sbyte_unaligned_inc (Dbg, Addr))
+#define read_addr_unaligned_inc(Nbytes, Dbg, Addr)                     \
+  (assert ((Nbytes) == 4 || (Nbytes) == 8),                            \
+    ((Nbytes) == 4 ? read_4ubyte_unaligned_inc (Dbg, Addr)             \
+     : read_8ubyte_unaligned_inc (Dbg, Addr)))
 
 #endif /* memory-access.h */
index 986b3417718089dc4e90eb7b51e8468dd129d409..aa986080ccf63665c47e0ba1e4508d7038fe64c6 100644 (file)
@@ -1,3 +1,9 @@
+2014-09-12  Petr Machata  <pmachata@redhat.com>
+
+       * readelf.c (encoded_ptr_size): In the switch statement, change
+       magic constants 3 and 4 to DW_EH_PE_* counterparts.  Still accept
+       0.  Print diagnostic for anything else.
+
 2014-08-25  Josh Stone  <jistone@redhat.com>
 
        * Makefile.am: Prevent premature @AR@ replacement in a sed expression.
index 6bbe436d3021ebe03781f21dbfed137701fe321e..7b43a658601801d4de98a5c9ebc311cde700c2f5 100644 (file)
@@ -5026,15 +5026,17 @@ encoded_ptr_size (int encoding, unsigned int ptr_size)
 {
   switch (encoding & 7)
     {
-    case 2:
-      return 2;
-    case 3:
+    case DW_EH_PE_udata4:
       return 4;
-    case 4:
+    case DW_EH_PE_udata8:
       return 8;
-    default:
+    case 0:
       return ptr_size;
     }
+
+  fprintf (stderr, "Unsupported pointer encoding: %#x, "
+          "assuming pointer size of %d.\n", encoding, ptr_size);
+  return ptr_size;
 }
 
 
@@ -5455,9 +5457,9 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
 
          const unsigned char *base = readp;
          // XXX There are sometimes relocations for this value
-         initial_location = read_ubyte_unaligned_inc (ptr_size, dbg, readp);
+         initial_location = read_addr_unaligned_inc (ptr_size, dbg, readp);
          Dwarf_Word address_range
-           = read_ubyte_unaligned_inc (ptr_size, dbg, readp);
+           = read_addr_unaligned_inc (ptr_size, dbg, readp);
 
          /* pcrel for an FDE address is relative to the runtime
             address of the start_address field itself.  Sign extend