+2015-12-11 Cary Coutant <ccoutant@gmail.com>
+
+ * 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.
+
2015-12-10 H.J. Lu <hongjiu.lu@intel.com>
PR ld/19317
discarded_eh_frame_shndx_(-1U),
is_deferred_layout_(false),
deferred_layout_(),
- deferred_layout_relocs_()
+ deferred_layout_relocs_(),
+ output_views_(NULL)
{
this->e_type_ = ehdr.get_e_type();
}
get_incremental_reloc_count(unsigned int symndx) const
{ return this->do_get_incremental_reloc_count(symndx); }
+ // Return the output view for section SHNDX.
+ const unsigned char*
+ get_output_view(unsigned int shndx, section_size_type* plen) const
+ { return this->do_get_output_view(shndx, plen); }
+
protected:
// Returns NULL for Objects that are not dynamic objects. This method
// is overridden in the Dynobj class.
do_get_incremental_reloc_count(unsigned int) const
{ gold_unreachable(); }
+ // Return the output view for a section.
+ virtual const unsigned char*
+ do_get_output_view(unsigned int, section_size_type*) const
+ { gold_unreachable(); }
+
void
set_compressed_sections(Compressed_section_map* compressed_sections)
{ this->compressed_sections_ = compressed_sections; }
set_output_local_symbol_count(unsigned int value)
{ this->output_local_symbol_count_ = value; }
+ // Return the output view for a section.
+ const unsigned char*
+ do_get_output_view(unsigned int, section_size_type*) const;
+
private:
// For convenience.
typedef Sized_relobj_file<size, big_endian> This;
std::vector<Deferred_layout> deferred_layout_;
// The list of relocation sections whose layout was deferred.
std::vector<Deferred_layout> deferred_layout_relocs_;
+ // Pointer to the list of output views; valid only during do_relocate().
+ const Views* output_views_;
};
// A class to manage the list of all objects.
// 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);
}
}
+// 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>
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
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
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
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