From 41cbeecc3c135adf06568c9cc566fce385cc3c06 Mon Sep 17 00:00:00 2001 From: Sriraman Tallam Date: Thu, 29 Jul 2010 18:57:28 +0000 Subject: * arm.cc (Target_arm::gc_process_relocs): Add template paramter to the call to gold::gc_process_relocs. * i386.cc (Target_i386::gc_process_relocs): Add template paramter to the call to gold::gc_process_relocs. * x86_64.cc (Target_x86_64::gc_process_relocs): Add template parameter to the call to gold::gc_process_relocs. * powerpc.cc (Target_powerpc::gc_process_relocs): Add template parameter to the call to gold::gc_process_relocs. * sparc.cc (Target_sparc::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. --- gold/gc.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'gold/gc.h') 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 +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 + 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(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(sh_type, r_type, + src_obj)); } if (gsym->source() != Symbol::FROM_OBJECT) -- cgit v1.1