]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Refactor Sized_relobj_file::do_relocate_sections.
authorCary Coutant <ccoutant@gmail.com>
Tue, 10 Jan 2017 15:46:30 +0000 (07:46 -0800)
committerAlan Modra <amodra@gmail.com>
Tue, 21 Feb 2017 23:10:24 +0000 (09:40 +1030)
gold/
* aarch64.cc (AArch64_relobj::do_relocate_sections): Call
Sized_relobj_file::relocate_section_range().
* arm.cc (Arm_relobj::do_relocate_sections): Likewise.
* object.h (Sized_relobj_file::relocate_section_range): New method.
* reloc.cc (Sized_relobj_file::do_relocate_sections): Move
implementation...
(Sized_relobj_file::relocate_section_range): ...to new method.

gold/ChangeLog
gold/aarch64.cc
gold/arm.cc
gold/object.h
gold/reloc.cc

index 879081115656e0a7c0b272f56f1dfdd81ffb9870..81d7ca12e3dfc478707215d362c5727cd46bb813 100644 (file)
@@ -1,6 +1,15 @@
 2017-02-22  Alan Modra  <amodra@gmail.com>
 
        Apply from master
+       2017-01-10  Cary Coutant  <ccoutant@gmail.com>
+       * aarch64.cc (AArch64_relobj::do_relocate_sections): Call
+       Sized_relobj_file::relocate_section_range().
+       * arm.cc (Arm_relobj::do_relocate_sections): Likewise.
+       * object.h (Sized_relobj_file::relocate_section_range): New method.
+       * reloc.cc (Sized_relobj_file::do_relocate_sections): Move
+       implementation...
+       (Sized_relobj_file::relocate_section_range): ...to new method.
+
        2017-01-10  Alan Modra  <amodra@gmail.com>
        * options.h: Add --secure-plt option.
        * powerpc.cc (Target_powerpc::Scan::local): Detect and error
