OSDN Git Service

* emultempl/elf32.em (struct orphan_save): Add os_tail field.
authoramodra <amodra>
Tue, 10 Dec 2002 03:34:42 +0000 (03:34 +0000)
committeramodra <amodra>
Tue, 10 Dec 2002 03:34:42 +0000 (03:34 +0000)
(gld${EMULATION_NAME}_place_orphan): Re-order output_section_statement
list too.

ld/ChangeLog
ld/emultempl/elf32.em

index 5d35770..74c9200 100644 (file)
@@ -1,3 +1,9 @@
+2002-12-10  Alan Modra  <amodra@bigpond.net.au>
+
+       * emultempl/elf32.em (struct orphan_save): Add os_tail field.
+       (gld${EMULATION_NAME}_place_orphan): Re-order output_section_statement
+       list too.
+
 2002-12-08  Alan Modra  <amodra@bigpond.net.au>
 
        * ldlang.h: Formatting.
index 06fdd81..b7c31fa 100644 (file)
@@ -1071,6 +1071,7 @@ struct orphan_save {
   lang_output_section_statement_type *os;
   asection **section;
   lang_statement_union_type **stmt;
+  lang_statement_union_type **os_tail;
 };
 
 static bfd_boolean
@@ -1093,6 +1094,7 @@ gld${EMULATION_NAME}_place_orphan (file, s)
   const char *secname;
   const char *ps = NULL;
   lang_output_section_statement_type *os;
+  lang_statement_union_type **os_tail;
   etree_type *load_base;
   int isdyn = 0;
 
@@ -1242,6 +1244,7 @@ gld${EMULATION_NAME}_place_orphan (file, s)
                             exp_nameop (ADDR, secname));
     }
 
+  os_tail = lang_output_section_statement.tail;
   os = lang_enter_output_section_statement (secname, address, 0,
                                            (bfd_vma) 0,
                                            (etree_type *) NULL,
@@ -1321,11 +1324,15 @@ gld${EMULATION_NAME}_place_orphan (file, s)
         read/write section before or amongst the read-only ones.  */
       if (add.head != NULL)
        {
+         lang_statement_union_type *newly_added_os;
+
          if (place->stmt == NULL)
            {
              /* Put the new statement list right at the head.  */
              *add.tail = place->os->header.next;
              place->os->header.next = add.head;
+
+             place->os_tail = &place->os->next;
            }
          else
            {
@@ -1341,6 +1348,21 @@ gld${EMULATION_NAME}_place_orphan (file, s)
 
          /* Save the end of this list.  */
          place->stmt = add.tail;
+
+         /* Do the same for the list of output section statements.  */
+         newly_added_os = *os_tail;
+         *os_tail = NULL;
+         newly_added_os->output_section_statement.next = *place->os_tail;
+         *place->os_tail = newly_added_os;
+         place->os_tail = &newly_added_os->output_section_statement.next;
+
+         /* Fixing the global list pointer here is a little different.
+            We added to the list in lang_enter_output_section_statement,
+            trimmed off the new output_section_statment above when
+            assigning *os_tail = NULL, but possibly added it back in
+            the same place when assigning *place->os_tail.  */
+         if (*os_tail == NULL)
+           lang_output_section_statement.tail = os_tail;
        }
     }