X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gold%2Fx86_64.cc;h=3cfc064d4b467de85c2c30dd1ac6dfbb4cfe9959;hb=4d625b70fc3fb7facc7159feb8d49b78ac6641f9;hp=c48a513e2f4acb776a257128e055c4752201de15;hpb=b05b120205e697db6291abb95a8cd2be054f99e9;p=deliverable%2Fbinutils-gdb.git diff --git a/gold/x86_64.cc b/gold/x86_64.cc index c48a513e2f..3cfc064d4b 100644 --- a/gold/x86_64.cc +++ b/gold/x86_64.cc @@ -496,6 +496,21 @@ class Target_x86_64 : public Sized_target 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* 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( @@ -859,15 +874,6 @@ class Target_x86_64 : public Sized_target bool skip_call_tls_get_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*); - }; - // Check if relocation against this symbol is a candidate for // conversion from // mov foo@GOTPCREL(%rip), %reg @@ -3191,15 +3197,16 @@ Target_x86_64::gc_process_relocs(Symbol_table* symtab, size_t local_symbol_count, const unsigned char* plocal_symbols) { + typedef gold::Default_classify_reloc + Classify_reloc; if (sh_type == elfcpp::SHT_REL) { return; } - gold::gc_process_relocs, elfcpp::SHT_RELA, - typename Target_x86_64::Scan, - typename Target_x86_64::Relocatable_size_for_reloc>( + gold::gc_process_relocs, Scan, + Classify_reloc>( symtab, layout, this, @@ -3229,6 +3236,9 @@ Target_x86_64::scan_relocs(Symbol_table* symtab, size_t local_symbol_count, const unsigned char* plocal_symbols) { + typedef gold::Default_classify_reloc + Classify_reloc; + if (sh_type == elfcpp::SHT_REL) { gold_error(_("%s: unsupported REL reloc section"), @@ -3236,8 +3246,7 @@ Target_x86_64::scan_relocs(Symbol_table* symtab, return; } - gold::scan_relocs, elfcpp::SHT_RELA, - typename Target_x86_64::Scan>( + gold::scan_relocs, Scan, Classify_reloc>( symtab, layout, this, @@ -4268,11 +4277,13 @@ Target_x86_64::relocate_section( section_size_type view_size, const Reloc_symbol_changes* reloc_symbol_changes) { + typedef gold::Default_classify_reloc + Classify_reloc; + gold_assert(sh_type == elfcpp::SHT_RELA); - gold::relocate_section, elfcpp::SHT_RELA, - typename Target_x86_64::Relocate, - gold::Default_comdat_behavior>( + gold::relocate_section, Relocate, + gold::Default_comdat_behavior, Classify_reloc>( relinfo, this, prelocs, @@ -4313,86 +4324,50 @@ Target_x86_64::apply_relocation( view_size); } -// Return the size of a relocation while scanning during a relocatable -// link. +// Scan the relocs during a relocatable link. template -unsigned int -Target_x86_64::Relocatable_size_for_reloc::get_size_for_reloc( - unsigned int r_type, - Relobj* object) +void +Target_x86_64::scan_relocatable_relocs( + Symbol_table* symtab, + Layout* layout, + Sized_relobj_file* 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_symbols, + Relocatable_relocs* rr) { - switch (r_type) - { - case elfcpp::R_X86_64_NONE: - case elfcpp::R_X86_64_GNU_VTINHERIT: - case elfcpp::R_X86_64_GNU_VTENTRY: - case elfcpp::R_X86_64_TLSGD: // Global-dynamic - case elfcpp::R_X86_64_GOTPC32_TLSDESC: // Global-dynamic (from ~oliva url) - case elfcpp::R_X86_64_TLSDESC_CALL: - case elfcpp::R_X86_64_TLSLD: // Local-dynamic - case elfcpp::R_X86_64_DTPOFF32: - case elfcpp::R_X86_64_DTPOFF64: - case elfcpp::R_X86_64_GOTTPOFF: // Initial-exec - case elfcpp::R_X86_64_TPOFF32: // Local-exec - return 0; + typedef gold::Default_classify_reloc + Classify_reloc; + typedef gold::Default_scan_relocatable_relocs + Scan_relocatable_relocs; - case elfcpp::R_X86_64_64: - case elfcpp::R_X86_64_PC64: - case elfcpp::R_X86_64_GOTOFF64: - case elfcpp::R_X86_64_GOTPC64: - case elfcpp::R_X86_64_PLTOFF64: - case elfcpp::R_X86_64_GOT64: - case elfcpp::R_X86_64_GOTPCREL64: - case elfcpp::R_X86_64_GOTPCREL: - case elfcpp::R_X86_64_GOTPCRELX: - case elfcpp::R_X86_64_REX_GOTPCRELX: - case elfcpp::R_X86_64_GOTPLT64: - return 8; - - case elfcpp::R_X86_64_32: - case elfcpp::R_X86_64_32S: - case elfcpp::R_X86_64_PC32: - case elfcpp::R_X86_64_PC32_BND: - case elfcpp::R_X86_64_PLT32: - case elfcpp::R_X86_64_PLT32_BND: - case elfcpp::R_X86_64_GOTPC32: - case elfcpp::R_X86_64_GOT32: - return 4; - - case elfcpp::R_X86_64_16: - case elfcpp::R_X86_64_PC16: - return 2; - - case elfcpp::R_X86_64_8: - case elfcpp::R_X86_64_PC8: - return 1; - - case elfcpp::R_X86_64_COPY: - case elfcpp::R_X86_64_GLOB_DAT: - case elfcpp::R_X86_64_JUMP_SLOT: - case elfcpp::R_X86_64_RELATIVE: - case elfcpp::R_X86_64_IRELATIVE: - // These are outstanding tls relocs, which are unexpected when linking - case elfcpp::R_X86_64_TPOFF64: - case elfcpp::R_X86_64_DTPMOD64: - case elfcpp::R_X86_64_TLSDESC: - object->error(_("unexpected reloc %u in object file"), r_type); - return 0; + gold_assert(sh_type == elfcpp::SHT_RELA); - case elfcpp::R_X86_64_SIZE32: - case elfcpp::R_X86_64_SIZE64: - default: - object->error(_("unsupported reloc %u against local symbol"), r_type); - return 0; - } + gold::scan_relocatable_relocs( + symtab, + layout, + object, + data_shndx, + prelocs, + reloc_count, + output_section, + needs_special_offset_handling, + local_symbol_count, + plocal_symbols, + rr); } -// Scan the relocs during a relocatable link. +// Scan the relocs for --emit-relocs. template void -Target_x86_64::scan_relocatable_relocs( +Target_x86_64::emit_relocs_scan( Symbol_table* symtab, Layout* layout, Sized_relobj_file* object, @@ -4403,16 +4378,17 @@ Target_x86_64::scan_relocatable_relocs( Output_section* output_section, bool needs_special_offset_handling, size_t local_symbol_count, - const unsigned char* plocal_symbols, + const unsigned char* plocal_syms, Relocatable_relocs* rr) { - gold_assert(sh_type == elfcpp::SHT_RELA); + typedef gold::Default_classify_reloc + Classify_reloc; + typedef gold::Default_emit_relocs_strategy + Emit_relocs_strategy; - typedef gold::Default_scan_relocatable_relocs Scan_relocatable_relocs; + gold_assert(sh_type == elfcpp::SHT_RELA); - gold::scan_relocatable_relocs( + gold::scan_relocatable_relocs( symtab, layout, object, @@ -4422,7 +4398,7 @@ Target_x86_64::scan_relocatable_relocs( output_section, needs_special_offset_handling, local_symbol_count, - plocal_symbols, + plocal_syms, rr); } @@ -4443,9 +4419,12 @@ Target_x86_64::relocate_relocs( unsigned char* reloc_view, section_size_type reloc_view_size) { + typedef gold::Default_classify_reloc + Classify_reloc; + gold_assert(sh_type == elfcpp::SHT_RELA); - gold::relocate_relocs( + gold::relocate_relocs( relinfo, prelocs, reloc_count,