diff options
author | Ian Lance Taylor <ian@airs.com> | 2008-04-16 22:54:29 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2008-04-16 22:54:29 +0000 |
commit | 12c0daef5f792cf27f8d0897794bb32729dc370b (patch) | |
tree | a282dbfb5ea5b87e31cd1eb4e61bf04584bcd9f7 /gold/reloc.cc | |
parent | 4f4995b6282c41516d0bd895832ced99d799a744 (diff) | |
download | gdb-12c0daef5f792cf27f8d0897794bb32729dc370b.zip gdb-12c0daef5f792cf27f8d0897794bb32729dc370b.tar.gz gdb-12c0daef5f792cf27f8d0897794bb32729dc370b.tar.bz2 |
* copy-relocs.cc: New file.
* copy-relocs.h: New file.
* reloc.cc: Remove Copy_relocs code.
* reloc.h: Likewise.
* reloc-types.h (struct Reloc_types) [both versions]: Add
get_reloc_addend_noerror.
* output.h (class Output_data_reloc<elfcpp::SHT_REL>): Add
variants of add_global which take an addend which must be zero.
* i386.cc: Include "copy-relocs.h".
(class Target_i386): Change type of copy_relocs_ to variable,
update initializer.
(Target_i386::copy_reloc): Rewrite to pass to Copy_relocs class.
Change all callers.
(Target_i386::do_finalize_sections): Change handling of
copy_relocs_.
* sparc.cc: Include "copy-relocs.h".
(class Target_sparc): Change type of copy_relocs_ to variable,
update initializer.
(Target_sparc::copy_reloc): Rewrite to pass to Copy_relocs class.
Change all callers.
(Target_sparc::do_finalize_sections): Change handling of
copy_relocs_.
* x86_64.cc: Include "copy-relocs.h".
(class Target_x86_64): Change type of copy_relocs_ to variable,
update initializer.
(Target_x86_64::copy_reloc): Rewrite to pass to Copy_relocs
class. Change all callers.
(Target_x86_64::do_finalize_sections): Change handling of
copy_relocs_.
* Makefile.am (CCFILES): Add copy-relocs.cc.
(HFILES): Add copy-relocs.h.
Diffstat (limited to 'gold/reloc.cc')
-rw-r--r-- | gold/reloc.cc | 217 |
1 files changed, 1 insertions, 216 deletions
diff --git a/gold/reloc.cc b/gold/reloc.cc index c94aa9b..99a736b 100644 --- a/gold/reloc.cc +++ b/gold/reloc.cc @@ -952,144 +952,6 @@ Merged_symbol_value<size>::value_from_output_section( return this->output_start_address_ + output_offset; } -// Copy_relocs::Copy_reloc_entry methods. - -// Return whether we should emit this reloc. We should emit it if the -// symbol is still defined in a dynamic object. If we should not emit -// it, we clear it, to save ourselves the test next time. - -template<int size, bool big_endian> -bool -Copy_relocs<size, big_endian>::Copy_reloc_entry::should_emit() -{ - if (this->sym_ == NULL) - return false; - if (this->sym_->is_from_dynobj()) - return true; - this->sym_ = NULL; - return false; -} - -// Emit a reloc into a SHT_REL section. - -template<int size, bool big_endian> -void -Copy_relocs<size, big_endian>::Copy_reloc_entry::emit( - Output_data_reloc<elfcpp::SHT_REL, true, size, big_endian>* reloc_data) -{ - this->sym_->set_needs_dynsym_entry(); - reloc_data->add_global(this->sym_, this->reloc_type_, this->output_section_, - this->relobj_, this->shndx_, this->address_); -} - -// Emit a reloc into a SHT_RELA section. - -template<int size, bool big_endian> -void -Copy_relocs<size, big_endian>::Copy_reloc_entry::emit( - Output_data_reloc<elfcpp::SHT_RELA, true, size, big_endian>* reloc_data) -{ - this->sym_->set_needs_dynsym_entry(); - reloc_data->add_global(this->sym_, this->reloc_type_, this->output_section_, - this->relobj_, this->shndx_, this->address_, - this->addend_); -} - -// Copy_relocs methods. - -// Return whether we need a COPY reloc for a relocation against GSYM. -// The relocation is being applied to section SHNDX in OBJECT. - -template<int size, bool big_endian> -bool -Copy_relocs<size, big_endian>::need_copy_reloc( - const General_options*, - Relobj* object, - unsigned int shndx, - Sized_symbol<size>* sym) -{ - // FIXME: Handle -z nocopyrelocs. - - if (sym->symsize() == 0) - return false; - - // If this is a readonly section, then we need a COPY reloc. - // Otherwise we can use a dynamic reloc. - if ((object->section_flags(shndx) & elfcpp::SHF_WRITE) == 0) - return true; - - return false; -} - -// Save a Rel reloc. - -template<int size, bool big_endian> -void -Copy_relocs<size, big_endian>::save( - Symbol* sym, - Relobj* relobj, - unsigned int shndx, - Output_section* output_section, - const elfcpp::Rel<size, big_endian>& rel) -{ - unsigned int reloc_type = elfcpp::elf_r_type<size>(rel.get_r_info()); - this->entries_.push_back(Copy_reloc_entry(sym, reloc_type, relobj, shndx, - output_section, - rel.get_r_offset(), 0)); -} - -// Save a Rela reloc. - -template<int size, bool big_endian> -void -Copy_relocs<size, big_endian>::save( - Symbol* sym, - Relobj* relobj, - unsigned int shndx, - Output_section* output_section, - const elfcpp::Rela<size, big_endian>& rela) -{ - unsigned int reloc_type = elfcpp::elf_r_type<size>(rela.get_r_info()); - this->entries_.push_back(Copy_reloc_entry(sym, reloc_type, relobj, shndx, - output_section, - rela.get_r_offset(), - rela.get_r_addend())); -} - -// Return whether there are any relocs to emit. We don't want to emit -// a reloc if the symbol is no longer defined in a dynamic object. - -template<int size, bool big_endian> -bool -Copy_relocs<size, big_endian>::any_to_emit() -{ - for (typename Copy_reloc_entries::iterator p = this->entries_.begin(); - p != this->entries_.end(); - ++p) - { - if (p->should_emit()) - return true; - } - return false; -} - -// Emit relocs. - -template<int size, bool big_endian> -template<int sh_type> -void -Copy_relocs<size, big_endian>::emit( - Output_data_reloc<sh_type, true, size, big_endian>* reloc_data) -{ - for (typename Copy_reloc_entries::iterator p = this->entries_.begin(); - p != this->entries_.end(); - ++p) - { - if (p->should_emit()) - p->emit(reloc_data); - } -} - // Track_relocs methods. // Initialize the class to track the relocs. This gets the object, @@ -1186,8 +1048,7 @@ Track_relocs<size, big_endian>::advance(off_t offset) return ret; } -// Instantiate the templates we need. We could use the configure -// script to restrict this to only the ones for implemented targets. +// Instantiate the templates we need. #ifdef HAVE_TARGET_32_LITTLE template @@ -1307,82 +1168,6 @@ class Symbol_value<64>; #ifdef HAVE_TARGET_32_LITTLE template -class Copy_relocs<32, false>; -#endif - -#ifdef HAVE_TARGET_32_BIG -template -class Copy_relocs<32, true>; -#endif - -#ifdef HAVE_TARGET_64_LITTLE -template -class Copy_relocs<64, false>; -#endif - -#ifdef HAVE_TARGET_64_BIG -template -class Copy_relocs<64, true>; -#endif - -#ifdef HAVE_TARGET_32_LITTLE -template -void -Copy_relocs<32, false>::emit<elfcpp::SHT_REL>( - Output_data_reloc<elfcpp::SHT_REL, true, 32, false>*); -#endif - -#ifdef HAVE_TARGET_32_BIG -template -void -Copy_relocs<32, true>::emit<elfcpp::SHT_REL>( - Output_data_reloc<elfcpp::SHT_REL, true, 32, true>*); -#endif - -#ifdef HAVE_TARGET_64_LITTLE -template -void -Copy_relocs<64, false>::emit<elfcpp::SHT_REL>( - Output_data_reloc<elfcpp::SHT_REL, true, 64, false>*); -#endif - -#ifdef HAVE_TARGET_64_BIG -template -void -Copy_relocs<64, true>::emit<elfcpp::SHT_REL>( - Output_data_reloc<elfcpp::SHT_REL, true, 64, true>*); -#endif - -#ifdef HAVE_TARGET_32_LITTLE -template -void -Copy_relocs<32, false>::emit<elfcpp::SHT_RELA>( - Output_data_reloc<elfcpp::SHT_RELA , true, 32, false>*); -#endif - -#ifdef HAVE_TARGET_32_BIG -template -void -Copy_relocs<32, true>::emit<elfcpp::SHT_RELA>( - Output_data_reloc<elfcpp::SHT_RELA, true, 32, true>*); -#endif - -#ifdef HAVE_TARGET_64_LITTLE -template -void -Copy_relocs<64, false>::emit<elfcpp::SHT_RELA>( - Output_data_reloc<elfcpp::SHT_RELA, true, 64, false>*); -#endif - -#ifdef HAVE_TARGET_64_BIG -template -void -Copy_relocs<64, true>::emit<elfcpp::SHT_RELA>( - Output_data_reloc<elfcpp::SHT_RELA, true, 64, true>*); -#endif - -#ifdef HAVE_TARGET_32_LITTLE -template class Track_relocs<32, false>; #endif |