aboutsummaryrefslogtreecommitdiff
path: root/gold/gc.h
diff options
context:
space:
mode:
authorSriraman Tallam <tmsriram@google.com>2010-07-29 18:57:28 +0000
committerSriraman Tallam <tmsriram@google.com>2010-07-29 18:57:28 +0000
commit41cbeecc3c135adf06568c9cc566fce385cc3c06 (patch)
tree98d916c8dcc44287161445d6b1f456abae97faac /gold/gc.h
parentf9c7014e9c1c8ac8b39b1819a6510d0a2ba90e13 (diff)
downloadgdb-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/gc.h')
-rw-r--r--gold/gc.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/gold/gc.h b/gold/gc.h
index 77ac6da..06b7125 100644
--- a/gold/gc.h
+++ b/gold/gc.h
@@ -151,6 +151,20 @@ struct Symbols_data
section_size_type symbol_names_size;
};
+// Relocations of type SHT_REL store the addend value in their bytes.
+// This function returns the size of the embedded addend which is
+// nothing but the size of the relocation.
+
+template<typename Classify_reloc>
+inline unsigned int
+get_embedded_addend_size(int sh_type, int r_type, Relobj* obj)
+{
+ if (sh_type != elfcpp::SHT_REL)
+ return 0;
+ Classify_reloc classify_reloc;
+ return classify_reloc.get_size_for_reloc(r_type, obj);
+}
+
// This function implements the generic part of reloc
// processing to map a section to all the sections it
// references through relocs. It is called only during
@@ -158,7 +172,7 @@ struct Symbols_data
// folding (--icf).
template<int size, bool big_endian, typename Target_type, int sh_type,
- typename Scan>
+ typename Scan, typename Classify_reloc>
inline void
gc_process_relocs(
Symbol_table* symtab,
@@ -185,6 +199,7 @@ gc_process_relocs(
Icf::Symbol_info* symvec = NULL;
Icf::Addend_info* addendvec = NULL;
Icf::Offset_info* offsetvec = NULL;
+ Icf::Reloc_addend_size_info* reloc_addend_size_vec = NULL;
bool is_icf_tracked = false;
const char* cident_section_name = NULL;
@@ -205,6 +220,7 @@ gc_process_relocs(
symvec = &reloc_info->symbol_info;
addendvec = &reloc_info->addend_info;
offsetvec = &reloc_info->offset_info;
+ reloc_addend_size_vec = &reloc_info->reloc_addend_size_info;
}
check_section_for_function_pointers =
@@ -243,6 +259,9 @@ gc_process_relocs(
uint64_t reloc_offset =
convert_to_section_size_type(reloc.get_r_offset());
(*offsetvec).push_back(reloc_offset);
+ (*reloc_addend_size_vec).push_back(
+ get_embedded_addend_size<Classify_reloc>(sh_type, r_type,
+ src_obj));
}
// When doing safe folding, check to see if this relocation is that
@@ -316,6 +335,9 @@ gc_process_relocs(
uint64_t reloc_offset =
convert_to_section_size_type(reloc.get_r_offset());
(*offsetvec).push_back(reloc_offset);
+ (*reloc_addend_size_vec).push_back(
+ get_embedded_addend_size<Classify_reloc>(sh_type, r_type,
+ src_obj));
}
if (gsym->source() != Symbol::FROM_OBJECT)