This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: orphan section logic


> iterates over sections that match the name..

Doh!  Of course it does.  New patch attached.  But is this the
functionality we want?  Or is it a user error to assume an input
section matches an output section just because the names match?

Index: emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.207
diff -p -U3 -r1.207 elf32.em
--- emultempl/elf32.em	11 Dec 2009 13:42:15 -0000	1.207
+++ emultempl/elf32.em	12 Jan 2010 03:42:13 -0000
@@ -1782,6 +1782,7 @@ gld${EMULATION_NAME}_place_orphan (asect
   struct orphan_save *place;
   lang_output_section_statement_type *after;
   lang_output_section_statement_type *os;
+  lang_output_section_statement_type *match_by_name = NULL;
   int isdyn = 0;
   int iself = s->owner->xvec->flavour == bfd_target_elf_flavour;
   unsigned int sh_type = iself ? elf_section_type (s) : SHT_NULL;
@@ -1837,8 +1838,21 @@ gld${EMULATION_NAME}_place_orphan (asect
 	    lang_add_section (&os->children, s, os);
 	    return os;
 	  }
+
+	/* Save unused output sections in case we can match them
+	   against orphans later.  */
+	if (os->bfd_section == NULL)
+	  match_by_name = os;
       }
 
+  /* If we didn't match an active output section, see if we matched an
+     unused one and use that.  */
+  if (match_by_name)
+    {
+      lang_add_section (&match_by_name->children, s, match_by_name);
+      return match_by_name;
+    }
+
   if (!orphan_init_done)
     {
       lang_output_section_statement_type *lookup;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]