From 7b986e992e1a3a388ee0ff0749749f063cc971a6 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 17 Nov 2005 00:10:05 +0000 Subject: * ldlang.h (lang_input_section_type): Remove "ifile" field. (lang_insert_orphan, lang_add_section): Update prototypes. * ldlang.c (lang_insert_orphan): Remove "file" param. (lang_add_section): Likewise. Update all callers. (wild_sort): Get an input section's bfd via "section->owner". (size_input_section): Access just_syms_flag via bfd usrdata. (lang_place_orphans): Update ldemul_place_orphan call. * ldemul.h (ldemul_place_orphan): Remove input_statement param. (struct ld_emulation_xfer_struct ): Likewise. * ldemul.c (ldemul_place_orphan): Likewise. * ldwrite.c (build_link_order): Access just_syms_flag via bfd usrdata. * emultempl/armelf.em (arm_elf_set_bfd_for_interworking): Likewise. * emultempl/beos.em (sort_by_file_name): Access bfd by section->owner. (sort_sections): Likewise. (place_orphan): Remove "file" param. Adjust lang_add_section call. * emultempl/elf32.em (place_orphan): Remove "file" param. Adjust lang_add_section and lang_insert_orphan calls. * emultempl/hppaelf.em (hppaelf_add_stub_section): Adjust lang_add_section call. (build_section_lists): Access just_syms_flag via bfd usrdata. * emultempl/m68hc1xelf.em (m68hc11elf_add_stub_section): Adjust lang_add_section call. * emultempl/mmo.em (mmo_place_orphan): Remove "file" param. Adjust lang_add_section and lang_insert_orphan calls. * emultempl/pe.em (place_orphan): Likewise. Access bfd via section owner. * emultempl/ppc64elf.em (ppc_add_stub_section): Adjust lang_add_section call. (build_toc_list): Access just_syms_flag via bfd usrdata. (build_section_lists): Likewise. * emultempl/xtensaelf.em (elf_xtensa_place_orphan): Remove "file" param. Adjust place_orphan call. (ld_build_required_section_dependence): Access bfd via section owner. --- ld/emultempl/armelf.em | 31 +++++++++++++++++-------------- ld/emultempl/beos.em | 22 +++++++++++----------- ld/emultempl/elf32.em | 11 +++++------ ld/emultempl/hppaelf.em | 19 +++++++++++-------- ld/emultempl/m68hc1xelf.em | 2 +- ld/emultempl/mmo.em | 6 +++--- ld/emultempl/pe.em | 9 ++++----- ld/emultempl/ppc64elf.em | 35 +++++++++++++++++++++-------------- ld/emultempl/xtensaelf.em | 6 +++--- 9 files changed, 76 insertions(+), 65 deletions(-) (limited to 'ld/emultempl') diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em index 125f049..71498da 100644 --- a/ld/emultempl/armelf.em +++ b/ld/emultempl/armelf.em @@ -71,24 +71,27 @@ arm_elf_after_open (void) static void arm_elf_set_bfd_for_interworking (lang_statement_union_type *statement) { - if (statement->header.type == lang_input_section_enum - && !statement->input_section.ifile->just_syms_flag - && (statement->input_section.section->flags & SEC_EXCLUDE) == 0) + if (statement->header.type == lang_input_section_enum) { asection *i = statement->input_section.section; - asection *output_section = i->output_section; - ASSERT (output_section->owner == output_bfd); - - /* Don't attach the interworking stubs to a dynamic object, to - an empty section, etc. */ - if ((output_section->flags & SEC_HAS_CONTENTS) != 0 - && (i->flags & SEC_NEVER_LOAD) == 0 - && ! (i->owner->flags & DYNAMIC) - && ! i->owner->output_has_begun) + if (!((lang_input_statement_type *) i->owner->usrdata)->just_syms_flag + && (i->flags & SEC_EXCLUDE) == 0) { - bfd_for_interwork = i->owner; - bfd_for_interwork->output_has_begun = TRUE; + asection *output_section = i->output_section; + + ASSERT (output_section->owner == output_bfd); + + /* Don't attach the interworking stubs to a dynamic object, to + an empty section, etc. */ + if ((output_section->flags & SEC_HAS_CONTENTS) != 0 + && (i->flags & SEC_NEVER_LOAD) == 0 + && ! (i->owner->flags & DYNAMIC) + && ! i->owner->output_has_begun) + { + bfd_for_interwork = i->owner; + bfd_for_interwork->output_has_begun = TRUE; + } } } } diff --git a/ld/emultempl/beos.em b/ld/emultempl/beos.em index 0b06bc7..220ba59 100644 --- a/ld/emultempl/beos.em +++ b/ld/emultempl/beos.em @@ -397,13 +397,13 @@ sort_by_file_name (const void *a, const void *b) const lang_statement_union_type *const *rb = b; int i, a_sec, b_sec; - i = strcmp ((*ra)->input_section.ifile->the_bfd->my_archive->filename, - (*rb)->input_section.ifile->the_bfd->my_archive->filename); + i = strcmp ((*ra)->input_section.section->owner->my_archive->filename, + (*rb)->input_section.section->owner->my_archive->filename); if (i != 0) return i; - i = strcmp ((*ra)->input_section.ifile->filename, - (*rb)->input_section.ifile->filename); + i = strcmp ((*ra)->input_section.section->owner->filename, + (*rb)->input_section.section->owner->filename); if (i != 0) return i; /* the tail idata4/5 are the only ones without relocs to an @@ -427,15 +427,15 @@ sort_by_file_name (const void *a, const void *b) if ( (strcmp( (*ra)->input_section.section->name, ".idata$6") == 0) ) return 0; /* don't sort .idata$6 or .idata$7 FIXME dlltool eliminate .idata$7 */ - if (! bfd_get_section_contents ((*ra)->input_section.ifile->the_bfd, + if (! bfd_get_section_contents ((*ra)->input_section.section->owner, (*ra)->input_section.section, &a_sec, (file_ptr) 0, (bfd_size_type)sizeof(a_sec))) einfo ("%F%B: Can't read contents of section .idata: %E\n", - (*ra)->input_section.ifile->the_bfd); + (*ra)->input_section.section->owner); - if (! bfd_get_section_contents ((*rb)->input_section.ifile->the_bfd, + if (! bfd_get_section_contents ((*rb)->input_section.section->owner, (*rb)->input_section.section, &b_sec, (file_ptr) 0, (bfd_size_type)sizeof(b_sec) )) einfo ("%F%B: Can't read contents of section .idata: %E\n", - (*rb)->input_section.ifile->the_bfd); + (*rb)->input_section.section->owner); i = ((a_sec < b_sec) ? -1 : 0); if ( i != 0) @@ -547,7 +547,7 @@ sort_sections (lang_statement_union_type *s) { lang_statement_union_type *start = *p; if (start->header.type != lang_input_section_enum - || !start->input_section.ifile->the_bfd->my_archive) + || !start->input_section.section->owner->my_archive) p = &(start->header.next); else { @@ -662,7 +662,7 @@ gld_${EMULATION_NAME}_before_allocation (void) which are not mentioned in the linker script. */ static bfd_boolean -gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s) +gld${EMULATION_NAME}_place_orphan (asection *s) { const char *secname; char *output_secname, *ps; @@ -722,7 +722,7 @@ gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s) The sections still have to be sorted, but that has to wait until all such sections have been processed by us. The sorting is done by sort_sections. */ - lang_add_section (&l->wild_statement.children, s, os, file); + lang_add_section (&l->wild_statement.children, s, os); return TRUE; } diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 0425d15..d7d2f0e 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -59,8 +59,7 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 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 - (lang_input_statement_type *file, asection *s); +static bfd_boolean gld${EMULATION_NAME}_place_orphan (asection *s); static void gld${EMULATION_NAME}_layout_sections_again (void); static void gld${EMULATION_NAME}_finish (void) ATTRIBUTE_UNUSED; @@ -1283,7 +1282,7 @@ output_rel_find (asection *sec, int isdyn) sections in the right segment. */ static bfd_boolean -gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s) +gld${EMULATION_NAME}_place_orphan (asection *s) { static struct orphan_save hold[] = { @@ -1374,7 +1373,7 @@ gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s) If the section already exists but does not have any flags set, then it has been created by the linker, probably as a result of a --section-start command line switch. */ - lang_add_section (&os->children, s, os, file); + lang_add_section (&os->children, s, os); return TRUE; } } @@ -1400,7 +1399,7 @@ gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s) && hold[orphan_text].os != NULL) { lang_add_section (&hold[orphan_text].os->children, s, - hold[orphan_text].os, file); + hold[orphan_text].os); return TRUE; } @@ -1461,7 +1460,7 @@ gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s) einfo ("%F%P: place_orphan failed: %E\n"); } - lang_insert_orphan (file, s, secname, after, place, NULL, NULL); + lang_insert_orphan (s, secname, after, place, NULL, NULL); return TRUE; } diff --git a/ld/emultempl/hppaelf.em b/ld/emultempl/hppaelf.em index fc81e76..82f37b6 100644 --- a/ld/emultempl/hppaelf.em +++ b/ld/emultempl/hppaelf.em @@ -198,7 +198,7 @@ hppaelf_add_stub_section (const char *stub_sec_name, asection *input_section) info.input_section = input_section; lang_list_init (&info.add); - lang_add_section (&info.add, stub_sec, os, stub_file); + lang_add_section (&info.add, stub_sec, os); if (info.add.head == NULL) goto err_ret; @@ -229,14 +229,17 @@ hppaelf_layout_sections_again (void) static void build_section_lists (lang_statement_union_type *statement) { - if (statement->header.type == lang_input_section_enum - && !statement->input_section.ifile->just_syms_flag - && (statement->input_section.section->flags & SEC_EXCLUDE) == 0 - && statement->input_section.section->output_section != NULL - && statement->input_section.section->output_section->owner == output_bfd) + if (statement->header.type == lang_input_section_enum) { - elf32_hppa_next_input_section (&link_info, - statement->input_section.section); + asection *i = statement->input_section.section; + + if (!((lang_input_statement_type *) i->owner->usrdata)->just_syms_flag + && (i->flags & SEC_EXCLUDE) == 0 + && i->output_section != NULL + && i->output_section->owner == output_bfd) + { + elf32_hppa_next_input_section (&link_info, i); + } } } diff --git a/ld/emultempl/m68hc1xelf.em b/ld/emultempl/m68hc1xelf.em index 3d04773..4cdfcc2 100644 --- a/ld/emultempl/m68hc1xelf.em +++ b/ld/emultempl/m68hc1xelf.em @@ -272,7 +272,7 @@ m68hc11elf_add_stub_section (const char *stub_sec_name, at the correct place. */ info.input_section = tramp_section; lang_list_init (&info.add); - lang_add_section (&info.add, stub_sec, os, stub_file); + lang_add_section (&info.add, stub_sec, os); if (info.add.head == NULL) goto err_ret; diff --git a/ld/emultempl/mmo.em b/ld/emultempl/mmo.em index bfc9c5a..0a7d648 100644 --- a/ld/emultempl/mmo.em +++ b/ld/emultempl/mmo.em @@ -37,7 +37,7 @@ cat >>e${EMULATION_NAME}.c <children, s, os, file); + lang_add_section (&os->children, s, os); return TRUE; } @@ -83,7 +83,7 @@ mmo_place_orphan (lang_input_statement_type *file, 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 (file, s, secname, after, place, NULL, NULL); + os = lang_insert_orphan (s, secname, 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 a4ed25d..bcd7e32 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -1518,7 +1518,7 @@ gld_${EMULATION_NAME}_finish (void) sort_sections. */ static bfd_boolean -gld_${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s) +gld_${EMULATION_NAME}_place_orphan (asection *s) { const char *secname; const char *orig_secname; @@ -1555,7 +1555,7 @@ gld_${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s If the section already exists but does not have any flags set, then it has been created by the linker, probably as a result of a --section-start command line switch. */ - lang_add_section (&add_child, s, os, file); + lang_add_section (&add_child, s, os); } else { @@ -1641,8 +1641,7 @@ gld_${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s /* 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 (file, s, secname, after, place, address, - &add_child); + os = lang_insert_orphan (s, secname, after, place, address, &add_child); } { @@ -1665,7 +1664,7 @@ gld_${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s ls = &(*pl)->input_section; - lname = bfd_get_section_name (ls->ifile->the_bfd, ls->section); + lname = bfd_get_section_name (ls->section->owner, ls->section); if (strchr (lname, '$') == NULL) { if (found_dollar) diff --git a/ld/emultempl/ppc64elf.em b/ld/emultempl/ppc64elf.em index f64a3d2..ea33771 100644 --- a/ld/emultempl/ppc64elf.em +++ b/ld/emultempl/ppc64elf.em @@ -235,7 +235,7 @@ ppc_add_stub_section (const char *stub_sec_name, asection *input_section) info.input_section = input_section; lang_list_init (&info.add); - lang_add_section (&info.add, stub_sec, os, stub_file); + lang_add_section (&info.add, stub_sec, os); if (info.add.head == NULL) goto err_ret; @@ -277,26 +277,33 @@ gld${EMULATION_NAME}_after_allocation (void) static void build_toc_list (lang_statement_union_type *statement) { - if (statement->header.type == lang_input_section_enum - && !statement->input_section.ifile->just_syms_flag - && (statement->input_section.section->flags & SEC_EXCLUDE) == 0 - && statement->input_section.section->output_section == toc_section) - ppc64_elf_next_toc_section (&link_info, statement->input_section.section); + if (statement->header.type == lang_input_section_enum) + { + asection *i = statement->input_section.section; + + if (!((lang_input_statement_type *) i->owner->usrdata)->just_syms_flag + && (i->flags & SEC_EXCLUDE) == 0 + && i->output_section == toc_section) + ppc64_elf_next_toc_section (&link_info, i); + } } static void build_section_lists (lang_statement_union_type *statement) { - if (statement->header.type == lang_input_section_enum - && !statement->input_section.ifile->just_syms_flag - && (statement->input_section.section->flags & SEC_EXCLUDE) == 0 - && statement->input_section.section->output_section != NULL - && statement->input_section.section->output_section->owner == output_bfd) + if (statement->header.type == lang_input_section_enum) { - if (!ppc64_elf_next_input_section (&link_info, - statement->input_section.section)) - einfo ("%X%P: can not size stub section: %E\n"); + asection *i = statement->input_section.section; + + if (!((lang_input_statement_type *) i->owner->usrdata)->just_syms_flag + && (i->flags & SEC_EXCLUDE) == 0 + && i->output_section != NULL + && i->output_section->owner == output_bfd) + { + if (!ppc64_elf_next_input_section (&link_info, i)) + einfo ("%X%P: can not size stub section: %E\n"); + } } } diff --git a/ld/emultempl/xtensaelf.em b/ld/emultempl/xtensaelf.em index de1d879..6773fb8 100644 --- a/ld/emultempl/xtensaelf.em +++ b/ld/emultempl/xtensaelf.em @@ -59,13 +59,13 @@ elf_xtensa_choose_target (int argc ATTRIBUTE_UNUSED, static bfd_boolean -elf_xtensa_place_orphan (lang_input_statement_type *file, asection *s) +elf_xtensa_place_orphan (asection *s) { /* Early exit for relocatable links. */ if (link_info.relocatable) return FALSE; - return gld${EMULATION_NAME}_place_orphan (file, s); + return gld${EMULATION_NAME}_place_orphan (s); } @@ -1137,7 +1137,7 @@ ld_build_required_section_dependence (lang_statement_union_type *s) { lang_input_section_type *input; input = &l->input_section; - xtensa_callback_required_dependence (input->ifile->the_bfd, + xtensa_callback_required_dependence (input->section->owner, input->section, &link_info, /* Use the same closure. */ -- cgit v1.1