From: Alan Modra Date: Thu, 17 Nov 2005 00:10:05 +0000 (+0000) Subject: * ldlang.h (lang_input_section_type): Remove "ifile" field. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7b986e992e1a3a388ee0ff0749749f063cc971a6;p=binutils-gdb.git * 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. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index 06c7815e5a7..68c2d5da59e 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,39 @@ +2005-11-17 Alan Modra + + * 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. + 2005-11-16 Alan Modra * ldlang.h (lang_output_section_statement_type): Add prev. diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em index 125f0494cdd..71498da1b33 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 0b06bc74208..220ba5900a3 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 0425d15b78b..d7d2f0e20a5 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 fc81e769186..82f37b69168 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 3d04773423e..4cdfcc21c75 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 bfc9c5a50d0..0a7d648bf1b 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 a4ed25d4462..bcd7e32be32 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 f64a3d2c2ed..ea337712ed1 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 de1d879742a..6773fb8bfd7 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. */ diff --git a/ld/ldemul.c b/ld/ldemul.c index 0ff11cebe08..fad1f184d59 100644 --- a/ld/ldemul.c +++ b/ld/ldemul.c @@ -121,10 +121,10 @@ ldemul_open_dynamic_archive (const char *arch, search_dirs_type *search, } bfd_boolean -ldemul_place_orphan (lang_input_statement_type *file, asection *s) +ldemul_place_orphan (asection *s) { if (ld_emulation->place_orphan) - return (*ld_emulation->place_orphan) (file, s); + return (*ld_emulation->place_orphan) (s); return FALSE; } diff --git a/ld/ldemul.h b/ld/ldemul.h index 44538d15a63..1b9b79b0676 100644 --- a/ld/ldemul.h +++ b/ld/ldemul.h @@ -54,7 +54,7 @@ extern void ldemul_set_symbols extern void ldemul_create_output_section_statements (void); extern bfd_boolean ldemul_place_orphan - (struct lang_input_statement_struct *, asection *); + (asection *); extern bfd_boolean ldemul_parse_args (int, char **); extern void ldemul_add_options @@ -147,7 +147,7 @@ typedef struct ld_emulation_xfer_struct { the default action should be taken. This field may be NULL, in which case the default action will always be taken. */ bfd_boolean (*place_orphan) - (struct lang_input_statement_struct *, asection *); + (asection *); /* Run after assigning parsing with the args, but before reading the script. Used to initialize symbols used in the script. */ diff --git a/ld/ldlang.c b/ld/ldlang.c index 198abba4bc7..6972b50fef7 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -1313,8 +1313,7 @@ output_prev_sec_find (lang_output_section_statement_type *os) } lang_output_section_statement_type * -lang_insert_orphan (lang_input_statement_type *file, - asection *s, +lang_insert_orphan (asection *s, const char *secname, lang_output_section_statement_type *after, struct orphan_save *place, @@ -1385,7 +1384,7 @@ lang_insert_orphan (lang_input_statement_type *file, if (add_child == NULL) add_child = &os->children; - lang_add_section (add_child, s, os, file); + lang_add_section (add_child, s, os); lang_leave_output_section_statement (0, "*default*", NULL, NULL); @@ -1811,8 +1810,7 @@ section_already_linked (bfd *abfd, asection *sec, void *data) void lang_add_section (lang_statement_list_type *ptr, asection *section, - lang_output_section_statement_type *output, - lang_input_statement_type *file) + lang_output_section_statement_type *output) { flagword flags = section->flags; bfd_boolean discard; @@ -1870,7 +1868,6 @@ lang_add_section (lang_statement_list_type *ptr, new = new_stat (lang_input_section, ptr); new->section = section; - new->ifile = file; section->output_section = output->bfd_section; flags = section->flags; @@ -2046,15 +2043,14 @@ wild_sort (lang_wild_statement_type *wild, fa = FALSE; } - if (ls->ifile->the_bfd != NULL - && bfd_my_archive (ls->ifile->the_bfd) != NULL) + if (bfd_my_archive (ls->section->owner) != NULL) { - ln = bfd_get_filename (bfd_my_archive (ls->ifile->the_bfd)); + ln = bfd_get_filename (bfd_my_archive (ls->section->owner)); la = TRUE; } else { - ln = ls->ifile->filename; + ln = ls->section->owner->filename; la = FALSE; } @@ -2069,7 +2065,7 @@ wild_sort (lang_wild_statement_type *wild, if (fa) fn = file->filename; if (la) - ln = ls->ifile->filename; + ln = ls->section->owner->filename; i = strcmp (fn, ln); if (i > 0) @@ -2115,8 +2111,7 @@ output_section_callback (lang_wild_statement_type *ptr, if (before == NULL) lang_add_section (&ptr->children, section, - (lang_output_section_statement_type *) output, - file); + (lang_output_section_statement_type *) output); else { lang_statement_list_type list; @@ -2124,8 +2119,7 @@ output_section_callback (lang_wild_statement_type *ptr, lang_list_init (&list); lang_add_section (&list, section, - (lang_output_section_statement_type *) output, - file); + (lang_output_section_statement_type *) output); /* If we are discarding the section, LIST.HEAD will be NULL. */ @@ -3903,7 +3897,8 @@ size_input_section lang_input_section_type *is = &((*this_ptr)->input_section); asection *i = is->section; - if (!is->ifile->just_syms_flag && (i->flags & SEC_EXCLUDE) == 0) + if (!((lang_input_statement_type *) i->owner->usrdata)->just_syms_flag + && (i->flags & SEC_EXCLUDE) == 0) { unsigned int alignment_needed; asection *o; @@ -5061,17 +5056,17 @@ lang_place_orphans (void) } lang_add_section (&default_common_section->children, s, - default_common_section, file); + default_common_section); } } - else if (ldemul_place_orphan (file, s)) + else if (ldemul_place_orphan (s)) ; else { lang_output_section_statement_type *os; os = lang_output_section_statement_lookup (s->name); - lang_add_section (&os->children, s, os, file); + lang_add_section (&os->children, s, os); } } } diff --git a/ld/ldlang.h b/ld/ldlang.h index 454a87c3b4e..1613541288a 100644 --- a/ld/ldlang.h +++ b/ld/ldlang.h @@ -285,8 +285,6 @@ typedef struct { lang_statement_header_type header; asection *section; - lang_input_statement_type *ifile; - } lang_input_section_type; typedef struct @@ -525,9 +523,8 @@ extern lang_output_section_statement_type *lang_output_section_find extern lang_output_section_statement_type *lang_output_section_find_by_flags (const asection *, lang_output_section_statement_type **exact); extern lang_output_section_statement_type *lang_insert_orphan - (lang_input_statement_type *, asection *, const char *, - lang_output_section_statement_type *, struct orphan_save *, - etree_type *, lang_statement_list_type *); + (asection *, const char *, lang_output_section_statement_type *, + struct orphan_save *, etree_type *, lang_statement_list_type *); extern lang_input_statement_type *lang_add_input_file (const char *, lang_input_file_enum_type, const char *); extern void lang_add_keepsyms_file @@ -564,7 +561,7 @@ extern void lang_leave_group (void); extern void lang_add_section (lang_statement_list_type *, asection *, - lang_output_section_statement_type *, lang_input_statement_type *); + lang_output_section_statement_type *); extern void lang_new_phdr (const char *, etree_type *, bfd_boolean, bfd_boolean, etree_type *, etree_type *); diff --git a/ld/ldwrite.c b/ld/ldwrite.c index d7bfab835c1..ee9d74a796d 100644 --- a/ld/ldwrite.c +++ b/ld/ldwrite.c @@ -218,43 +218,46 @@ build_link_order (lang_statement_union_type *statement) break; case lang_input_section_enum: - /* Create a new link_order in the output section with this - attached */ - if (!statement->input_section.ifile->just_syms_flag - && (statement->input_section.section->flags & SEC_EXCLUDE) == 0) - { - asection *i = statement->input_section.section; - asection *output_section = i->output_section; + { + /* Create a new link_order in the output section with this + attached */ + asection *i = statement->input_section.section; - ASSERT (output_section->owner == output_bfd); + if (!((lang_input_statement_type *) i->owner->usrdata)->just_syms_flag + && (i->flags & SEC_EXCLUDE) == 0) + { + asection *output_section = i->output_section; - if ((output_section->flags & SEC_HAS_CONTENTS) != 0 - || ((output_section->flags & SEC_LOAD) != 0 - && (output_section->flags & SEC_THREAD_LOCAL))) - { - struct bfd_link_order *link_order; + ASSERT (output_section->owner == output_bfd); - link_order = bfd_new_link_order (output_bfd, output_section); + if ((output_section->flags & SEC_HAS_CONTENTS) != 0 + || ((output_section->flags & SEC_LOAD) != 0 + && (output_section->flags & SEC_THREAD_LOCAL))) + { + struct bfd_link_order *link_order; - if (i->flags & SEC_NEVER_LOAD) - { - /* We've got a never load section inside one which - is going to be output, we'll change it into a - fill. */ - link_order->type = bfd_data_link_order; - link_order->u.data.contents = (unsigned char *) ""; - link_order->u.data.size = 1; - } - else - { - link_order->type = bfd_indirect_link_order; - link_order->u.indirect.section = i; - ASSERT (i->output_section == output_section); - } - link_order->size = i->size; - link_order->offset = i->output_offset; - } - } + link_order = bfd_new_link_order (output_bfd, output_section); + + if (i->flags & SEC_NEVER_LOAD) + { + /* We've got a never load section inside one which + is going to be output, we'll change it into a + fill. */ + link_order->type = bfd_data_link_order; + link_order->u.data.contents = (unsigned char *) ""; + link_order->u.data.size = 1; + } + else + { + link_order->type = bfd_indirect_link_order; + link_order->u.indirect.section = i; + ASSERT (i->output_section == output_section); + } + link_order->size = i->size; + link_order->offset = i->output_offset; + } + } + } break; case lang_padding_statement_enum: