diff options
Diffstat (limited to 'gold/sparc.cc')
-rw-r--r-- | gold/sparc.cc | 109 |
1 files changed, 74 insertions, 35 deletions
diff --git a/gold/sparc.cc b/gold/sparc.cc index 049e0ab..c97c32c 100644 --- a/gold/sparc.cc +++ b/gold/sparc.cc @@ -131,6 +131,21 @@ class Target_sparc : public Sized_target<size, big_endian> const unsigned char* plocal_symbols, Relocatable_relocs*); + // Scan the relocs for --emit-relocs. + void + emit_relocs_scan(Symbol_table* symtab, + Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + size_t local_symbol_count, + const unsigned char* plocal_syms, + Relocatable_relocs* rr); + // Emit relocations for a section. void relocate_relocs(const Relocate_info<size, big_endian>*, @@ -345,15 +360,6 @@ class Target_sparc : public Sized_target<size, big_endian> unsigned char *reloc_adjust_addr_; }; - // A class which returns the size required for a relocation type, - // used while scanning relocs during a relocatable link. - class Relocatable_size_for_reloc - { - public: - unsigned int - get_size_for_reloc(unsigned int, Relobj*); - }; - // Get the GOT section, creating it if necessary. Output_data_got<size, big_endian>* got_section(Symbol_table*, Layout*); @@ -3036,9 +3042,10 @@ Target_sparc<size, big_endian>::gc_process_relocs( { typedef Target_sparc<size, big_endian> Sparc; typedef typename Target_sparc<size, big_endian>::Scan Scan; + typedef gold::Default_classify_reloc<elfcpp::SHT_RELA, size, big_endian> + Classify_reloc; - gold::gc_process_relocs<size, big_endian, Sparc, elfcpp::SHT_RELA, Scan, - typename Target_sparc::Relocatable_size_for_reloc>( + gold::gc_process_relocs<size, big_endian, Sparc, Scan, Classify_reloc>( symtab, layout, this, @@ -3070,7 +3077,8 @@ Target_sparc<size, big_endian>::scan_relocs( const unsigned char* plocal_symbols) { typedef Target_sparc<size, big_endian> Sparc; - typedef typename Target_sparc<size, big_endian>::Scan Scan; + typedef gold::Default_classify_reloc<elfcpp::SHT_RELA, size, big_endian> + Classify_reloc; if (sh_type == elfcpp::SHT_REL) { @@ -3079,7 +3087,7 @@ Target_sparc<size, big_endian>::scan_relocs( return; } - gold::scan_relocs<size, big_endian, Sparc, elfcpp::SHT_RELA, Scan>( + gold::scan_relocs<size, big_endian, Sparc, Scan, Classify_reloc>( symtab, layout, this, @@ -4142,11 +4150,13 @@ Target_sparc<size, big_endian>::relocate_section( { typedef Target_sparc<size, big_endian> Sparc; typedef typename Target_sparc<size, big_endian>::Relocate Sparc_relocate; + typedef gold::Default_classify_reloc<elfcpp::SHT_RELA, size, big_endian> + Classify_reloc; gold_assert(sh_type == elfcpp::SHT_RELA); - gold::relocate_section<size, big_endian, Sparc, elfcpp::SHT_RELA, - Sparc_relocate, gold::Default_comdat_behavior>( + gold::relocate_section<size, big_endian, Sparc, Sparc_relocate, + gold::Default_comdat_behavior, Classify_reloc>( relinfo, this, prelocs, @@ -4159,20 +4169,6 @@ Target_sparc<size, big_endian>::relocate_section( reloc_symbol_changes); } -// Return the size of a relocation while scanning during a relocatable -// link. - -template<int size, bool big_endian> -unsigned int -Target_sparc<size, big_endian>::Relocatable_size_for_reloc::get_size_for_reloc( - unsigned int, - Relobj*) -{ - // We are always SHT_RELA, so we should never get here. - gold_unreachable(); - return 0; -} - // Scan the relocs during a relocatable link. template<int size, bool big_endian> @@ -4191,13 +4187,14 @@ Target_sparc<size, big_endian>::scan_relocatable_relocs( const unsigned char* plocal_symbols, Relocatable_relocs* rr) { - gold_assert(sh_type == elfcpp::SHT_RELA); + typedef gold::Default_classify_reloc<elfcpp::SHT_RELA, size, big_endian> + Classify_reloc; + typedef gold::Default_scan_relocatable_relocs<Classify_reloc> + Scan_relocatable_relocs; - typedef gold::Default_scan_relocatable_relocs<elfcpp::SHT_RELA, - Relocatable_size_for_reloc> Scan_relocatable_relocs; + gold_assert(sh_type == elfcpp::SHT_RELA); - gold::scan_relocatable_relocs<size, big_endian, elfcpp::SHT_RELA, - Scan_relocatable_relocs>( + gold::scan_relocatable_relocs<size, big_endian, Scan_relocatable_relocs>( symtab, layout, object, @@ -4211,6 +4208,45 @@ Target_sparc<size, big_endian>::scan_relocatable_relocs( rr); } +// Scan the relocs for --emit-relocs. + +template<int size, bool big_endian> +void +Target_sparc<size, big_endian>::emit_relocs_scan( + Symbol_table* symtab, + Layout* layout, + Sized_relobj_file<size, big_endian>* object, + unsigned int data_shndx, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + size_t local_symbol_count, + const unsigned char* plocal_syms, + Relocatable_relocs* rr) +{ + typedef gold::Default_classify_reloc<elfcpp::SHT_RELA, size, big_endian> + Classify_reloc; + typedef gold::Default_emit_relocs_strategy<Classify_reloc> + Emit_relocs_strategy; + + gold_assert(sh_type == elfcpp::SHT_RELA); + + gold::scan_relocatable_relocs<size, big_endian, Emit_relocs_strategy>( + symtab, + layout, + object, + data_shndx, + prelocs, + reloc_count, + output_section, + needs_special_offset_handling, + local_symbol_count, + plocal_syms, + rr); +} + // Emit relocations for a section. template<int size, bool big_endian> @@ -4228,9 +4264,12 @@ Target_sparc<size, big_endian>::relocate_relocs( unsigned char* reloc_view, section_size_type reloc_view_size) { + typedef gold::Default_classify_reloc<elfcpp::SHT_RELA, size, big_endian> + Classify_reloc; + gold_assert(sh_type == elfcpp::SHT_RELA); - gold::relocate_relocs<size, big_endian, elfcpp::SHT_RELA>( + gold::relocate_relocs<size, big_endian, Classify_reloc>( relinfo, prelocs, reloc_count, |