aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2005-05-04 11:00:28 +0000
committerAlan Modra <amodra@gmail.com>2005-05-04 11:00:28 +0000
commit8423293d34986cfa218f79b2b2f1ff9bf77d468f (patch)
tree330cd698b1cb69439de3e3dc7add1d1af4812772 /ld
parent53e09e0aaf3d13e4b893744e2fe79edde7edfd20 (diff)
downloadfsf-binutils-gdb-8423293d34986cfa218f79b2b2f1ff9bf77d468f.zip
fsf-binutils-gdb-8423293d34986cfa218f79b2b2f1ff9bf77d468f.tar.gz
fsf-binutils-gdb-8423293d34986cfa218f79b2b2f1ff9bf77d468f.tar.bz2
bfd/
* section.c (struct bfd_section): Replace link_order_head and link_order_tail with map_head and map_tail union. (STD_SECTION): Update. (_bfd_strip_section_from_output): Delete. * aoutx.h: Update throughout for above changes. * coff-ppc.c: Likewise. * cofflink.c: Likewise. * ecoff.c: Likewise. * elf-eh-frame.c: Likewise. * elf-m10300.c: Likewise. * elf.c: Likewise. * elf32-arm.c: Likewise. * elf32-cris.c: Likewise. * elf32-hppa.c: Likewise. * elf32-i386.c: Likewise. * elf32-m32r.c: Likewise. * elf32-m68hc1x.c: Likewise. * elf32-m68k.c: Likewise. * elf32-ppc.c: Likewise. * elf32-s390.c: Likewise. * elf32-sh.c: Likewise. * elf32-vax.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-s390.c: Likewise. * elf64-sh64.c: Likewise. * elf64-x86-64.c: Likewise. * elflink.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elfxx-sparc.c: Likewise. * linker.c: Likewise. * merge.c: Likewise. * pdp11.c: Likewise. * xcofflink.c: Likewise. * elflink.c (bfd_boolean bfd_elf_size_dynsym_hash_dynstr): Split out from bfd_elf_size_dynamic_sections. * bfd-in.h (bfd_boolean bfd_elf_size_dynsym_hash_dynstr): Declare. * bfd-in2.h: Regenerate. ld/ * ldemul.c: Include bfdlink.h. (ldemul_before_allocation): Assume before_allocation is non-zero. (before_allocation_default): Call strip_excluded_output_sections. * ldlang.c (stripped_excluded_sections): New variable. (lang_add_section): Build input section list for each output section, attached via map_head and map_tail pointers. (strip_excluded_output_sections): Make global. Traverse the input section lists to find which output sections can go. Clear link_order pointers and set stripped_excluded_sections. (lang_process): Call strip_excluded_output_sections. * ldlang.h (strip_excluded_output_sections): Declare. * ldwrite.c: Update throuhout for link_order_head -> map_head change. * emultempl/aix.em (before_allocation): Call strip_excluded_output_sections. * emultempl/armcoff.em (before_allocation): Likewise. * emultempl/beos.em (before_allocation): Likewise. * emultempl/linux.em (before_allocation): Likewise. * emultempl/pe.em (before_allocation): Likewise. * emultempl/sunos.em (before_allocation): Likewise. * emultempl/elf32.em (before_allocation): Likewise. Call bfd_elf_size_dynsym_hash_dynstr too. * emultempl/lnk960.em (lnk960_before_allocation): Delete. (ld_lnk960): Use before_allocation_default.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog26
-rw-r--r--ld/emultempl/aix.em5
-rw-r--r--ld/emultempl/armcoff.em5
-rw-r--r--ld/emultempl/beos.em3
-rw-r--r--ld/emultempl/elf32.em7
-rw-r--r--ld/emultempl/linux.em4
-rw-r--r--ld/emultempl/lnk960.em7
-rw-r--r--ld/emultempl/m68kcoff.em2
-rw-r--r--ld/emultempl/pe.em3
-rw-r--r--ld/emultempl/sunos.em2
-rw-r--r--ld/ldemul.c8
-rw-r--r--ld/ldlang.c38
-rw-r--r--ld/ldlang.h2
-rw-r--r--ld/ldwrite.c12
14 files changed, 99 insertions, 25 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 938f62e..2448124 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,29 @@
+2005-05-04 Alan Modra <amodra@bigpond.net.au>
+
+ * ldemul.c: Include bfdlink.h.
+ (ldemul_before_allocation): Assume before_allocation is non-zero.
+ (before_allocation_default): Call strip_excluded_output_sections.
+ * ldlang.c (stripped_excluded_sections): New variable.
+ (lang_add_section): Build input section list for each output
+ section, attached via map_head and map_tail pointers.
+ (strip_excluded_output_sections): Make global. Traverse the
+ input section lists to find which output sections can go. Clear
+ link_order pointers and set stripped_excluded_sections.
+ (lang_process): Call strip_excluded_output_sections.
+ * ldlang.h (strip_excluded_output_sections): Declare.
+ * ldwrite.c: Update throuhout for link_order_head -> map_head change.
+ * emultempl/aix.em (before_allocation): Call
+ strip_excluded_output_sections.
+ * emultempl/armcoff.em (before_allocation): Likewise.
+ * emultempl/beos.em (before_allocation): Likewise.
+ * emultempl/linux.em (before_allocation): Likewise.
+ * emultempl/pe.em (before_allocation): Likewise.
+ * emultempl/sunos.em (before_allocation): Likewise.
+ * emultempl/elf32.em (before_allocation): Likewise. Call
+ bfd_elf_size_dynsym_hash_dynstr too.
+ * emultempl/lnk960.em (lnk960_before_allocation): Delete.
+ (ld_lnk960): Use before_allocation_default.
+
2005-05-02 H.J. Lu <hongjiu.lu@intel.com>
* emultempl/elf32.em (gld${EMULATION_NAME}_strip_empty_section):
diff --git a/ld/emultempl/aix.em b/ld/emultempl/aix.em
index c37cadf..480a3c6 100644
--- a/ld/emultempl/aix.em
+++ b/ld/emultempl/aix.em
@@ -10,7 +10,7 @@ cat >e${EMULATION_NAME}.c <<EOF
/* AIX emulation code for ${EMULATION_NAME}
Copyright 1991, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004
+ 2003, 2004, 2005
Free Software Foundation, Inc.
Written by Steve Chamberlain <sac@cygnus.com>
AIX support by Ian Lance Taylor <ian@cygnus.com>
@@ -787,6 +787,9 @@ gld${EMULATION_NAME}_before_allocation (void)
&is->header.next);
}
}
+
+ if (!link_info.relocatable)
+ strip_excluded_output_sections ();
}
static char *
diff --git a/ld/emultempl/armcoff.em b/ld/emultempl/armcoff.em
index 468c3b0..3dc8ee0 100644
--- a/ld/emultempl/armcoff.em
+++ b/ld/emultempl/armcoff.em
@@ -5,7 +5,7 @@ cat >e${EMULATION_NAME}.c <<EOF
/* emulate the original gld for the given ${EMULATION_NAME}
Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
- 2004 Free Software Foundation, Inc.
+ 2004, 2005 Free Software Foundation, Inc.
Written by Steve Chamberlain steve@cygnus.com
This file is part of GLD, the Gnu Linker.
@@ -125,6 +125,9 @@ gld${EMULATION_NAME}_before_allocation (void)
/* We have seen it all. Allocate it, and carry on */
bfd_arm_allocate_interworking_sections (& link_info);
+
+ if (!link_info.relocatable)
+ strip_excluded_output_sections ();
}
static void
diff --git a/ld/emultempl/beos.em b/ld/emultempl/beos.em
index 679fd81..2d4491f 100644
--- a/ld/emultempl/beos.em
+++ b/ld/emultempl/beos.em
@@ -661,6 +661,9 @@ gld_${EMULATION_NAME}_before_allocation (void)
#endif /* TARGET_IS_ppcpe */
sort_sections (stat_ptr->head);
+
+ if (!link_info.relocatable)
+ strip_excluded_output_sections ();
}
/* Place an orphan section. We use this to put sections with a '\$' in them
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 2e1dac1..641cd63 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1069,6 +1069,7 @@ gld${EMULATION_NAME}_before_allocation (void)
(const char * const *) command_line.auxiliary_filters,
&link_info, &sinterp, lang_elf_version_info)))
einfo ("%P%F: failed to set dynamic section sizes: %E\n");
+
${ELF_INTERPRETER_SET_DEFAULT}
/* Let the user override the dynamic linker we are using. */
if (command_line.interpreter != NULL
@@ -1125,6 +1126,12 @@ ${ELF_INTERPRETER_SET_DEFAULT}
s->flags |= SEC_EXCLUDE;
}
}
+
+ if (!link_info.relocatable)
+ strip_excluded_output_sections ();
+
+ if (!bfd_elf_size_dynsym_hash_dynstr (output_bfd, &link_info))
+ einfo ("%P%F: failed to set dynamic section sizes: %E\n");
}
EOF
diff --git a/ld/emultempl/linux.em b/ld/emultempl/linux.em
index 0d2dc5d..32a445c 100644
--- a/ld/emultempl/linux.em
+++ b/ld/emultempl/linux.em
@@ -10,7 +10,7 @@ cat >e${EMULATION_NAME}.c <<EOF
/* Linux a.out emulation code for ${EMULATION_NAME}
Copyright 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004 Free Software Foundation, Inc.
+ 2003, 2004, 2005 Free Software Foundation, Inc.
Written by Steve Chamberlain <sac@cygnus.com>
Linux support by Eric Youngdale <ericy@cais.cais.com>
@@ -121,6 +121,8 @@ gld${EMULATION_NAME}_before_allocation (void)
dynamic linking. */
if (! bfd_${EMULATION_NAME}_size_dynamic_sections (output_bfd, &link_info))
einfo ("%P%F: failed to set dynamic section sizes: %E\n");
+
+ strip_excluded_output_sections ();
}
static char *
diff --git a/ld/emultempl/lnk960.em b/ld/emultempl/lnk960.em
index 7d9176e..b58efcc 100644
--- a/ld/emultempl/lnk960.em
+++ b/ld/emultempl/lnk960.em
@@ -130,11 +130,6 @@ lnk960_after_parse (void)
}
static void
-lnk960_before_allocation (void)
-{
-}
-
-static void
lnk960_after_allocation (void)
{
if (!link_info.relocatable)
@@ -273,7 +268,7 @@ struct ld_emulation_xfer_struct ld_lnk960_emulation =
lnk960_after_allocation,
lnk960_set_output_arch,
lnk960_choose_target,
- lnk960_before_allocation,
+ before_allocation_default,
lnk960_get_script,
"lnk960",
"",
diff --git a/ld/emultempl/m68kcoff.em b/ld/emultempl/m68kcoff.em
index ba251c1..2d04ead 100644
--- a/ld/emultempl/m68kcoff.em
+++ b/ld/emultempl/m68kcoff.em
@@ -4,7 +4,7 @@ cat >e${EMULATION_NAME}.c <<EOF
/* This file is is generated by a shell script. DO NOT EDIT! */
/* Handle embedded relocs for m68k.
- Copyright 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Written by Michael Sokolov <msokolov@ivan.Harhan.ORG>, based on generic.em
by Steve Chamberlain <steve@cygnus.com>, embedded relocs code based on
mipsecoff.em by Ian Lance Taylor <ian@cygnus.com>.
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index 16cc437..f2b5c03 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -1287,6 +1287,9 @@ gld_${EMULATION_NAME}_before_allocation (void)
/* We have seen it all. Allocate it, and carry on. */
bfd_arm_pe_allocate_interworking_sections (& link_info);
#endif /* TARGET_IS_armpe */
+
+ if (!link_info.relocatable)
+ strip_excluded_output_sections ();
}
#ifdef DLL_SUPPORT
diff --git a/ld/emultempl/sunos.em b/ld/emultempl/sunos.em
index a84959f..f5595dd 100644
--- a/ld/emultempl/sunos.em
+++ b/ld/emultempl/sunos.em
@@ -809,6 +809,8 @@ gld${EMULATION_NAME}_before_allocation (void)
hdyn->u.def.section = sdyn;
else
hdyn->u.def.section = bfd_abs_section_ptr;
+
+ strip_excluded_output_sections ();
}
}
diff --git a/ld/ldemul.c b/ld/ldemul.c
index abd48fe..10cb07c 100644
--- a/ld/ldemul.c
+++ b/ld/ldemul.c
@@ -1,6 +1,6 @@
/* ldemul.c -- clearing house for ld emulation states
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003
+ 2001, 2002, 2003, 2005
Free Software Foundation, Inc.
This file is part of GLD, the Gnu Linker.
@@ -24,6 +24,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "bfd.h"
#include "sysdep.h"
#include "getopt.h"
+#include "bfdlink.h"
#include "ld.h"
#include "ldmisc.h"
@@ -75,8 +76,7 @@ ldemul_after_allocation (void)
void
ldemul_before_allocation (void)
{
- if (ld_emulation->before_allocation)
- ld_emulation->before_allocation ();
+ ld_emulation->before_allocation ();
}
void
@@ -212,6 +212,8 @@ after_allocation_default (void)
void
before_allocation_default (void)
{
+ if (!link_info.relocatable)
+ strip_excluded_output_sections ();
}
void
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 895eded..453b7ac 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -54,6 +54,7 @@ static struct obstack map_obstack;
static const char *startup_file;
static lang_statement_list_type input_file_chain;
static bfd_boolean placed_commons = FALSE;
+static bfd_boolean stripped_excluded_sections = FALSE;
static lang_output_section_statement_type *default_common_section;
static bfd_boolean map_option_f;
static bfd_vma print_dot;
@@ -1721,6 +1722,19 @@ lang_add_section (lang_statement_list_type *ptr,
first = ! output->bfd_section->linker_has_input;
output->bfd_section->linker_has_input = 1;
+ if (!link_info.relocatable
+ && !stripped_excluded_sections)
+ {
+ asection *s = output->bfd_section->map_tail.s;
+ output->bfd_section->map_tail.s = section;
+ section->map_head.s = NULL;
+ section->map_tail.s = s;
+ if (s != NULL)
+ s->map_head.s = section;
+ else
+ output->bfd_section->map_head.s = section;
+ }
+
/* Add a section reference to the list. */
new = new_stat (lang_input_section, ptr);
@@ -3029,7 +3043,7 @@ map_input_to_output_sections
added. For example, ldemul_before_allocation can remove dynamic
sections if they turn out to be not needed. Clean them up here. */
-static void
+void
strip_excluded_output_sections (void)
{
lang_output_section_statement_type *os;
@@ -3042,9 +3056,20 @@ strip_excluded_output_sections (void)
if (os->constraint == -1)
continue;
- s = os->bfd_section;
- if (s != NULL && (s->flags & SEC_EXCLUDE) != 0)
+
+ if (os->bfd_section == NULL || os->bfd_section->map_head.s == NULL)
+ continue;
+
+ for (s = os->bfd_section->map_head.s; s != NULL; s = s->map_head.s)
+ if ((s->flags & SEC_EXCLUDE) == 0)
+ break;
+
+ os->bfd_section->map_head.link_order = NULL;
+ os->bfd_section->map_tail.link_order = NULL;
+
+ if (s == NULL)
{
+ s = os->bfd_section;
os->bfd_section = NULL;
if (!bfd_section_removed_from_list (output_bfd, s))
{
@@ -3053,6 +3078,10 @@ strip_excluded_output_sections (void)
}
}
}
+
+ /* Stop future calls to lang_add_section from messing with map_head
+ and map_tail link_order fields. */
+ stripped_excluded_sections = TRUE;
}
static void
@@ -5226,9 +5255,6 @@ lang_process (void)
and other back-ends size dynamic sections. */
ldemul_before_allocation ();
- if (!link_info.relocatable)
- strip_excluded_output_sections ();
-
/* We must record the program headers before we try to fix the
section positions, since they will affect SIZEOF_HEADERS. */
lang_record_phdrs ();
diff --git a/ld/ldlang.h b/ld/ldlang.h
index 2cf8259..7fca8b0 100644
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -549,6 +549,8 @@ extern void lang_for_each_statement
(void (*) (lang_statement_union_type *));
extern void *stat_alloc
(size_t);
+extern void strip_excluded_output_sections
+ (void);
extern void dprint_statement
(lang_statement_union_type *, int);
extern bfd_vma lang_size_sections
diff --git a/ld/ldwrite.c b/ld/ldwrite.c
index 56c4d0a..5538c65 100644
--- a/ld/ldwrite.c
+++ b/ld/ldwrite.c
@@ -378,7 +378,7 @@ clone_section (bfd *abfd, asection *s, const char *name, int *count)
static void
ds (asection *s)
{
- struct bfd_link_order *l = s->link_order_head;
+ struct bfd_link_order *l = s->map_head.link_order;
printf ("vma %x size %x\n", s->vma, s->size);
while (l)
{
@@ -410,7 +410,7 @@ sanity_check (bfd *abfd)
{
struct bfd_link_order *p;
bfd_vma prev = 0;
- for (p = s->link_order_head; p; p = p->next)
+ for (p = s->map_head.link_order; p; p = p->next)
{
if (p->offset > 100000)
abort ();
@@ -447,7 +447,7 @@ split_sections (bfd *abfd, struct bfd_link_info *info)
/* Count up the relocations and line entries to see if anything
would be too big to fit. Accumulate section size too. */
- for (l = NULL, p = cursor->link_order_head; p != NULL; p = l->next)
+ for (l = NULL, p = cursor->map_head.link_order; p != NULL; p = l->next)
{
unsigned int thislines = 0;
unsigned int thisrelocs = 0;
@@ -488,9 +488,9 @@ split_sections (bfd *abfd, struct bfd_link_info *info)
/* Attach the link orders to the new section and snip
them off from the old section. */
- n->link_order_head = p;
- n->link_order_tail = cursor->link_order_tail;
- cursor->link_order_tail = l;
+ n->map_head.link_order = p;
+ n->map_tail.link_order = cursor->map_tail.link_order;
+ cursor->map_tail.link_order = l;
l->next = NULL;
l = p;