public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Doug Kwan (關振德)" <dougkwan@google.com>
To: Ian Lance Taylor <iant@google.com>,
	Sriraman Tallam <tmsriram@google.com>,
	       binutils <binutils@sourceware.org>
Subject: [PATCH][GOLD] Fix section ordering with --section-ordering-file in ARM.
Date: Thu, 28 Oct 2010 00:46:00 -0000	[thread overview]
Message-ID: <AANLkTimfA0waqa6EREg54iJE-pVVDnBfbvpe=9RuodMZ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 817 bytes --]

Hi,

   This patch fixes section ordering with the --section-ordering-file
option in gold.  The existing code drops section order indices when
converting normal input sections into relaxed input sections.  The
patch adds back code to maintain the indices in relaxed sections as
well.

-Doug


2010-10-27  Doug Kwan  <dougkwan@google.com>

        * arm.cc (Arm_outout_section::fix_exidx_coverage): Adjust call to
        Output_section::add_relaxed_input_section.
        * output.cc (Output_section::add_relaxed_input_section): Add new
        arguments LAYOUT and NAME.  Set section order index.
        (Output_section::convert_input_sections_in_list_to_relaxed_sections):
        Copy section order index.
        * output.h (Output_section::add_relaxed_input_section): Add new
        arguments LAYOUT and NAME.

[-- Attachment #2: patch-order.txt --]
[-- Type: text/plain, Size: 3462 bytes --]

Index: gold/arm.cc
===================================================================
RCS file: /cvs/src/src/gold/arm.cc,v
retrieving revision 1.125
diff -u -u -p -r1.125 arm.cc
--- gold/arm.cc	20 Oct 2010 15:30:54 -0000	1.125
+++ gold/arm.cc	28 Oct 2010 00:37:57 -0000
@@ -5847,7 +5847,8 @@ Arm_output_section<big_endian>::fix_exid
 	  Arm_exidx_merged_section* merged_section =
 	    new Arm_exidx_merged_section(*exidx_input_section,
 					 *section_offset_map, deleted_bytes);
-	  this->add_relaxed_input_section(merged_section);
+	  const std::string secname = exidx_relobj->section_name(exidx_shndx);
+	  this->add_relaxed_input_section(layout, merged_section, secname);
 	  arm_relobj->convert_input_section_to_relaxed_section(exidx_shndx);
 
 	  // All local symbols defined in discarded portions of this input
Index: gold/output.cc
===================================================================
RCS file: /cvs/src/src/gold/output.cc,v
retrieving revision 1.136
diff -u -u -p -r1.136 output.cc
--- gold/output.cc	18 Oct 2010 05:39:23 -0000	1.136
+++ gold/output.cc	28 Oct 2010 00:37:57 -0000
@@ -2203,9 +2203,25 @@ Output_section::add_output_section_data(
 // Add a relaxed input section.
 
 void
-Output_section::add_relaxed_input_section(Output_relaxed_input_section* poris)
+Output_section::add_relaxed_input_section(Layout* layout,
+					  Output_relaxed_input_section* poris,
+					  const std::string& name)
 {
   Input_section inp(poris);
+
+  // If the --section-ordering-file option is used to specify the order of
+  // sections, we need to keep track of sections.
+  if (parameters->options().section_ordering_file())
+    {
+      unsigned int section_order_index =
+        layout->find_section_order_index(name);
+      if (section_order_index != 0)
+        {
+          inp.set_section_order_index(section_order_index);
+          this->set_input_section_order_specified();
+        }
+    }
+
   this->add_output_section_data(&inp);
   if (this->lookup_maps_->is_valid())
     this->lookup_maps_->add_relaxed_input_section(poris->relobj(),
@@ -2373,7 +2389,13 @@ Output_section::convert_input_sections_i
       Relaxation_map::const_iterator p = map.find(sid);
       gold_assert(p != map.end());
       gold_assert((*input_sections)[p->second].is_input_section());
+
+      // Remember section order index of original input section
+      // if it is set.  Copy it to the relaxed input section.
+      unsigned int soi =
+	(*input_sections)[p->second].section_order_index();
       (*input_sections)[p->second] = Input_section(poris);
+      (*input_sections)[p->second].set_section_order_index(soi);
     }
 }
   
Index: gold/output.h
===================================================================
RCS file: /cvs/src/src/gold/output.h,v
retrieving revision 1.115
diff -u -u -p -r1.115 output.h
--- gold/output.h	18 Oct 2010 05:39:23 -0000	1.115
+++ gold/output.h	28 Oct 2010 00:37:57 -0000
@@ -2542,9 +2542,12 @@ class Output_section : public Output_dat
   void
   add_output_section_data(Output_section_data* posd);
 
-  // Add a relaxed input section PORIS to this output section.
+  // Add a relaxed input section PORIS called NAME to this output section
+  // with LAYOUT.
   void
-  add_relaxed_input_section(Output_relaxed_input_section* poris);
+  add_relaxed_input_section(Layout* layout,
+			    Output_relaxed_input_section* poris,
+			    const std::string& name);
 
   // Return the section name.
   const char*

             reply	other threads:[~2010-10-28  0:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-28  0:46 Doug Kwan (關振德) [this message]
2010-10-29 19:54 ` Ian Lance Taylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTimfA0waqa6EREg54iJE-pVVDnBfbvpe=9RuodMZ@mail.gmail.com' \
    --to=dougkwan@google.com \
    --cc=binutils@sourceware.org \
    --cc=iant@google.com \
    --cc=tmsriram@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).