forked from Imagelibrary/binutils-gdb
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.
This commit is contained in:
38
ld/ldlang.c
38
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 ();
|
||||
|
||||
Reference in New Issue
Block a user