]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Speedup orphan placement for relocatable link
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 29 Feb 2016 19:04:22 +0000 (11:04 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 4 Mar 2016 14:45:44 +0000 (06:45 -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.

Backport from master

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

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

index 887f43520f285fdd976fe13c4167936279beedb7..1ee2dfa392d19c5f11d188c6d0ce77c1bb1e2239 100644 (file)
@@ -1,3 +1,15 @@
+2016-03-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+       Backport from master
+       2016-03-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/19739
+       * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Don't
+       merge flags of other input sections for relocatable link.
+       * emultempl/mmo.em (mmo_place_orphan): Likewise.
+       * 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>
 
        Backport from master
index 0405d4fa71554a672e6b3070f3f310fec2244760..809b27c8bf7fb41ba0d9b7c5b9b275a7ae3f1e54 100644 (file)
@@ -1946,25 +1946,32 @@ gld${EMULATION_NAME}_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)
+           && _bfd_elf_match_sections_by_type (nexts->owner, nexts,
+                                               s->owner, s))
+         flags = (((flags ^ SEC_READONLY)
+                   | (nexts->flags ^ SEC_READONLY))
+                  ^ SEC_READONLY);
+    }
+
   /* Decide which segment the section should go in based on the
      section name and section flags.  We put loadable .note sections
      right after the .interp section, so that the PT_NOTE segment is
      stored right after the program headers where the OS can read it
      in the first page.  */
 
-  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)
-       && _bfd_elf_match_sections_by_type (nexts->owner, nexts, s->owner, s))
-      flags = (((flags ^ SEC_READONLY) | (nexts->flags ^ SEC_READONLY))
-              ^ SEC_READONLY);
   place = NULL;
   if ((flags & (SEC_ALLOC | SEC_DEBUGGING)) == 0)
     place = &hold[orphan_nonalloc];
index 8949aed13fa22a88c6feacd95d063998db7ff677..3a382ecb13f2f6b10f2b9ab5330e8e7b308e1574 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 0370c5a52637c4043e80963f4065ab13ee7f9a14..bddd9a8607d987888442ab99e1550799d87fb02a 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 91de50165d71765ee61179dbd4e1f6b3f6ebe486..5ddeffc9718c81806916a9c5b83d0280291aaeb5 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)
        ;