* emultempl/elf32.em (output_rel_find): Always place orphan loadable
authorAlan Modra <amodra@gmail.com>
Mon, 30 Sep 2002 03:34:46 +0000 (03:34 +0000)
committerAlan Modra <amodra@gmail.com>
Mon, 30 Sep 2002 03:34:46 +0000 (03:34 +0000)
reloc sections just before .rel.plt/.rela.plt.
(gld${EMULATION_NAME}_place_orphan <.rel>): Remove combreloc code.
Only put loadable reloc sections in hold_rel.

ld/ChangeLog
ld/emultempl/elf32.em

index 6bbe1effefc922d8fc097241dff7bf39743c82b3..8cba873e28244307078361fd5c7aaa54520c6a9d 100644 (file)
@@ -1,3 +1,10 @@
+2002-09-30  Alan Modra  <amodra@bigpond.net.au>
+
+       * emultempl/elf32.em (output_rel_find): Always place orphan loadable
+       reloc sections just before .rel.plt/.rela.plt.
+       (gld${EMULATION_NAME}_place_orphan <.rel>): Remove combreloc code.
+       Only put loadable reloc sections in hold_rel.
+
 2002-09-29  H.J. Lu <hjl@gnu.org>
 
        * ld/emulparams/elf32ppc.sh (OTHER_GOT_RELOC_SECTIONS): New.
index 26e4c46297f89742c5a358e2852ad8bc236f2f72..7f8637483bd78897c72e796b8e33d308bc872088 100644 (file)
@@ -1000,20 +1000,39 @@ output_rel_find ()
 {
   lang_statement_union_type *u;
   lang_output_section_statement_type *lookup;
+  lang_output_section_statement_type *last = NULL;
+  lang_output_section_statement_type *last_rel = NULL;
+  lang_output_section_statement_type *last_rel_alloc = NULL;
 
-  for (u = lang_output_section_statement.head;
-       u != (lang_statement_union_type *) NULL;
-       u = lookup->next)
+  for (u = lang_output_section_statement.head; u; u = lookup->next)
     {
       lookup = &u->output_section_statement;
-      if (strncmp (".rel", lookup->name, 4) == 0
-         && lookup->bfd_section != NULL
-         && (lookup->bfd_section->flags & SEC_ALLOC) != 0)
+      if (strncmp (".rel", lookup->name, 4) == 0)
        {
-         return lookup;
+         /* Don't place after .rel.plt as doing so results in wrong
+            dynamic tags.  Also, place allocated reloc sections before
+            non-allocated.  */
+         int rela = lookup->name[4] == 'a';
+
+         if (strcmp (".plt", lookup->name + 4 + rela) == 0
+             || (lookup->bfd_section != NULL
+                 && (lookup->bfd_section->flags & SEC_ALLOC) == 0))
+           break;
+         last_rel = lookup;
+         if (lookup->bfd_section != NULL
+             && (lookup->bfd_section->flags & SEC_ALLOC) != 0)
+           last_rel_alloc = lookup;
        }
+      last = lookup;
     }
-  return (lang_output_section_statement_type *) NULL;
+
+  if (last_rel_alloc)
+    return last_rel_alloc;
+
+  if (last_rel)
+    return last_rel;
+
+  return last;
 }
 
 /* Find the last output section before given output statement.
@@ -1138,27 +1157,10 @@ gld${EMULATION_NAME}_place_orphan (file, s)
           && HAVE_SECTION (hold_data, ".data"))
     place = &hold_data;
   else if (strncmp (secname, ".rel", 4) == 0
+          && (s->flags & SEC_LOAD) != 0
           && (hold_rel.os != NULL
               || (hold_rel.os = output_rel_find ()) != NULL))
-    {
-      if (! link_info.relocateable && link_info.combreloc)
-       {
-         if (strncmp (secname, ".rela", 5) == 0)
-           os = lang_output_section_find (".rela.dyn");
-         else
-           os = lang_output_section_find (".rel.dyn");
-
-         if (os != NULL
-             && os->bfd_section != NULL
-             && ((s->flags ^ os->bfd_section->flags)
-                 & (SEC_LOAD | SEC_ALLOC)) == 0)
-           {
-             lang_add_section (&os->children, s, os, file);
-             return true;
-           }
-       }
-      place = &hold_rel;
-    }
+    place = &hold_rel;
   else if ((s->flags & (SEC_CODE | SEC_READONLY)) == SEC_READONLY
           && HAVE_SECTION (hold_rodata, ".rodata"))
     place = &hold_rodata;
This page took 0.031741 seconds and 4 git commands to generate.