From: Petr Machata Date: Fri, 12 Sep 2014 17:03:33 +0000 (+0200) Subject: Rename read_ubyte_unaligned_inc to read_addr_unaligned_inc X-Git-Tag: elfutils-0.161~110 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1498f541290f072ade0b783c298c358e9da74937;p=thirdparty%2Felfutils.git Rename read_ubyte_unaligned_inc to read_addr_unaligned_inc - 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 --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index cc44004eb..410b31ab0 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,11 @@ +2014-09-12 Petr Machata + + * 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 * dwarf_getlocation.c (attr_ok): Also accept diff --git a/libdw/memory-access.h b/libdw/memory-access.h index f41f783dd..6a4ce885e 100644 --- a/libdw/memory-access.h +++ b/libdw/memory-access.h @@ -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 */ diff --git a/src/ChangeLog b/src/ChangeLog index 986b34177..aa986080c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2014-09-12 Petr Machata + + * 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 * Makefile.am: Prevent premature @AR@ replacement in a sed expression. diff --git a/src/readelf.c b/src/readelf.c index 6bbe436d3..7b43a6586 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -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