summaryrefslogtreecommitdiff
path: root/ld/emultempl
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2016-03-02 05:05:42 -0800
committerH.J. Lu <hjl.tools@gmail.com>2016-03-02 05:07:50 -0800
commit523f4c9234439fd6ccc0dd2c3b387331dd64c54b (patch)
treeb05e390abf459b9a34281e09c364b7e5f229d26c /ld/emultempl
parentc697cf0b2b85cb1231e2c76c52cfed43770aa04a (diff)
downloadbinutils-gdb-523f4c9234439fd6ccc0dd2c3b387331dd64c54b.tar.gz
Speedup mmo and pe orphan placement for relocatable link
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.
Diffstat (limited to 'ld/emultempl')
-rw-r--r--ld/emultempl/mmo.em30
-rw-r--r--ld/emultempl/pe.em30
-rw-r--r--ld/emultempl/pep.em30
3 files changed, 54 insertions, 36 deletions
diff --git a/ld/emultempl/mmo.em b/ld/emultempl/mmo.em
index c2dcc76ead3..b5a7aa02439 100644
--- a/ld/emultempl/mmo.em
+++ b/ld/emultempl/mmo.em
@@ -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)
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index f15c6c415c2..2b78536df89 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -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)
;
diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
index 054a98497f3..ab7c473439a 100644
--- a/ld/emultempl/pep.em
+++ b/ld/emultempl/pep.em
@@ -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)
;