diff options
author | Cary Coutant <ccoutant@gmail.com> | 2015-12-11 14:01:22 -0800 |
---|---|---|
committer | Cary Coutant <ccoutant@gmail.com> | 2015-12-11 14:23:58 -0800 |
commit | 6b2353a53a621680dc839366f4b2b4f96eccb6da (patch) | |
tree | a28e925b00e104787ffcb6d2945ac8076fb72020 /gold/reloc.cc | |
parent | f1637ebed142eabd96cbc009edda8ec903c71fd6 (diff) | |
download | gdb-6b2353a53a621680dc839366f4b2b4f96eccb6da.zip gdb-6b2353a53a621680dc839366f4b2b4f96eccb6da.tar.gz gdb-6b2353a53a621680dc839366f4b2b4f96eccb6da.tar.bz2 |
Make output views accessible to Target during do_relocate().
gold/
* object.cc (Sized_relobj_file::Sized_relobj_file): Initialize
output_views_.
* object.h (Object::get_output_view): New function.
(Object::do_get_output_view): New function.
(Sized_relobj_file::do_get_output_view): New function.
(Sized_relobj_file::output_views_): New data member.
* reloc.cc: (Sized_relobj_file::do_relocate): Store pointer to
output views in class object.
(Sized_relobj_file::do_get_output_view): New function.
Diffstat (limited to 'gold/reloc.cc')
-rw-r--r-- | gold/reloc.cc | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/gold/reloc.cc b/gold/reloc.cc index f18f432..b83a962 100644 --- a/gold/reloc.cc +++ b/gold/reloc.cc @@ -665,6 +665,24 @@ Sized_relobj_file<size, big_endian>::do_relocate(const Symbol_table* symtab, // input offsets to output addresses. this->initialize_input_to_output_maps(); + // Make the views available through get_output_view() for the duration + // of this routine. This RAII class will reset output_views_ to NULL + // when the views go out of scope. + struct Set_output_views + { + Set_output_views(const Views** ppviews, const Views* pviews) + { + ppviews_ = ppviews; + *ppviews = pviews; + } + + ~Set_output_views() + { *ppviews_ = NULL; } + + const Views** ppviews_; + }; + Set_output_views set_output_views(&this->output_views_, &views); + // Apply relocations. this->relocate_sections(symtab, layout, pshdrs, of, &views); @@ -1040,6 +1058,21 @@ Sized_relobj_file<size, big_endian>::do_relocate_sections( } } +// Return the output view for section SHNDX. + +template<int size, bool big_endian> +const unsigned char* +Sized_relobj_file<size, big_endian>::do_get_output_view( + unsigned int shndx, + section_size_type* plen) const +{ + gold_assert(this->output_views_ != NULL); + gold_assert(shndx < this->output_views_->size()); + const View_size& v = (*this->output_views_)[shndx]; + *plen = v.view_size; + return v.view; +} + // Write the incremental relocs. template<int size, bool big_endian> @@ -1739,6 +1772,12 @@ Sized_relobj_file<32, false>::do_relocate_sections( const unsigned char* pshdrs, Output_file* of, Views* pviews); + +template +const unsigned char* +Sized_relobj_file<32, false>::do_get_output_view( + unsigned int shndx, + section_size_type* plen) const; #endif #ifdef HAVE_TARGET_32_BIG @@ -1750,6 +1789,12 @@ Sized_relobj_file<32, true>::do_relocate_sections( const unsigned char* pshdrs, Output_file* of, Views* pviews); + +template +const unsigned char* +Sized_relobj_file<32, true>::do_get_output_view( + unsigned int shndx, + section_size_type* plen) const; #endif #ifdef HAVE_TARGET_64_LITTLE @@ -1761,6 +1806,12 @@ Sized_relobj_file<64, false>::do_relocate_sections( const unsigned char* pshdrs, Output_file* of, Views* pviews); + +template +const unsigned char* +Sized_relobj_file<64, false>::do_get_output_view( + unsigned int shndx, + section_size_type* plen) const; #endif #ifdef HAVE_TARGET_64_BIG @@ -1772,6 +1823,12 @@ Sized_relobj_file<64, true>::do_relocate_sections( const unsigned char* pshdrs, Output_file* of, Views* pviews); + +template +const unsigned char* +Sized_relobj_file<64, true>::do_get_output_view( + unsigned int shndx, + section_size_type* plen) const; #endif #ifdef HAVE_TARGET_32_LITTLE |