aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2008-10-04 06:08:59 +0000
committerAlan Modra <amodra@gmail.com>2008-10-04 06:08:59 +0000
commit8a99a385a72553a657a1238d310f94bafad182be (patch)
tree900f06409b15b8c0b6a3fb6b6c1551c883b7e37f /ld/emultempl
parent2605c5df34a43fcbd60dcb4d974938022baae1ce (diff)
downloadfsf-binutils-gdb-8a99a385a72553a657a1238d310f94bafad182be.zip
fsf-binutils-gdb-8a99a385a72553a657a1238d310f94bafad182be.tar.gz
fsf-binutils-gdb-8a99a385a72553a657a1238d310f94bafad182be.tar.bz2
* ldemul.c (ldemul_place_orphan): Add "constraint" param.
* ldemul.h (ldemul_place_orphan): Update prototype. (struct ld_emulation_xfer_struct <place_orphan>): Likewise add param. * ldlang.c (unique_section_p): Make static. (lang_output_section_statement_lookup): Optimise creation of SPECIAL sections. (lang_insert_orphan): Add "constraint" param. Pass to lang_enter_output_section_statement. (init_os): Don't use an existing bfd section for SPECIAL sections. (lang_place_orphans): Don't rename unique output sections, instead mark their output section statements SPECIAL. * ldlang.h (lang_insert_orphan): Update prototype. (unique_section_p): Delete. * emultempl/beos.em (place_orphan): Add "constraint" param. * emultempl/elf32.em (place_orphan): Likewise. Don't match existing output sections if set. * emultempl/pe.em (place_orphan): Likewise. * emultempl/pep.em (place_orphan): Likewise. * emultempl/mmo.em (mmo_place_orphan): Update. * emultempl/spuelf.em (spu_place_special_section): Update.
Diffstat (limited to 'ld/emultempl')
-rw-r--r--ld/emultempl/beos.em6
-rw-r--r--ld/emultempl/elf32.em14
-rw-r--r--ld/emultempl/mmo.em8
-rw-r--r--ld/emultempl/pe.em12
-rw-r--r--ld/emultempl/pep.em12
-rw-r--r--ld/emultempl/spuelf.em2
6 files changed, 31 insertions, 23 deletions
diff --git a/ld/emultempl/beos.em b/ld/emultempl/beos.em
index 997f3a6..2777be8 100644
--- a/ld/emultempl/beos.em
+++ b/ld/emultempl/beos.em
@@ -665,7 +665,9 @@ gld_${EMULATION_NAME}_before_allocation (void)
which are not mentioned in the linker script. */
static bfd_boolean
-gld${EMULATION_NAME}_place_orphan (asection *s, const char *secname)
+gld${EMULATION_NAME}_place_orphan (asection *s,
+ const char *secname,
+ int constraint)
{
char *output_secname, *ps;
lang_output_section_statement_type *os;
@@ -694,7 +696,7 @@ gld${EMULATION_NAME}_place_orphan (asection *s, const char *secname)
output_secname = xstrdup (secname);
ps = strchr (output_secname + 1, '\$');
*ps = 0;
- os = lang_output_section_statement_lookup (output_secname, 0, TRUE);
+ os = lang_output_section_statement_lookup (output_secname, constraint, TRUE);
/* Find the '\$' wild statement for this section. We currently require the
linker script to explicitly mention "*(.foo\$)".
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 65ad4f1..7eb4e28 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -62,7 +62,8 @@ fragment <<EOF
static void gld${EMULATION_NAME}_before_parse (void);
static void gld${EMULATION_NAME}_after_open (void);
static void gld${EMULATION_NAME}_before_allocation (void);
-static bfd_boolean gld${EMULATION_NAME}_place_orphan (asection *, const char *);
+static bfd_boolean gld${EMULATION_NAME}_place_orphan
+ (asection *, const char *, int);
static void gld${EMULATION_NAME}_finish (void);
EOF
@@ -1635,7 +1636,9 @@ output_rel_find (asection *sec, int isdyn)
sections in the right segment. */
static bfd_boolean
-gld${EMULATION_NAME}_place_orphan (asection *s, const char *secname)
+gld${EMULATION_NAME}_place_orphan (asection *s,
+ const char *secname,
+ int constraint)
{
static struct orphan_save hold[] =
{
@@ -1705,9 +1708,8 @@ gld${EMULATION_NAME}_place_orphan (asection *s, const char *secname)
}
/* Look through the script to see where to place this section. */
- os = lang_output_section_find (secname);
-
- if (os != NULL
+ if (constraint == 0
+ && (os = lang_output_section_find (secname)) != NULL
&& os->bfd_section != NULL
&& (os->bfd_section->flags == 0
|| (_bfd_elf_match_sections_by_type (link_info.output_bfd,
@@ -1796,7 +1798,7 @@ gld${EMULATION_NAME}_place_orphan (asection *s, const char *secname)
after = &lang_output_section_statement.head->output_section_statement;
}
- lang_insert_orphan (s, secname, after, place, NULL, NULL);
+ lang_insert_orphan (s, secname, constraint, after, place, NULL, NULL);
return TRUE;
}
diff --git a/ld/emultempl/mmo.em b/ld/emultempl/mmo.em
index 8b02fd6..4ff9846 100644
--- a/ld/emultempl/mmo.em
+++ b/ld/emultempl/mmo.em
@@ -47,7 +47,9 @@ fragment <<EOF
from elf32.em. */
static bfd_boolean
-mmo_place_orphan (asection *s)
+mmo_place_orphan (asection *s,
+ const char *secname,
+ int constraint ATTRIBUTE_UNUSED)
{
static struct orphan_save hold_text =
{
@@ -56,7 +58,6 @@ mmo_place_orphan (asection *s)
0, 0, 0, 0
};
struct orphan_save *place;
- const char *secname;
lang_output_section_statement_type *after;
lang_output_section_statement_type *os;
@@ -66,7 +67,6 @@ mmo_place_orphan (asection *s)
return FALSE;
/* Only care for sections we're going to load. */
- secname = s->name;
os = lang_output_section_find (secname);
/* We have an output section by this name. Place the section inside it
@@ -93,7 +93,7 @@ mmo_place_orphan (asection *s)
/* If there's an output section by this name, we'll use it, regardless
of section flags, in contrast to what's done in elf32.em. */
- os = lang_insert_orphan (s, secname, after, place, NULL, NULL);
+ os = lang_insert_orphan (s, secname, 0, after, place, NULL, NULL);
/* We need an output section for .text as a root, so if there was none
(might happen with a peculiar linker script such as in "map
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index 89c521d..b014257 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -1613,7 +1613,9 @@ gld_${EMULATION_NAME}_finish (void)
sort_sections. */
static bfd_boolean
-gld_${EMULATION_NAME}_place_orphan (asection *s, const char *secname)
+gld_${EMULATION_NAME}_place_orphan (asection *s,
+ const char *secname,
+ int constraint)
{
const char *orig_secname = secname;
char *dollar = NULL;
@@ -1631,11 +1633,10 @@ gld_${EMULATION_NAME}_place_orphan (asection *s, const char *secname)
secname = newname;
}
- os = lang_output_section_find (secname);
-
lang_list_init (&add_child);
- if (os != NULL
+ if (constraint == 0
+ && (os = lang_output_section_find (secname)) != NULL
&& os->bfd_section != NULL
&& (os->bfd_section->flags == 0
|| ((s->flags ^ os->bfd_section->flags)
@@ -1721,7 +1722,8 @@ gld_${EMULATION_NAME}_place_orphan (asection *s, const char *secname)
/* All sections in an executable must be aligned to a page boundary. */
address = exp_unop (ALIGN_K, exp_nameop (NAME, "__section_alignment__"));
- os = lang_insert_orphan (s, secname, after, place, address, &add_child);
+ os = lang_insert_orphan (s, secname, constraint, after, place, address,
+ &add_child);
}
{
diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
index 4afac02..386c98f 100644
--- a/ld/emultempl/pep.em
+++ b/ld/emultempl/pep.em
@@ -1372,7 +1372,9 @@ gld_${EMULATION_NAME}_finish (void)
sort_sections. */
static bfd_boolean
-gld_${EMULATION_NAME}_place_orphan (asection *s, const char *secname)
+gld_${EMULATION_NAME}_place_orphan (asection *s,
+ const char *secname,
+ int constraint)
{
const char *orig_secname = secname;
char *dollar = NULL;
@@ -1390,11 +1392,10 @@ gld_${EMULATION_NAME}_place_orphan (asection *s, const char *secname)
secname = newname;
}
- os = lang_output_section_find (secname);
-
lang_list_init (&add_child);
- if (os != NULL
+ if (constraint == 0
+ && (os = lang_output_section_find (secname)) != NULL
&& os->bfd_section != NULL
&& (os->bfd_section->flags == 0
|| ((s->flags ^ os->bfd_section->flags)
@@ -1480,7 +1481,8 @@ gld_${EMULATION_NAME}_place_orphan (asection *s, const char *secname)
/* All sections in an executable must be aligned to a page boundary. */
address = exp_unop (ALIGN_K, exp_nameop (NAME, "__section_alignment__"));
- os = lang_insert_orphan (s, secname, after, place, address, &add_child);
+ os = lang_insert_orphan (s, secname, constraint, after, place, address,
+ &add_child);
}
{
diff --git a/ld/emultempl/spuelf.em b/ld/emultempl/spuelf.em
index bc2f6b5..fe248af 100644
--- a/ld/emultempl/spuelf.em
+++ b/ld/emultempl/spuelf.em
@@ -114,7 +114,7 @@ spu_place_special_section (asection *s, asection *o, const char *output_name)
os = lang_output_section_find (o != NULL ? o->name : output_name);
if (os == NULL)
- gld${EMULATION_NAME}_place_orphan (s, output_name);
+ gld${EMULATION_NAME}_place_orphan (s, output_name, 0);
else if (o != NULL && os->children.head != NULL)
{
lang_statement_list_type add;