aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2010-01-14 04:56:12 +0000
committerDJ Delorie <dj@redhat.com>2010-01-14 04:56:12 +0000
commitb5f14a6dffb53245e454ebeb1a353a42d02dfc04 (patch)
treee1b66d5c9a817b328932a970ecb305ce71d3b3fc /ld/emultempl
parent62fb9fe1fcde9fd534fdc4f284257212804bb1fe (diff)
downloadgdb-b5f14a6dffb53245e454ebeb1a353a42d02dfc04.zip
gdb-b5f14a6dffb53245e454ebeb1a353a42d02dfc04.tar.gz
gdb-b5f14a6dffb53245e454ebeb1a353a42d02dfc04.tar.bz2
* emultempl/elf32.em (_place_orphan): If an input section doesn't
match an existing output section, but an unused output section statement does match, use it. * emultempl/pe.em (_place_orphan): Likewise. * emultempl/pep.em (_place_orphan): Likewise. * ld-elf/orphan4.d: New. * ld-elf/orphan4.ld: New. * ld-elf/orphan4.s: New.
Diffstat (limited to 'ld/emultempl')
-rw-r--r--ld/emultempl/elf32.em14
-rw-r--r--ld/emultempl/pe.em14
-rw-r--r--ld/emultempl/pep.em14
3 files changed, 42 insertions, 0 deletions
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 7215ff0..4fea6a9 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1782,6 +1782,7 @@ gld${EMULATION_NAME}_place_orphan (asection *s,
struct orphan_save *place;
lang_output_section_statement_type *after;
lang_output_section_statement_type *os;
+ lang_output_section_statement_type *match_by_name = NULL;
int isdyn = 0;
int iself = s->owner->xvec->flavour == bfd_target_elf_flavour;
unsigned int sh_type = iself ? elf_section_type (s) : SHT_NULL;
@@ -1837,8 +1838,21 @@ gld${EMULATION_NAME}_place_orphan (asection *s,
lang_add_section (&os->children, s, os);
return os;
}
+
+ /* Save unused output sections in case we can match them
+ against orphans later. */
+ if (os->bfd_section == NULL)
+ match_by_name = os;
}
+ /* If we didn't match an active output section, see if we matched an
+ unused one and use that. */
+ if (match_by_name)
+ {
+ lang_add_section (&match_by_name->children, s, match_by_name);
+ return match_by_name;
+ }
+
if (!orphan_init_done)
{
lang_output_section_statement_type *lookup;
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index b936199..79b30d3 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -1816,6 +1816,7 @@ gld_${EMULATION_NAME}_place_orphan (asection *s,
char *dollar = NULL;
lang_output_section_statement_type *os;
lang_statement_list_type add_child;
+ lang_output_section_statement_type *match_by_name = NULL;
lang_statement_union_type **pl;
/* Look through the script to see where to place this section. */
@@ -1854,8 +1855,21 @@ gld_${EMULATION_NAME}_place_orphan (asection *s,
lang_add_section (&add_child, s, os);
break;
}
+
+ /* Save unused output sections in case we can match them
+ against orphans later. */
+ if (os->bfd_section == NULL)
+ match_by_name = os;
}
+ /* If we didn't match an active output section, see if we matched an
+ unused one and use that. */
+ if (os == NULL && match_by_name)
+ {
+ lang_add_section (&match_by_name->children, s, match_by_name);
+ return match_by_name;
+ }
+
if (os == NULL)
{
static struct orphan_save hold[] =
diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
index 753f425..bcc959e 100644
--- a/ld/emultempl/pep.em
+++ b/ld/emultempl/pep.em
@@ -1582,6 +1582,7 @@ gld_${EMULATION_NAME}_place_orphan (asection *s,
char *dollar = NULL;
lang_output_section_statement_type *os;
lang_statement_list_type add_child;
+ lang_output_section_statement_type *match_by_name = NULL;
lang_statement_union_type **pl;
/* Look through the script to see where to place this section. */
@@ -1620,8 +1621,21 @@ gld_${EMULATION_NAME}_place_orphan (asection *s,
lang_add_section (&add_child, s, os);
break;
}
+
+ /* Save unused output sections in case we can match them
+ against orphans later. */
+ if (os->bfd_section == NULL)
+ match_by_name = os;
}
+ /* If we didn't match an active output section, see if we matched an
+ unused one and use that. */
+ if (os == NULL && match_by_name)
+ {
+ lang_add_section (&match_by_name->children, s, match_by_name);
+ return match_by_name;
+ }
+
if (os == NULL)
{
static struct orphan_save hold[] =