Speedup mmo and pe orphan placement for relocatable link
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 2 Mar 2016 13:05:42 +0000 (05:05 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 2 Mar 2016 13:07:50 +0000 (05:07 -0800)
Since there is no need to place output sections in specific order for
relocatable link, we can skip merging flags of other input sections.

PR ld/19739
* emultempl/mmo.em (mmo_place_orphan): Don't merge flags of other
input sections for relocatable link.
* emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Likewise.
* emultempl/pep.em (gld_${EMULATION_NAME}_place_orphan): Likewise.

ld/ChangeLog
ld/emultempl/mmo.em
ld/emultempl/pe.em
ld/emultempl/pep.em

index 51061a810eb9e9efd30f08687dc036cbe3569d75..e27d5f011312b045064ca6d6eaad2db3e84ab076 100644 (file)
@@ -1,3 +1,17 @@
+2016-03-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/19739
+       * emultempl/mmo.em (mmo_place_orphan): Don't merge flags of other
+       input sections for relocatable link.
+       * emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Likewise.
+       * emultempl/pep.em (gld_${EMULATION_NAME}_place_orphan): Likewise.
+
+2016-03-01  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/19739
+       * ld/emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Don't
+       merge flags of other input sections for relocatable link.
+
 2016-03-01  H.J. Lu  <hongjiu.lu@intel.com>
 
        * testsuite/ld-plugin/lto.exp: Update PR ld/12365 test for GCC 6.
index c2dcc76ead31399a791e5a6cd8c5e4436552d5e7..b5a7aa02439d7568640f853010947790be58e388 100644 (file)
@@ -107,22 +107,28 @@ mmo_place_orphan (asection *s,
       return os;
     }
 
+  flags = s->flags;
+  if (!bfd_link_relocatable (&link_info))
+    {
+      nexts = s;
+      while ((nexts = bfd_get_next_section_by_name (nexts->owner, nexts))
+            != NULL)
+       if (nexts->output_section == NULL
+           && (nexts->flags & SEC_EXCLUDE) == 0
+           && ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0
+           && (nexts->owner->flags & DYNAMIC) == 0
+           && nexts->owner->usrdata != NULL
+           && !(((lang_input_statement_type *) nexts->owner->usrdata)
+                ->flags.just_syms))
+         flags = (((flags ^ SEC_READONLY) | (nexts->flags ^ SEC_READONLY))
+                  ^ SEC_READONLY);
+    }
+
   /* Check for matching section type flags for sections we care about.
      A section without contents can have SEC_LOAD == 0, but we still
      want it attached to a sane section so the symbols appear as
      expected.  */
-  flags = s->flags;
-  nexts = s;
-  while ((nexts = bfd_get_next_section_by_name (nexts->owner, nexts)) != NULL)
-    if (nexts->output_section == NULL
-       && (nexts->flags & SEC_EXCLUDE) == 0
-       && ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0
-       && (nexts->owner->flags & DYNAMIC) == 0
-       && nexts->owner->usrdata != NULL
-       && !(((lang_input_statement_type *) nexts->owner->usrdata)
-            ->flags.just_syms))
-      flags = (((flags ^ SEC_READONLY) | (nexts->flags ^ SEC_READONLY))
-              ^ SEC_READONLY);
+
   if ((flags & (SEC_ALLOC | SEC_READONLY)) != SEC_READONLY)
     for (i = 0; i < sizeof (holds) / sizeof (holds[0]); i++)
       if ((flags & holds[i].nonzero_flags) != 0)
index f15c6c415c2c2b41b3c4f9753c4a2fafd2f59767..2b78536df8996bc387c34c55c948b74224e7d8c9 100644 (file)
@@ -2225,21 +2225,27 @@ gld_${EMULATION_NAME}_place_orphan (asection *s,
          orphan_init_done = 1;
        }
 
+      flags = s->flags;
+      if (!bfd_link_relocatable (&link_info))
+       {
+         nexts = s;
+         while ((nexts = bfd_get_next_section_by_name (nexts->owner,
+                                                       nexts)))
+           if (nexts->output_section == NULL
+               && (nexts->flags & SEC_EXCLUDE) == 0
+               && ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0
+               && (nexts->owner->flags & DYNAMIC) == 0
+               && nexts->owner->usrdata != NULL
+               && !(((lang_input_statement_type *) nexts->owner->usrdata)
+                    ->flags.just_syms))
+             flags = (((flags ^ SEC_READONLY)
+                       | (nexts->flags ^ SEC_READONLY))
+                      ^ SEC_READONLY);
+       }
+
       /* Try to put the new output section in a reasonable place based
         on the section name and section flags.  */
 
-      flags = s->flags;
-      nexts = s;
-      while ((nexts = bfd_get_next_section_by_name (nexts->owner, nexts)))
-       if (nexts->output_section == NULL
-           && (nexts->flags & SEC_EXCLUDE) == 0
-           && ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0
-           && (nexts->owner->flags & DYNAMIC) == 0
-           && nexts->owner->usrdata != NULL
-           && !(((lang_input_statement_type *) nexts->owner->usrdata)
-                ->flags.just_syms))
-         flags = (((flags ^ SEC_READONLY) | (nexts->flags ^ SEC_READONLY))
-                  ^ SEC_READONLY);
       place = NULL;
       if ((flags & SEC_ALLOC) == 0)
        ;
index 054a98497f3c386adecd361612d4d1bbdc779049..ab7c473439a0cddf95e6ef2ca210759454348890 100644 (file)
@@ -1996,21 +1996,27 @@ gld_${EMULATION_NAME}_place_orphan (asection *s,
          orphan_init_done = 1;
        }
 
+      flags = s->flags;
+      if (!bfd_link_relocatable (&link_info))
+       {
+         nexts = s;
+         while ((nexts = bfd_get_next_section_by_name (nexts->owner,
+                                                       nexts)))
+           if (nexts->output_section == NULL
+               && (nexts->flags & SEC_EXCLUDE) == 0
+               && ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0
+               && (nexts->owner->flags & DYNAMIC) == 0
+               && nexts->owner->usrdata != NULL
+               && !(((lang_input_statement_type *) nexts->owner->usrdata)
+                    ->flags.just_syms))
+             flags = (((flags ^ SEC_READONLY)
+                       | (nexts->flags ^ SEC_READONLY))
+                      ^ SEC_READONLY);
+       }
+
       /* Try to put the new output section in a reasonable place based
         on the section name and section flags.  */
 
-      flags = s->flags;
-      nexts = s;
-      while ((nexts = bfd_get_next_section_by_name (nexts->owner, nexts)))
-       if (nexts->output_section == NULL
-           && (nexts->flags & SEC_EXCLUDE) == 0
-           && ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0
-           && (nexts->owner->flags & DYNAMIC) == 0
-           && nexts->owner->usrdata != NULL
-           && !(((lang_input_statement_type *) nexts->owner->usrdata)
-                ->flags.just_syms))
-         flags = (((flags ^ SEC_READONLY) | (nexts->flags ^ SEC_READONLY))
-                  ^ SEC_READONLY);
       place = NULL;
       if ((flags & SEC_ALLOC) == 0)
        ;