index f31e0918d73db0542ccf4105a3b14b045f800142..96ed66e3ef7aadfe647b8316f9ab126e0252b258 100644 (file)
@@ -2044,9 +2044,9 @@ AArch64_relobj<size, big_endian>::do_relocate_sections(
     const unsigned char* pshdrs, Output_file* of,
     typename Sized_relobj_file<size, big_endian>::Views* pviews)
 {
-  // Call parent to relocate sections.
-  Sized_relobj_file<size, big_endian>::do_relocate_sections(symtab, layout,
-                                                           pshdrs, of, pviews);
+  // Relocate the section data.
+  this->relocate_section_range(symtab, layout, pshdrs, of, pviews,
+                              1, this->shnum() - 1);
 
   // We do not generate stubs if doing a relocatable link.
   if (parameters->options().relocatable())
index 9120279f83f261f8836bbf1238ac42d1f8956a2f..d9c0a2b20de127b7b41ac2deb8e5ab5209d9d423 100644 (file)
@@ -6555,9 +6555,9 @@ Arm_relobj<big_endian>::do_relocate_sections(
     Output_file* of,
     typename Sized_relobj_file<32, big_endian>::Views* pviews)
 {
-  // Call parent to relocate sections.
-  Sized_relobj_file<32, big_endian>::do_relocate_sections(symtab, layout,
-                                                         pshdrs, of, pviews);
+  // Relocate the section data.
+  this->relocate_section_range(symtab, layout, pshdrs, of, pviews,
+                              1, this->shnum() - 1);
 
   // We do not generate stubs if doing a relocatable link.
   if (parameters->options().relocatable())
index 95f6d56e0861b4b1a49c3a8844adb9b87c3e3c09..aa1a815f031679da83bfaa9b02e69a6b8b8869b2 100644 (file)
@@ -2562,6 +2562,13 @@ class Sized_relobj_file : public Sized_relobj<size, big_endian>
                       const unsigned char* pshdrs, Output_file* of,
                       Views* pviews);
 
+  // Relocate section data for a range of sections.
+  void
+  relocate_section_range(const Symbol_table* symtab, const Layout* layout,
+                        const unsigned char* pshdrs, Output_file* of,
+                        Views* pviews, unsigned int start_shndx,
+                        unsigned int end_shndx);
+
   // Adjust this local symbol value.  Return false if the symbol
   // should be discarded from the output file.
   virtual bool
index ca54f153a3f1ef6f28cab52711bd19bb44893786..8bbb07d39601506ded1832cf5a7e87fb5316e75d 100644 (file)
@@ -871,7 +871,30 @@ Sized_relobj_file<size, big_endian>::do_relocate_sections(
     Output_file* of,
     Views* pviews)
 {
-  unsigned int shnum = this->shnum();
+  this->relocate_section_range(symtab, layout, pshdrs, of, pviews,
+                              1, this->shnum() - 1);
+}
+
+// Relocate section data for the range of sections START_SHNDX through
+// END_SHNDX.
+
+template<int size, bool big_endian>
+void
+Sized_relobj_file<size, big_endian>::relocate_section_range(
+    const Symbol_table* symtab,
+    const Layout* layout,
+    const unsigned char* pshdrs,
+    Output_file* of,
+    Views* pviews,
+    unsigned int start_shndx,
+    unsigned int end_shndx)
+{
+  gold_assert(start_shndx >= 1);
+  gold_assert(end_shndx < this->shnum());
+
+  if (end_shndx < start_shndx)
+    return;
+
   Sized_target<size, big_endian>* target =
     parameters->sized_target<size, big_endian>();
 
@@ -883,8 +906,8 @@ Sized_relobj_file<size, big_endian>::do_relocate_sections(
   relinfo.layout = layout;
   relinfo.object = this;
 
-  const unsigned char* p = pshdrs + This::shdr_size;
-  for (unsigned int i = 1; i < shnum; ++i, p += This::shdr_size)
+  const unsigned char* p = pshdrs + start_shndx * This::shdr_size;
+  for (unsigned int i = start_shndx; i <= end_shndx; ++i, p += This::shdr_size)
     {
       typename This::Shdr shdr(p);
 
@@ -1717,6 +1740,17 @@ Sized_relobj_file<32, false>::do_relocate_sections(
     Output_file* of,
     Views* pviews);
 
+template
+void
+Sized_relobj_file<32, false>::relocate_section_range(
+    const Symbol_table* symtab,
+    const Layout* layout,
+    const unsigned char* pshdrs,
+    Output_file* of,
+    Views* pviews,
+    unsigned int start_shndx,
+    unsigned int end_shndx);
+
 template
 unsigned char*
 Sized_relobj_file<32, false>::do_get_output_view(
@@ -1734,6 +1768,17 @@ Sized_relobj_file<32, true>::do_relocate_sections(
     Output_file* of,
     Views* pviews);
 
+template
+void
+Sized_relobj_file<32, true>::relocate_section_range(
+    const Symbol_table* symtab,
+    const Layout* layout,
+    const unsigned char* pshdrs,
+    Output_file* of,
+    Views* pviews,
+    unsigned int start_shndx,
+    unsigned int end_shndx);
+
 template
 unsigned char*
 Sized_relobj_file<32, true>::do_get_output_view(
@@ -1751,6 +1796,17 @@ Sized_relobj_file<64, false>::do_relocate_sections(
     Output_file* of,
     Views* pviews);
 
+template
+void
+Sized_relobj_file<64, false>::relocate_section_range(
+    const Symbol_table* symtab,
+    const Layout* layout,
+    const unsigned char* pshdrs,
+    Output_file* of,
+    Views* pviews,
+    unsigned int start_shndx,
+    unsigned int end_shndx);
+
 template
 unsigned char*
 Sized_relobj_file<64, false>::do_get_output_view(
@@ -1768,6 +1824,17 @@ Sized_relobj_file<64, true>::do_relocate_sections(
     Output_file* of,
     Views* pviews);
 
+template
+void
+Sized_relobj_file<64, true>::relocate_section_range(
+    const Symbol_table* symtab,
+    const Layout* layout,
+    const unsigned char* pshdrs,
+    Output_file* of,
+    Views* pviews,
+    unsigned int start_shndx,
+    unsigned int end_shndx);
+
 template
 unsigned char*
 Sized_relobj_file<64, true>::do_get_output_view(