aboutsummaryrefslogtreecommitdiff
path: root/gold/output.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2008-04-07 22:46:17 +0000
committerIan Lance Taylor <ian@airs.com>2008-04-07 22:46:17 +0000
commit624f881062a90cbd4675e7b826225c232c39050e (patch)
treee9a126aef21b68223532b4da5d2ccc6cf51717bf /gold/output.cc
parent6835af537eec580a0f4f2064d0e11e378c86b39e (diff)
downloadbinutils-624f881062a90cbd4675e7b826225c232c39050e.zip
binutils-624f881062a90cbd4675e7b826225c232c39050e.tar.gz
binutils-624f881062a90cbd4675e7b826225c232c39050e.tar.bz2
* output.cc (Output_reloc<SHT_REL>::local_section_offset): Add
addend parameter. Change caller. Handle merge sections. (Output_reloc<SHT_REL>::symbol_value): Change parameter type from Address to Addend. Don't add in the result of local_section_offset, pass down the addend and use the returned value. * output.h (class Output_reloc<SHT_REL>): Add Addend typedef. Update declarations of local_section_offset and symbol_value. * testsuite/two_file_test_1.cc (t18): New function. * testsuite/two_file_test_2.cc (f18): New function. * testsuite/two_file_test_main.cc (main): Call t18. * testsuite/two_file_test.h (t18, f18): Declare.
Diffstat (limited to 'gold/output.cc')
-rw-r--r--gold/output.cc21
1 files changed, 15 insertions, 6 deletions
diff --git a/gold/output.cc b/gold/output.cc
index f3ae678..7a76f79 100644
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -790,18 +790,27 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::get_symbol_index()
return index;
}
-// For a local section symbol, get the section offset of the input
-// section within the output section.
+// For a local section symbol, get the address of the offset ADDEND
+// within the input section.
template<bool dynamic, int size, bool big_endian>
section_offset_type
Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::
- local_section_offset() const
+ local_section_offset(Addend addend) const
{
+ gold_assert(this->local_sym_index_ != GSYM_CODE
+ && this->local_sym_index_ != SECTION_CODE
+ && this->local_sym_index_ != INVALID_CODE
+ && this->is_section_symbol_);
const unsigned int lsi = this->local_sym_index_;
section_offset_type offset;
Output_section* os = this->u1_.relobj->output_section(lsi, &offset);
- gold_assert(os != NULL && offset != -1);
+ gold_assert(os != NULL);
+ if (offset != -1)
+ return offset + addend;
+ // This is a merge section.
+ offset = os->output_address(this->u1_.relobj, lsi, addend);
+ gold_assert(offset != -1);
return offset;
}
@@ -853,7 +862,7 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::write(
template<bool dynamic, int size, bool big_endian>
typename elfcpp::Elf_types<size>::Elf_Addr
Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::symbol_value(
- Address addend) const
+ Addend addend) const
{
if (this->local_sym_index_ == GSYM_CODE)
{
@@ -882,7 +891,7 @@ Output_reloc<elfcpp::SHT_RELA, dynamic, size, big_endian>::write(
if (this->rel_.is_relative())
addend = this->rel_.symbol_value(addend);
else if (this->rel_.is_local_section_symbol())
- addend += this->rel_.local_section_offset();
+ addend = this->rel_.local_section_offset(addend);
orel.put_r_addend(addend);
}