aboutsummaryrefslogtreecommitdiff
path: root/gold/dwarf_reader.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2010-12-01 19:49:22 +0000
committerIan Lance Taylor <ian@airs.com>2010-12-01 19:49:22 +0000
commit4dbfafccf0dd346e7a73cddf85c600aa7afa3644 (patch)
tree48e04173f24d3f0584279ae2a043809cbe100616 /gold/dwarf_reader.cc
parent148c11bf2e571032ff6b7baa6c364a2b01f0b42e (diff)
downloadgdb-4dbfafccf0dd346e7a73cddf85c600aa7afa3644.zip
gdb-4dbfafccf0dd346e7a73cddf85c600aa7afa3644.tar.gz
gdb-4dbfafccf0dd346e7a73cddf85c600aa7afa3644.tar.bz2
* dwarf_reader.h (class Sized_dwarf_line_info): Add
track_relocs_type_ field. * dwarf_reader.cc (Sized_dwarf_line_info::Sized_dwarf_line_info): Set track_relocs_type_. (Sized_dwarf_line_info::process_one_opcode): Ignore the section contents when using RELA relocs. (Sized_dwarf_line_info::read_relocs): Add the reloc addend to reloc_map_. * reloc.cc (Track_relocs::next_addend): New function. * reloc.h (class Track_relocs): Declare next_addend.
Diffstat (limited to 'gold/dwarf_reader.cc')
-rw-r--r--gold/dwarf_reader.cc24
1 files changed, 18 insertions, 6 deletions
diff --git a/gold/dwarf_reader.cc b/gold/dwarf_reader.cc
index e83e7fb..c4c9bfc 100644
--- a/gold/dwarf_reader.cc
+++ b/gold/dwarf_reader.cc
@@ -1,6 +1,6 @@
// dwarf_reader.cc -- parse dwarf2/3 debug information
-// Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
@@ -113,6 +113,7 @@ Sized_dwarf_line_info<size, big_endian>::Sized_dwarf_line_info(Object* object,
{
got_relocs = this->track_relocs_.initialize(object, reloc_shndx,
reloc_sh_type);
+ this->track_relocs_type_ = reloc_sh_type;
break;
}
}
@@ -392,13 +393,21 @@ Sized_dwarf_line_info<size, big_endian>::process_one_opcode(
case elfcpp::DW_LNE_set_address:
{
- lsm->address = elfcpp::Swap_unaligned<size, big_endian>::readval(start);
+ lsm->address =
+ elfcpp::Swap_unaligned<size, big_endian>::readval(start);
typename Reloc_map::const_iterator it
- = reloc_map_.find(start - this->buffer_);
+ = this->reloc_map_.find(start - this->buffer_);
if (it != reloc_map_.end())
{
- // value + addend.
- lsm->address += it->second.second;
+ // If this is a SHT_RELA section, then ignore the
+ // section contents. This assumes that this is a
+ // straight reloc which just uses the reloc addend.
+ // The reloc addend has already been included in the
+ // symbol value.
+ if (this->track_relocs_type_ == elfcpp::SHT_RELA)
+ lsm->address = 0;
+ // Add in the symbol value.
+ lsm->address += it->second.second;
lsm->shndx = it->second.first;
}
else
@@ -536,7 +545,10 @@ Sized_dwarf_line_info<size, big_endian>::read_relocs(Object* object)
// There is no reason to record non-ordinary section indexes, or
// SHN_UNDEF, because they will never match the real section.
if (is_ordinary && shndx != elfcpp::SHN_UNDEF)
- this->reloc_map_[reloc_offset] = std::make_pair(shndx, value);
+ {
+ value += this->track_relocs_.next_addend();
+ this->reloc_map_[reloc_offset] = std::make_pair(shndx, value);
+ }
this->track_relocs_.advance(reloc_offset + 1);
}