+2017-11-19 Ian Lance Taylor <iant@google.com>
+ Cary Coutant <ccoutant@gmail.com>
+
+ * gold/dwarf_reader.h (class Dwarf_info_reader): Add ref_addr_size
+ method.
+ * gold/dwarf_reader.cc (Dwarf_die::read_attributes): Use ref_addr_size
+ for DW_FORM_ref_addr_size.
+ (Dwarf_die::skip_attributes): Likewise.
+
2017-11-08 H.J. Lu <hongjiu.lu@intel.com>
PR gold/22291
break;
}
case elfcpp::DW_FORM_addr:
- case elfcpp::DW_FORM_ref_addr:
{
off_t sec_off;
if (this->dwinfo_->address_size() == 4)
ref_form = true;
break;
}
+ case elfcpp::DW_FORM_ref_addr:
+ {
+ off_t sec_off;
+ if (this->dwinfo_->ref_addr_size() == 4)
+ sec_off = this->dwinfo_->read_from_pointer<32>(&pattr);
+ else
+ 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;
+ attr_value.val.refval = sec_off;
+ ref_form = true;
+ break;
+ }
case elfcpp::DW_FORM_block1:
attr_value.aux.blocklen = *pattr++;
attr_value.val.blockval = pattr;
pattr += this->dwinfo_->offset_size();
break;
case elfcpp::DW_FORM_addr:
- case elfcpp::DW_FORM_ref_addr:
pattr += this->dwinfo_->address_size();
break;
+ case elfcpp::DW_FORM_ref_addr:
+ pattr += this->dwinfo_->ref_addr_size();
+ break;
case elfcpp::DW_FORM_block1:
pattr += 1 + *pattr;
break;
address_size() const
{ return this->address_size_; }
+ // Return the size of a DW_FORM_ref_addr.
+ // In DWARF v2, this was the size of an address; in DWARF v3 and later,
+ // it is the size of an DWARF offset.
+ unsigned int
+ ref_addr_size() const
+ { return this->cu_version_ > 2 ? this->offset_size_ : this->address_size_; }
+
// Set the section index of the .debug_abbrev section.
// We use this if there are no relocations for the .debug_info section.
// If not set, the code parse() routine will search for the section by name.