unsigned int symndx, Address* value, bool* is_ordinary)
{
const int symsize = elfcpp::Elf_sizes<size>::sym_size;
- gold_assert((symndx + 1) * symsize <= this->symtab_size_);
+ gold_assert(static_cast<off_t>((symndx + 1) * symsize) <= this->symtab_size_);
elfcpp::Sym<size, big_endian> elfsym(this->symtab_ + symndx * symsize);
*value = elfsym.get_st_value();
return this->object_->adjust_sym_shndx(symndx, elfsym.get_st_shndx(),
// Read the raw contents of the section.
if (addr_size == 4)
{
- start = read_from_pointer<32>(this->ranges_buffer_ + offset);
- end = read_from_pointer<32>(this->ranges_buffer_ + offset + 4);
+ start = this->dwinfo_->read_from_pointer<32>(this->ranges_buffer_
+ + offset);
+ end = this->dwinfo_->read_from_pointer<32>(this->ranges_buffer_
+ + offset + 4);
}
else
{
- start = read_from_pointer<64>(this->ranges_buffer_ + offset);
- end = read_from_pointer<64>(this->ranges_buffer_ + offset + 8);
+ start = this->dwinfo_->read_from_pointer<64>(this->ranges_buffer_
+ + offset);
+ end = this->dwinfo_->read_from_pointer<64>(this->ranges_buffer_
+ + offset + 8);
}
// Check for relocations and adjust the values.
const unsigned char* pinfo = this->buffer_ + offset;
// Read the unit_length field.
- uint32_t unit_length = read_from_pointer<32>(pinfo);
+ uint32_t unit_length = this->dwinfo_->read_from_pointer<32>(pinfo);
pinfo += 4;
if (unit_length == 0xffffffff)
{
- unit_length = read_from_pointer<64>(pinfo);
+ unit_length = this->dwinfo_->read_from_pointer<64>(pinfo);
pinfo += 8;
this->offset_size_ = 8;
}
this->offset_size_ = 4;
// Check the version.
- unsigned int version = read_from_pointer<16>(pinfo);
+ unsigned int version = this->dwinfo_->read_from_pointer<16>(pinfo);
pinfo += 2;
if (version != 2)
return false;
-
+
// Skip the debug_info_offset and debug_info_size fields.
pinfo += 2 * this->offset_size_;
// the end of the list.
uint32_t offset;
if (this->offset_size_ == 4)
- offset = read_from_pointer<32>(&pinfo);
+ offset = this->dwinfo_->read_from_pointer<32>(&pinfo);
else
- offset = read_from_pointer<64>(&pinfo);
+ offset = this->dwinfo_->read_from_pointer<64>(&pinfo);
if (offset == 0)
return NULL;
{
off_t str_off;
if (this->dwinfo_->offset_size() == 4)
- str_off = read_from_pointer<32>(&pattr);
+ str_off = this->dwinfo_->read_from_pointer<32>(&pattr);
else
- str_off = read_from_pointer<64>(&pattr);
+ str_off = this->dwinfo_->read_from_pointer<64>(&pattr);
unsigned int shndx =
this->dwinfo_->lookup_reloc(attr_off, &str_off);
attr_value.aux.shndx = shndx;
{
off_t sec_off;
if (this->dwinfo_->offset_size() == 4)
- sec_off = read_from_pointer<32>(&pattr);
+ sec_off = this->dwinfo_->read_from_pointer<32>(&pattr);
else
- sec_off = read_from_pointer<64>(&pattr);
+ sec_off = this->dwinfo_->read_from_pointer<64>(&pattr);
unsigned int shndx =
this->dwinfo_->lookup_reloc(attr_off, &sec_off);
attr_value.aux.shndx = shndx;
{
off_t sec_off;
if (this->dwinfo_->address_size() == 4)
- sec_off = read_from_pointer<32>(&pattr);
+ sec_off = this->dwinfo_->read_from_pointer<32>(&pattr);
else
- sec_off = read_from_pointer<64>(&pattr);
+ sec_off = this->dwinfo_->read_from_pointer<64>(&pattr);
unsigned int shndx =
this->dwinfo_->lookup_reloc(attr_off, &sec_off);
attr_value.aux.shndx = shndx;
pattr += attr_value.aux.blocklen;
break;
case elfcpp::DW_FORM_block2:
- attr_value.aux.blocklen = read_from_pointer<16>(&pattr);
+ attr_value.aux.blocklen =
+ this->dwinfo_->read_from_pointer<16>(&pattr);
attr_value.val.blockval = pattr;
pattr += attr_value.aux.blocklen;
break;
case elfcpp::DW_FORM_block4:
- attr_value.aux.blocklen = read_from_pointer<32>(&pattr);
+ attr_value.aux.blocklen =
+ this->dwinfo_->read_from_pointer<32>(&pattr);
attr_value.val.blockval = pattr;
pattr += attr_value.aux.blocklen;
break;
ref_form = true;
break;
case elfcpp::DW_FORM_data2:
- attr_value.val.intval = read_from_pointer<16>(&pattr);
+ attr_value.val.intval =
+ this->dwinfo_->read_from_pointer<16>(&pattr);
break;
case elfcpp::DW_FORM_ref2:
- attr_value.val.refval = read_from_pointer<16>(&pattr);
+ attr_value.val.refval =
+ this->dwinfo_->read_from_pointer<16>(&pattr);
ref_form = true;
break;
case elfcpp::DW_FORM_data4:
{
off_t sec_off;
- sec_off = read_from_pointer<32>(&pattr);
+ sec_off = this->dwinfo_->read_from_pointer<32>(&pattr);
unsigned int shndx =
this->dwinfo_->lookup_reloc(attr_off, &sec_off);
attr_value.aux.shndx = shndx;
case elfcpp::DW_FORM_ref4:
{
off_t sec_off;
- sec_off = read_from_pointer<32>(&pattr);
+ sec_off = this->dwinfo_->read_from_pointer<32>(&pattr);
unsigned int shndx =
this->dwinfo_->lookup_reloc(attr_off, &sec_off);
attr_value.aux.shndx = shndx;
case elfcpp::DW_FORM_data8:
{
off_t sec_off;
- sec_off = read_from_pointer<64>(&pattr);
+ sec_off = this->dwinfo_->read_from_pointer<64>(&pattr);
unsigned int shndx =
this->dwinfo_->lookup_reloc(attr_off, &sec_off);
attr_value.aux.shndx = shndx;
break;
}
case elfcpp::DW_FORM_ref_sig8:
- attr_value.val.uintval = read_from_pointer<64>(&pattr);
+ attr_value.val.uintval =
+ this->dwinfo_->read_from_pointer<64>(&pattr);
break;
case elfcpp::DW_FORM_ref8:
{
off_t sec_off;
- sec_off = read_from_pointer<64>(&pattr);
+ sec_off = this->dwinfo_->read_from_pointer<64>(&pattr);
unsigned int shndx =
this->dwinfo_->lookup_reloc(attr_off, &sec_off);
attr_value.aux.shndx = shndx;
case elfcpp::DW_FORM_block2:
{
uint16_t block_size;
- block_size = read_from_pointer<16>(&pattr);
+ block_size = this->dwinfo_->read_from_pointer<16>(&pattr);
pattr += block_size;
break;
}
case elfcpp::DW_FORM_block4:
{
uint32_t block_size;
- block_size = read_from_pointer<32>(&pattr);
+ block_size = this->dwinfo_->read_from_pointer<32>(&pattr);
pattr += block_size;
break;
}
return true;
}
+// Read a possibly unaligned integer of SIZE.
+template <int valsize>
+inline typename elfcpp::Valtype_base<valsize>::Valtype
+Dwarf_info_reader::read_from_pointer(const unsigned char* source)
+{
+ typename elfcpp::Valtype_base<valsize>::Valtype return_value;
+ if (this->object_->is_big_endian())
+ return_value = elfcpp::Swap_unaligned<valsize, true>::readval(source);
+ else
+ return_value = elfcpp::Swap_unaligned<valsize, false>::readval(source);
+ return return_value;
+}
+
+// Read a possibly unaligned integer of SIZE. Update SOURCE after read.
+template <int valsize>
+inline typename elfcpp::Valtype_base<valsize>::Valtype
+Dwarf_info_reader::read_from_pointer(const unsigned char** source)
+{
+ typename elfcpp::Valtype_base<valsize>::Valtype return_value;
+ if (this->object_->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;
+}
+
// Look for a relocation at offset ATTR_OFF in the dwarf info,
// and return the section index and offset of the target.