diff options
author | Cary Coutant <ccoutant@google.com> | 2013-05-15 16:36:38 +0000 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2013-05-15 16:36:38 +0000 |
commit | 87bc83b328c32e82623df4c7689304c277106a3e (patch) | |
tree | b1b0463d19c323acd605597f68bf1d09ad4b3aba /binutils/elfcomm.c | |
parent | af880d85b8ba82c4cd3bfc987df6f8ae85ebb917 (diff) | |
download | binutils-gdb-87bc83b328c32e82623df4c7689304c277106a3e.tar.gz |
binutils/
* dwarf.c (SAFE_BYTE_GET64): Correct end-of-buffer check;
don't increment PTR.
(decode_location_expression): DW_OP_const2u should read 2 bytes.
(display_debug_lines_decoded): Adjust formatting.
* elfcomm.c (byte_get_little_endian): Add cases for 5-, 6-, and
7-byte reads.
(byte_get_big_endian): Likewise.
(byte_get_signed): Likewise.
Diffstat (limited to 'binutils/elfcomm.c')
-rw-r--r-- | binutils/elfcomm.c | 119 |
1 files changed, 118 insertions, 1 deletions
diff --git a/binutils/elfcomm.c b/binutils/elfcomm.c index 1a1fae98b99..d5b4313880d 100644 --- a/binutils/elfcomm.c +++ b/binutils/elfcomm.c @@ -150,6 +150,57 @@ byte_get_little_endian (unsigned char *field, int size) | (((unsigned long) (field[2])) << 16) | (((unsigned long) (field[3])) << 24); + case 5: + if (sizeof (elf_vma) == 8) + return ((elf_vma) (field[0])) + | (((elf_vma) (field[1])) << 8) + | (((elf_vma) (field[2])) << 16) + | (((elf_vma) (field[3])) << 24) + | (((elf_vma) (field[4])) << 32); + else if (sizeof (elf_vma) == 4) + /* We want to extract data from an 8 byte wide field and + place it into a 4 byte wide field. Since this is a little + endian source we can just use the 4 byte extraction code. */ + return ((unsigned long) (field[0])) + | (((unsigned long) (field[1])) << 8) + | (((unsigned long) (field[2])) << 16) + | (((unsigned long) (field[3])) << 24); + + case 6: + if (sizeof (elf_vma) == 8) + return ((elf_vma) (field[0])) + | (((elf_vma) (field[1])) << 8) + | (((elf_vma) (field[2])) << 16) + | (((elf_vma) (field[3])) << 24) + | (((elf_vma) (field[4])) << 32) + | (((elf_vma) (field[5])) << 40); + else if (sizeof (elf_vma) == 4) + /* We want to extract data from an 8 byte wide field and + place it into a 4 byte wide field. Since this is a little + endian source we can just use the 4 byte extraction code. */ + return ((unsigned long) (field[0])) + | (((unsigned long) (field[1])) << 8) + | (((unsigned long) (field[2])) << 16) + | (((unsigned long) (field[3])) << 24); + + case 7: + if (sizeof (elf_vma) == 8) + return ((elf_vma) (field[0])) + | (((elf_vma) (field[1])) << 8) + | (((elf_vma) (field[2])) << 16) + | (((elf_vma) (field[3])) << 24) + | (((elf_vma) (field[4])) << 32) + | (((elf_vma) (field[5])) << 40) + | (((elf_vma) (field[6])) << 48); + else if (sizeof (elf_vma) == 4) + /* We want to extract data from an 8 byte wide field and + place it into a 4 byte wide field. Since this is a little + endian source we can just use the 4 byte extraction code. */ + return ((unsigned long) (field[0])) + | (((unsigned long) (field[1])) << 8) + | (((unsigned long) (field[2])) << 16) + | (((unsigned long) (field[3])) << 24); + case 8: if (sizeof (elf_vma) == 8) return ((elf_vma) (field[0])) @@ -197,6 +248,63 @@ byte_get_big_endian (unsigned char *field, int size) | (((unsigned long) (field[1])) << 16) | (((unsigned long) (field[0])) << 24); + case 5: + if (sizeof (elf_vma) == 8) + return ((elf_vma) (field[4])) + | (((elf_vma) (field[3])) << 8) + | (((elf_vma) (field[2])) << 16) + | (((elf_vma) (field[1])) << 24) + | (((elf_vma) (field[0])) << 32); + else if (sizeof (elf_vma) == 4) + { + /* Although we are extracting data from an 8 byte wide field, + we are returning only 4 bytes of data. */ + field += 1; + return ((unsigned long) (field[3])) + | (((unsigned long) (field[2])) << 8) + | (((unsigned long) (field[1])) << 16) + | (((unsigned long) (field[0])) << 24); + } + + case 6: + if (sizeof (elf_vma) == 8) + return ((elf_vma) (field[5])) + | (((elf_vma) (field[4])) << 8) + | (((elf_vma) (field[3])) << 16) + | (((elf_vma) (field[2])) << 24) + | (((elf_vma) (field[1])) << 32) + | (((elf_vma) (field[0])) << 40); + else if (sizeof (elf_vma) == 4) + { + /* Although we are extracting data from an 8 byte wide field, + we are returning only 4 bytes of data. */ + field += 2; + return ((unsigned long) (field[3])) + | (((unsigned long) (field[2])) << 8) + | (((unsigned long) (field[1])) << 16) + | (((unsigned long) (field[0])) << 24); + } + + case 7: + if (sizeof (elf_vma) == 8) + return ((elf_vma) (field[6])) + | (((elf_vma) (field[5])) << 8) + | (((elf_vma) (field[4])) << 16) + | (((elf_vma) (field[3])) << 24) + | (((elf_vma) (field[2])) << 32) + | (((elf_vma) (field[1])) << 40) + | (((elf_vma) (field[0])) << 48); + else if (sizeof (elf_vma) == 4) + { + /* Although we are extracting data from an 8 byte wide field, + we are returning only 4 bytes of data. */ + field += 3; + return ((unsigned long) (field[3])) + | (((unsigned long) (field[2])) << 8) + | (((unsigned long) (field[1])) << 16) + | (((unsigned long) (field[0])) << 24); + } + case 8: if (sizeof (elf_vma) == 8) return ((elf_vma) (field[7])) @@ -209,7 +317,7 @@ byte_get_big_endian (unsigned char *field, int size) | (((elf_vma) (field[0])) << 56); else if (sizeof (elf_vma) == 4) { - /* Although we are extracing data from an 8 byte wide field, + /* Although we are extracting data from an 8 byte wide field, we are returning only 4 bytes of data. */ field += 4; return ((unsigned long) (field[3])) @@ -235,9 +343,18 @@ byte_get_signed (unsigned char *field, int size) return (x ^ 0x80) - 0x80; case 2: return (x ^ 0x8000) - 0x8000; + case 3: + return (x ^ 0x800000) - 0x800000; case 4: return (x ^ 0x80000000) - 0x80000000; + case 5: + case 6: + case 7: case 8: + /* Reads of 5-, 6-, and 7-byte numbers are the result of + trying to read past the end of a buffer, and will therefore + not have meaningful values, so we don't try to deal with + the sign in these cases. */ return x; default: abort (); |