OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [gold/] [int_encoding.cc] - Diff between revs 27 and 166

Show entire file | Details | Blame | View Log

Rev 27 Rev 166
Line 30... Line 30...
 
 
namespace gold {
namespace gold {
 
 
// Read an unsigned LEB128 number.  Each byte contains 7 bits of
// Read an unsigned LEB128 number.  Each byte contains 7 bits of
// information, plus one bit saying whether the number continues or
// information, plus one bit saying whether the number continues or
// not.
// not.  BYTE contains the first byte of the number, and is guaranteed
 
// to have the continuation bit set.
 
 
uint64_t
uint64_t
read_unsigned_LEB_128(const unsigned char* buffer, size_t* len)
read_unsigned_LEB_128_x(const unsigned char* buffer, size_t* len,
 
                        unsigned char byte)
{
{
  uint64_t result = 0;
  uint64_t result = static_cast<uint64_t>(byte & 0x7f);
  size_t num_read = 0;
  size_t num_read = 1;
  unsigned int shift = 0;
  unsigned int shift = 7;
  unsigned char byte;
 
 
 
  do
  do
    {
    {
      if (num_read >= 64 / 7)
      if (num_read > 64 / 7 + 1)
        {
        {
          gold_warning(_("Unusually large LEB128 decoded, "
          gold_warning(_("Unusually large LEB128 decoded, "
                         "debug information may be corrupted"));
                         "debug information may be corrupted"));
          break;
          break;
        }
        }
Line 62... Line 63...
  return result;
  return result;
}
}
 
 
// Read a signed LEB128 number.  These are like regular LEB128
// Read a signed LEB128 number.  These are like regular LEB128
// numbers, except the last byte may have a sign bit set.
// numbers, except the last byte may have a sign bit set.
 
// BYTE contains the first byte of the number, and is guaranteed
 
// to have the continuation bit set.
 
 
int64_t
int64_t
read_signed_LEB_128(const unsigned char* buffer, size_t* len)
read_signed_LEB_128_x(const unsigned char* buffer, size_t* len,
 
                      unsigned char byte)
{
{
  int64_t result = 0;
  int64_t result = static_cast<uint64_t>(byte & 0x7f);
  int shift = 0;
  int shift = 7;
  size_t num_read = 0;
  size_t num_read = 1;
  unsigned char byte;
 
 
 
  do
  do
    {
    {
      if (num_read >= 64 / 7)
      if (num_read > 64 / 7 + 1)
        {
        {
          gold_warning(_("Unusually large LEB128 decoded, "
          gold_warning(_("Unusually large LEB128 decoded, "
                         "debug information may be corrupted"));
                         "debug information may be corrupted"));
          break;
          break;
        }
        }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.