diff options
author | Doug Kwan <dougkwan@google.com> | 2009-12-09 03:02:28 +0000 |
---|---|---|
committer | Doug Kwan <dougkwan@google.com> | 2009-12-09 03:02:28 +0000 |
commit | 4f7872716e8b73149e9024e1b95db6c3cfa66bd1 (patch) | |
tree | c33f338158eadac574de9434ef24c217bfb2cb08 /gold/dwarf_reader.cc | |
parent | 829da89821d7f0b7663b8314128fa06878d228e0 (diff) | |
download | gdb-4f7872716e8b73149e9024e1b95db6c3cfa66bd1.zip gdb-4f7872716e8b73149e9024e1b95db6c3cfa66bd1.tar.gz gdb-4f7872716e8b73149e9024e1b95db6c3cfa66bd1.tar.bz2 |
2009-12-08 Doug Kwan <dougkwan@google.com>
* Makefile.am (CCFILES): Add attributes.cc and int_encoding.cc.
(HFILES): Add attributes.h and int_encoding.h.
* Makefile.in: Regenerate.
* dwarf_reader.cc (read_unsigned_LEB_128, read_signed_LEB_128): Move
function definitions to int_encoding.cc
* dwarf_reader.h (read_unsigned_LEB_128, read_signed_LEB_128): Move
prototypes to int_encoding.h
* reduced_debug_output.cc (int_encoding.h): New include.
(write_unsigned_LEB_128, get_length_as_unsigned_LEB_128): Move
function definitions to int_encoding.cc
(insert_into_vector, read_from_pointer): Move template definitions to
int_encoding.h
* attributes.cc: New file.
* attributes.h: New file.
* int_encoding.cc: New file.
* int_encoding.h: New file.
Diffstat (limited to 'gold/dwarf_reader.cc')
-rw-r--r-- | gold/dwarf_reader.cc | 69 |
1 files changed, 1 insertions, 68 deletions
diff --git a/gold/dwarf_reader.cc b/gold/dwarf_reader.cc index d142586..4062fe6 100644 --- a/gold/dwarf_reader.cc +++ b/gold/dwarf_reader.cc @@ -31,77 +31,10 @@ #include "parameters.h" #include "reloc.h" #include "dwarf_reader.h" +#include "int_encoding.h" namespace gold { -// Read an unsigned LEB128 number. Each byte contains 7 bits of -// information, plus one bit saying whether the number continues or -// not. - -uint64_t -read_unsigned_LEB_128(const unsigned char* buffer, size_t* len) -{ - uint64_t result = 0; - size_t num_read = 0; - unsigned int shift = 0; - unsigned char byte; - - do - { - if (num_read >= 64 / 7) - { - gold_warning(_("Unusually large LEB128 decoded, " - "debug information may be corrupted")); - break; - } - byte = *buffer++; - num_read++; - result |= (static_cast<uint64_t>(byte & 0x7f)) << shift; - shift += 7; - } - while (byte & 0x80); - - *len = num_read; - - return result; -} - -// Read a signed LEB128 number. These are like regular LEB128 -// numbers, except the last byte may have a sign bit set. - -int64_t -read_signed_LEB_128(const unsigned char* buffer, size_t* len) -{ - int64_t result = 0; - int shift = 0; - size_t num_read = 0; - unsigned char byte; - - do - { - if (num_read >= 64 / 7) - { - gold_warning(_("Unusually large LEB128 decoded, " - "debug information may be corrupted")); - break; - } - byte = *buffer++; - num_read++; - result |= (static_cast<uint64_t>(byte & 0x7f) << shift); - shift += 7; - } - while (byte & 0x80); - - if ((shift < 8 * static_cast<int>(sizeof(result))) && (byte & 0x40)) - result |= -((static_cast<int64_t>(1)) << shift); - *len = num_read; - return result; -} - -// This is the format of a DWARF2/3 line state machine that we process -// opcodes using. There is no need for anything outside the lineinfo -// processor to know how this works. - struct LineStateMachine { int file_num; |