diff options
author | Cary Coutant <ccoutant@gmail.com> | 2017-11-19 17:56:30 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2017-11-21 10:22:10 -0800 |
commit | 72a84cb1b1285e244e918381c69de5a08bb63a9b (patch) | |
tree | 96663b944a82d51a2513c932a5e9c075e71dbf12 | |
parent | 234874b46f90b1e6a650dc4a700f8e6b0999e482 (diff) | |
download | gdb-72a84cb1b1285e244e918381c69de5a08bb63a9b.zip gdb-72a84cb1b1285e244e918381c69de5a08bb63a9b.tar.gz gdb-72a84cb1b1285e244e918381c69de5a08bb63a9b.tar.bz2 |
Fix DWARF reader to use correct size for DW_FORM_ref_addr.
2017-11-19 Ian Lance Taylor <iant@google.com>
Cary Coutant <ccoutant@gmail.com>
gold/
* 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.
-rw-r--r-- | gold/ChangeLog | 11 | ||||
-rw-r--r-- | gold/dwarf_reader.cc | 19 | ||||
-rw-r--r-- | gold/dwarf_reader.h | 7 |
3 files changed, 35 insertions, 2 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index b15b0d8..00cc91f 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,14 @@ +2017-11-21 Ian Lance Taylor <iant@google.com> + + Apply from master: + 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-15 Eric Christopher <echristo@gmail.com> Apply from master. diff --git a/gold/dwarf_reader.cc b/gold/dwarf_reader.cc index 8c0d593..4da9c1e 100644 --- a/gold/dwarf_reader.cc +++ b/gold/dwarf_reader.cc @@ -737,7 +737,6 @@ Dwarf_die::read_attributes() break; } case elfcpp::DW_FORM_addr: - case elfcpp::DW_FORM_ref_addr: { off_t sec_off; if (this->dwinfo_->address_size() == 4) @@ -751,6 +750,20 @@ Dwarf_die::read_attributes() 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; @@ -947,9 +960,11 @@ Dwarf_die::skip_attributes() 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; diff --git a/gold/dwarf_reader.h b/gold/dwarf_reader.h index b41e057..31e76ce 100644 --- a/gold/dwarf_reader.h +++ b/gold/dwarf_reader.h @@ -764,6 +764,13 @@ class Dwarf_info_reader 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. |