diff options
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; |