(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 <place_orphan>): 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-17 Alan Modra <amodra@bigpond.net.au>
+
+ * 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 <place_orphan>): 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 <amodra@bigpond.net.au>
* ldlang.h (lang_output_section_statement_type): Add prev.
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;
+ }
}
}
}
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
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)
{
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
{
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;
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;
}
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;
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[] =
{
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;
}
}
&& 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;
}
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;
}
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;
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);
+ }
}
}
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;
from elf32.em. */
static bfd_boolean
-mmo_place_orphan (lang_input_statement_type *file, asection *s)
+mmo_place_orphan (asection *s)
{
static struct orphan_save hold_text =
{
(regardless of whether the linker script lists it as input). */
if (os != NULL)
{
- lang_add_section (&os->children, s, os, file);
+ lang_add_section (&os->children, s, os);
return TRUE;
}
/* 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
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;
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
{
/* 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);
}
{
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)
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;
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");
+ }
}
}
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);
}
{
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. */
}
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;
}
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
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. */
}
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,
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);
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;
new = new_stat (lang_input_section, ptr);
new->section = section;
- new->ifile = file;
section->output_section = output->bfd_section;
flags = section->flags;
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;
}
if (fa)
fn = file->filename;
if (la)
- ln = ls->ifile->filename;
+ ln = ls->section->owner->filename;
i = strcmp (fn, ln);
if (i > 0)
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;
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. */
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;
}
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);
}
}
}
{
lang_statement_header_type header;
asection *section;
- lang_input_statement_type *ifile;
-
} lang_input_section_type;
typedef struct
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
(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 *);
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: