Update Gnulib to the latest git version
[deliverable/binutils-gdb.git] / gold / reduced_debug_output.cc
index d195cfdd40d6aefe6b72ef15565cc9f0722b21fb..30c475666f31c5dda2bb1758d41c5fbdcae73564 100644 (file)
@@ -1,6 +1,6 @@
 // reduced_debug_output.cc -- output reduced debugging information to save space
 
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright (C) 2008-2019 Free Software Foundation, Inc.
 // Written by Caleb Howe <cshowe@google.com>.
 
 // This file is part of gold.
 #include "dwarf.h"
 #include "dwarf_reader.h"
 #include "reduced_debug_output.h"
+#include "int_encoding.h"
 
 #include <vector>
 
 namespace gold
 {
 
-void
-write_unsigned_LEB_128(std::vector<unsigned char>* buffer, uint64_t value)
-{
-  do
-    {
-      unsigned char current_byte = value & 0x7f;
-      value >>= 7;
-      if (value != 0)
-        {
-          current_byte |= 0x80;
-        }
-      buffer->push_back(current_byte);
-    }
-  while (value != 0);
-}
-
-size_t
-get_length_as_unsigned_LEB_128(uint64_t value)
-{
-  size_t length = 0;
-  do
-    {
-      unsigned char current_byte = value & 0x7f;
-      value >>= 7;
-      if (value != 0)
-        {
-          current_byte |= 0x80;
-        }
-      length++;
-    }
-  while (value != 0);
-  return length;
-}
-
-template <int valsize>
-void Insert_into_vector(std::vector<unsigned char>* destination,
-                        typename elfcpp::Valtype_base<valsize>::Valtype value)
-{
-  union
-    {
-      unsigned char buffer[valsize / 8];
-      long long align;
-    } u;
-  if (parameters->target().is_big_endian())
-    elfcpp::Swap<valsize, true>::writeval(u.buffer, value);
-  else
-    elfcpp::Swap<valsize, false>::writeval(u.buffer, value);
-  destination->insert(destination->end(), u.buffer, u.buffer + valsize / 8);
-}
-
-template <int valsize>
-typename elfcpp::Valtype_base<valsize>::Valtype
-read_from_pointer(unsigned char** source)
-{
-  typename elfcpp::Valtype_base<valsize>::Valtype return_value;
-  if (parameters->target().is_big_endian())
-    return_value = elfcpp::Swap_unaligned<valsize, true>::readval(*source);
-  else
-    return_value = elfcpp::Swap_unaligned<valsize, false>::readval(*source);
-  *source += valsize / 8;
-  return return_value;
-}
-
 // Given a pointer to the beginning of a die and the beginning of the associated
 // abbreviation fills in die_end with the end of the information entry.  If
 // successful returns true.  Get_die_end also takes a pointer to the end of the
@@ -122,9 +60,10 @@ Output_reduced_debug_info_section::get_die_end(
         return false;
       switch(form)
         {
-          case elfcpp::DW_FORM_null:
+          case elfcpp::DW_FORM_flag_present:
             break;
           case elfcpp::DW_FORM_strp:
+          case elfcpp::DW_FORM_sec_offset:
             die += is64 ? 8 : 4;
             break;
           case elfcpp::DW_FORM_addr:
@@ -150,6 +89,7 @@ Output_reduced_debug_info_section::get_die_end(
               break;
             }
           case elfcpp::DW_FORM_block:
+          case elfcpp::DW_FORM_exprloc:
             LEB_decoded = read_unsigned_LEB_128(die, &LEB_size);
             die += (LEB_decoded + LEB_size);
             break;
@@ -168,6 +108,7 @@ Output_reduced_debug_info_section::get_die_end(
             break;
           case elfcpp::DW_FORM_data8:
           case elfcpp::DW_FORM_ref8:
+          case elfcpp::DW_FORM_ref_sig8:
             die += 8;
             break;
           case elfcpp::DW_FORM_ref_udata:
@@ -175,14 +116,20 @@ Output_reduced_debug_info_section::get_die_end(
             read_unsigned_LEB_128(die, &LEB_size);
             die += LEB_size;
             break;
+          case elfcpp::DW_FORM_sdata:
+            read_signed_LEB_128(die, &LEB_size);
+            die += LEB_size;
+            break;
           case elfcpp::DW_FORM_string:
             {
               size_t length = strlen(reinterpret_cast<char*>(die));
               die += length + 1;
               break;
             }
-          case elfcpp::DW_FORM_sdata:
           case elfcpp::DW_FORM_indirect:
+          case elfcpp::DW_FORM_GNU_addr_index:
+          case elfcpp::DW_FORM_GNU_str_index:
+          default:
             return false;
       }
     }
@@ -216,20 +163,20 @@ Output_reduced_debug_abbrev_section::set_final_data_size()
           abbrev_data += LEB_size;
 
           // Together with the abbreviation number these fields make up
-          // the header for each abbreviation
+          // the header for each abbreviation.
           uint64_t abbrev_type = read_unsigned_LEB_128(abbrev_data, &LEB_size);
           abbrev_data += LEB_size;
 
           // This would ordinarily be the has_children field of the
-          // abbreviation.  But it's going to be false after reducting the
-          // information, so there's no point in storing it
+          // abbreviation.  But it's going to be false after reducing the
+          // information, so there's no point in storing it.
           abbrev_data++;
 
-          // Read to the end of the current abbreviation
+          // Read to the end of the current abbreviation.
           // This is indicated by two zero unsigned LEBs in a row.  We don't
           // need to parse the data yet, so we just scan through the data
           // looking for two consecutive 0 bytes indicating the end of the
-          // abbreviation
+          // abbreviation.
           unsigned char* current_abbrev;
           for (current_abbrev = abbrev_data;
                current_abbrev[0] || current_abbrev[1];
@@ -356,15 +303,15 @@ void Output_reduced_debug_info_section::set_final_data_size()
               return;
             }
 
-          Insert_into_vector<32>(&this->data_, 0xFFFFFFFF);
-          Insert_into_vector<32>(&this->data_, 0);
-          Insert_into_vector<64>(
+          insert_into_vector<32>(&this->data_, 0xFFFFFFFF);
+          insert_into_vector<32>(&this->data_, 0);
+          insert_into_vector<64>(
               &this->data_,
               (11 + get_length_as_unsigned_LEB_128(abbreviation_number)
               + die_end - debug_info));
-          Insert_into_vector<16>(&this->data_, version);
-          Insert_into_vector<64>(&this->data_, 0);
-          Insert_into_vector<8>(&this->data_, address_size);
+          insert_into_vector<16>(&this->data_, version);
+          insert_into_vector<64>(&this->data_, 0);
+          insert_into_vector<8>(&this->data_, address_size);
           write_unsigned_LEB_128(&this->data_, abbreviation_number);
           this->data_.insert(this->data_.end(), debug_info, die_end);
         }
@@ -398,13 +345,13 @@ void Output_reduced_debug_info_section::set_final_data_size()
               return;
             }
 
-          Insert_into_vector<32>(
+          insert_into_vector<32>(
               &this->data_,
               (7 + get_length_as_unsigned_LEB_128(abbreviation_number)
               + die_end - debug_info));
-          Insert_into_vector<16>(&this->data_, version);
-          Insert_into_vector<32>(&this->data_, 0);
-          Insert_into_vector<8>(&this->data_, address_size);
+          insert_into_vector<16>(&this->data_, version);
+          insert_into_vector<32>(&this->data_, 0);
+          insert_into_vector<8>(&this->data_, address_size);
           write_unsigned_LEB_128(&this->data_, abbreviation_number);
           this->data_.insert(this->data_.end(), debug_info, die_end);
         }
This page took 0.027966 seconds and 4 git commands to generate.