diff options
author | Sriraman Tallam <tmsriram@google.com> | 2010-07-29 18:57:28 +0000 |
---|---|---|
committer | Sriraman Tallam <tmsriram@google.com> | 2010-07-29 18:57:28 +0000 |
commit | 41cbeecc3c135adf06568c9cc566fce385cc3c06 (patch) | |
tree | 98d916c8dcc44287161445d6b1f456abae97faac /gold/icf.cc | |
parent | f9c7014e9c1c8ac8b39b1819a6510d0a2ba90e13 (diff) | |
download | gdb-41cbeecc3c135adf06568c9cc566fce385cc3c06.zip gdb-41cbeecc3c135adf06568c9cc566fce385cc3c06.tar.gz gdb-41cbeecc3c135adf06568c9cc566fce385cc3c06.tar.bz2 |
* arm.cc (Target_arm<big_endian>::gc_process_relocs): Add template
paramter to the call to gold::gc_process_relocs.
* i386.cc (Target_i386<big_endian>::gc_process_relocs): Add template
paramter to the call to gold::gc_process_relocs.
* x86_64.cc (Target_x86_64<big_endian>::gc_process_relocs): Add template
parameter to the call to gold::gc_process_relocs.
* powerpc.cc (Target_powerpc<big_endian>::gc_process_relocs): Add
template parameter to the call to gold::gc_process_relocs.
* sparc.cc (Target_sparc<big_endian>::gc_process_relocs): Add template
paramter to the call to gold::gc_process_relocs.
* gc.h (get_embedded_addend_size): New function.
(gc_process_relocs): Save the size of the reloc for use by ICF.
* icf.cc (get_section_contents): Get the addend from the text section
for SHT_REL relocation sections.
* icf.h (Icf::Reloc_addend_size_info): New typedef.
(Icf::Reloc_info): Add new member reloc_addend_size_info.
* int_encoding.h (read_from_pointer): New overloaded function.
* testsuite/Makefile.am (icf_sht_rel_addend_test): New test.
* testsuite/icf_sht_rel_addend_test.sh: New file.
* testsuite/icf_sht_rel_addend_test_1.cc: New file.
* testsuite/icf_sht_rel_addend_test_2.cc: New file.
Diffstat (limited to 'gold/icf.cc')
-rw-r--r-- | gold/icf.cc | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/gold/icf.cc b/gold/icf.cc index 47b6c60..31312bb 100644 --- a/gold/icf.cc +++ b/gold/icf.cc @@ -145,6 +145,8 @@ #include "symtab.h" #include "libiberty.h" #include "demangle.h" +#include "elfcpp.h" +#include "int_encoding.h" namespace gold { @@ -269,12 +271,16 @@ get_section_contents(bool first_iteration, Icf::Addend_info a = (it_reloc_info_list->second).addend_info; // Stores the offset of the reloc. Icf::Offset_info o = (it_reloc_info_list->second).offset_info; + Icf::Reloc_addend_size_info reloc_addend_size_info = + (it_reloc_info_list->second).reloc_addend_size_info; Icf::Sections_reachable_info::iterator it_v = v.begin(); Icf::Symbol_info::iterator it_s = s.begin(); Icf::Addend_info::iterator it_a = a.begin(); Icf::Offset_info::iterator it_o = o.begin(); + Icf::Reloc_addend_size_info::iterator it_addend_size = + reloc_addend_size_info.begin(); - for (; it_v != v.end(); ++it_v, ++it_s, ++it_a, ++it_o) + for (; it_v != v.end(); ++it_v, ++it_s, ++it_a, ++it_o, ++it_addend_size) { // ADDEND_STR stores the symbol value and addend and offset, // each atmost 16 hex digits long. it_a points to a pair @@ -372,6 +378,46 @@ get_section_contents(bool first_iteration, if (addend < 0xffffff00) offset = offset + addend; + // For SHT_REL relocation sections, the addend is stored in the + // text section at the relocation offset. + uint64_t reloc_addend_value = 0; + const unsigned char* reloc_addend_ptr = + contents + static_cast<unsigned long long>(*it_o); + switch(*it_addend_size) + { + case 0: + { + break; + } + case 1: + { + reloc_addend_value = + read_from_pointer<8>(reloc_addend_ptr); + break; + } + case 2: + { + reloc_addend_value = + read_from_pointer<16>(reloc_addend_ptr); + break; + } + case 4: + { + reloc_addend_value = + read_from_pointer<32>(reloc_addend_ptr); + break; + } + case 8: + { + reloc_addend_value = + read_from_pointer<64>(reloc_addend_ptr); + break; + } + default: + gold_unreachable(); + } + offset = offset + reloc_addend_value; + section_size_type secn_len; const unsigned char* str_contents = (it_v->first)->section_contents(it_v->second, |