(lang_input_statement_type): ..here. New field "flags".
(input_flags): Declare.
(missing_file): Delete.
* ldmain.h (whole_archive): Delete.
(add_DT_NEEDED_for_regular, add_DT_NEEDED_for_dynamic): Delete.
* ld.h (ld_config_type <dynamic_link>): Delete.
* ldmain.c (whole_archive): Delete.
(add_DT_NEEDED_for_regular, add_DT_NEEDED_for_dynamic): Delete.
* ldlang.c (missing_file, ldlang_sysrooted_script): Delete.
(input_flags): New variable. Replace all uses of config.dynamic_link,
missing_file, ldlang_sysrooted_script, whole_archive,
add_DT_NEEDED_for_regular and add_DT_NEEDED_for_dynamic with fields
from here.
* ldfile.c: Likewise.
* ldgram.y: Likewise.
* ldmain.c: Likewise.
* ldwrite.c: Likewise.
* lexsup.c: Likewise.
* plugin.c: Likewise.
* emultempl/aix.em: Likewise.
* emultempl/armelf.em: Likewise.
* emultempl/elf32.em: Likewise.
* emultempl/hppaelf.em: Likewise.
* emultempl/linux.em: Likewise.
* emultempl/pe.em: Likewise.
* emultempl/pep.em: Likewise.
* emultempl/ppc64elf.em: Likewise.
* emultempl/scoreelf.em: Likewise.
* emultempl/spuelf.em: Likewise.
* emultempl/sunos.em: Likewise.
* emultempl/vms.em: Likewise.
* ldlang.c (new_afile): Use memset to init zero fields.
(load_symbols): Simplify save and restore of flags around command
file processing.
* ldfile.c (is_sysrooted_pathname): Tidy.
+2012-03-06 Alan Modra <amodra@gmail.com>
+
+ * ldlang.h (struct lang_input_statement_flags): New, extract from..
+ (lang_input_statement_type): ..here. New field "flags".
+ (input_flags): Declare.
+ (missing_file): Delete.
+ * ldmain.h (whole_archive): Delete.
+ (add_DT_NEEDED_for_regular, add_DT_NEEDED_for_dynamic): Delete.
+ * ld.h (ld_config_type <dynamic_link>): Delete.
+ * ldmain.c (whole_archive): Delete.
+ (add_DT_NEEDED_for_regular, add_DT_NEEDED_for_dynamic): Delete.
+ * ldlang.c (missing_file, ldlang_sysrooted_script): Delete.
+ (input_flags): New variable. Replace all uses of config.dynamic_link,
+ missing_file, ldlang_sysrooted_script, whole_archive,
+ add_DT_NEEDED_for_regular and add_DT_NEEDED_for_dynamic with fields
+ from here.
+ * ldfile.c: Likewise.
+ * ldgram.y: Likewise.
+ * ldmain.c: Likewise.
+ * ldwrite.c: Likewise.
+ * lexsup.c: Likewise.
+ * plugin.c: Likewise.
+ * emultempl/aix.em: Likewise.
+ * emultempl/armelf.em: Likewise.
+ * emultempl/elf32.em: Likewise.
+ * emultempl/hppaelf.em: Likewise.
+ * emultempl/linux.em: Likewise.
+ * emultempl/pe.em: Likewise.
+ * emultempl/pep.em: Likewise.
+ * emultempl/ppc64elf.em: Likewise.
+ * emultempl/scoreelf.em: Likewise.
+ * emultempl/spuelf.em: Likewise.
+ * emultempl/sunos.em: Likewise.
+ * emultempl/vms.em: Likewise.
+ * ldlang.c (new_afile): Use memset to init zero fields.
+ (load_symbols): Simplify save and restore of flags around command
+ file processing.
+ * ldfile.c (is_sysrooted_pathname): Tidy.
+
2012-03-05 Hans-Peter Nilsson <hp@axis.com>
* configure.tgt (mips64*el-*-freebsd*, mips64*-*-freebsd*)
/* AIX emulation code for ${EMULATION_NAME}
Copyright 1991, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012
Free Software Foundation, Inc.
Written by Steve Chamberlain <sac@cygnus.com>
AIX support by Ian Lance Taylor <ian@cygnus.com>
{
ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
- config.dynamic_link = TRUE;
+ input_flags.dynamic = TRUE;
config.has_shared = TRUE;
/* The link_info.[init|fini]_functions are initialized in ld/lexsup.c.
*flpp = n;
ret = TRUE;
- entry->loaded = TRUE;
+ entry->flags.loaded = TRUE;
}
fclose (e);
{
char *path;
- if (!entry->maybe_archive)
+ if (!entry->flags.maybe_archive)
return FALSE;
path = concat (search->name, "/lib", entry->filename, arch, ".a", NULL);
# This shell script emits a C file. -*- C -*-
# Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-# 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+# 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
# Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#ifndef TARGET_ /* I.e., if not generic. */
ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
#endif /* not TARGET_ */
- config.dynamic_link = ${DYNAMIC_LINK-TRUE};
+ input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
}
{
asection *i = statement->input_section.section;
- if (!((lang_input_statement_type *) i->owner->usrdata)->just_syms_flag
+ if (!((lang_input_statement_type *) i->owner->usrdata)->flags.just_syms
&& (i->flags & SEC_EXCLUDE) == 0
&& i->output_section != NULL
&& i->output_section->owner == link_info.output_bfd)
/* ${ELFSIZE} bit ELF emulation code for ${EMULATION_NAME}
Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+ 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
Written by Steve Chamberlain <sac@cygnus.com>
ELF support by Ian Lance Taylor <ian@cygnus.com>
gld${EMULATION_NAME}_before_parse (void)
{
ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
- config.dynamic_link = ${DYNAMIC_LINK-TRUE};
+ input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
}
/* Tell the ELF linker that we don't want the output file to have a
DT_NEEDED entry for this file, unless it is used to resolve
references in a regular object. */
- if (entry->add_DT_NEEDED_for_regular)
+ if (entry->flags.add_DT_NEEDED_for_regular)
link_class = DYN_AS_NEEDED;
/* Tell the ELF linker that we don't want the output file to have a
DT_NEEDED entry for any dynamic library in DT_NEEDED tags from
this file at all. */
- if (!entry->add_DT_NEEDED_for_dynamic)
+ if (!entry->flags.add_DT_NEEDED_for_dynamic)
link_class |= DYN_NO_ADD_NEEDED;
- if (entry->just_syms_flag
+ if (entry->flags.just_syms
&& (bfd_get_file_flags (entry->the_bfd) & DYNAMIC) != 0)
einfo (_("%P%F: --just-symbols may not be used on DSO: %B\n"),
entry->the_bfd);
return;
}
- if (s->search_dirs_flag)
+ if (s->flags.search_dirs)
{
const char *f = strrchr (s->filename, '/');
if (f != NULL
char *msg;
bfd_boolean ret;
- if (is->just_syms_flag)
+ if (is->flags.just_syms)
continue;
s = bfd_get_section_by_name (is->the_bfd, ".gnu.warning");
const char *filename;
char *string;
- if (! entry->maybe_archive)
+ if (! entry->flags.maybe_archive)
return FALSE;
filename = entry->filename;
if (bfd_check_format (entry->the_bfd, bfd_object)
&& (entry->the_bfd->flags & DYNAMIC) != 0)
{
- ASSERT (entry->maybe_archive && entry->search_dirs_flag);
+ ASSERT (entry->flags.maybe_archive && entry->flags.search_dirs);
/* Rather than duplicating the logic above. Just use the
filename we recorded earlier. */
# This shell script emits a C file. -*- C -*-
# Copyright 1991, 1993, 1994, 1997, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+# 2005, 2006, 2007, 2008, 2009, 2012 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
{
asection *i = statement->input_section.section;
- if (!((lang_input_statement_type *) i->owner->usrdata)->just_syms_flag
+ if (!((lang_input_statement_type *) i->owner->usrdata)->flags.just_syms
&& (i->flags & SEC_EXCLUDE) == 0
&& i->output_section != NULL
&& i->output_section->owner == link_info.output_bfd)
/* Linux a.out emulation code for ${EMULATION_NAME}
Copyright 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+ 2003, 2004, 2005, 2007, 2008, 2012 Free Software Foundation, Inc.
Written by Steve Chamberlain <sac@cygnus.com>
Linux support by Eric Youngdale <ericy@cais.cais.com>
gld${EMULATION_NAME}_before_parse (void)
{
ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
- config.dynamic_link = TRUE;
+ input_flags.dynamic = TRUE;
config.has_shared = TRUE;
}
{
char *string;
- if (! entry->maybe_archive)
+ if (! entry->flags.maybe_archive)
return FALSE;
string = (char *) xmalloc (strlen (search->name)
(echo;echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-)
fragment <<EOF
/* Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+ 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
+ Free Software Foundation, Inc.
This file is part of the GNU Binutils.
ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
output_filename = "${EXECUTABLE_NAME:-a.exe}";
#ifdef DLL_SUPPORT
- config.dynamic_link = TRUE;
+ input_flags.dynamic = TRUE;
config.has_shared = 1;
EOF
unsigned int i;
- if (! entry->maybe_archive)
+ if (! entry->flags.maybe_archive)
return FALSE;
filename = entry->filename;
rm -f e${EMULATION_NAME}.c
(echo;echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-)
fragment <<EOF
-/* Copyright 2006, 2007, 2008, 2009, 2010, 2011
+/* Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
Written by Kai Tietz, OneVision Software GmbH&CoKg.
ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
output_filename = "${EXECUTABLE_NAME:-a.exe}";
#ifdef DLL_SUPPORT
- config.dynamic_link = TRUE;
+ input_flags.dynamic = TRUE;
config.has_shared = 1;
link_info.pei386_auto_import = 1;
link_info.pei386_runtime_pseudo_reloc = 2; /* Use by default version 2. */
unsigned int i;
- if (! entry->maybe_archive)
+ if (! entry->flags.maybe_archive)
return FALSE;
filename = entry->filename;
{
asection *i = statement->input_section.section;
- if (!((lang_input_statement_type *) i->owner->usrdata)->just_syms_flag
+ if (!((lang_input_statement_type *) i->owner->usrdata)->flags.just_syms
&& (i->flags & SEC_EXCLUDE) == 0
&& i->output_section == toc_section)
{
{
asection *i = statement->input_section.section;
- if (!((lang_input_statement_type *) i->owner->usrdata)->just_syms_flag
+ if (!((lang_input_statement_type *) i->owner->usrdata)->flags.just_syms
&& (i->flags & SEC_EXCLUDE) == 0
&& i->output_section != NULL
&& i->output_section->owner == link_info.output_bfd)
# This shell script emits a C file. -*- C -*-
-# Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+# Copyright 2006, 2007, 2008, 2009, 2012 Free Software Foundation, Inc.
# Contributed by:
# Brain.lin (brain.lin@sunplusct.com)
# Mei Ligang (ligang@sunnorth.com.cn)
#ifndef TARGET_ /* I.e., if not generic. */
ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
#endif /* not TARGET_ */
- config.dynamic_link = ${DYNAMIC_LINK-TRUE};
+ input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
}
# This shell script emits a C file. -*- C -*-
-# Copyright 2006, 2007, 2008, 2009, 2010, 2011
+# Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012
# Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
/* Ensure bfd sections are excluded from the output. */
bfd_section_list_clear (entry->the_bfd);
- entry->loaded = TRUE;
+ entry->flags.loaded = TRUE;
return TRUE;
}
/* SunOS emulation code for ${EMULATION_NAME}
Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+ 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2012
+ Free Software Foundation, Inc.
Written by Steve Chamberlain <sac@cygnus.com>
SunOS shared library support by Ian Lance Taylor <ian@cygnus.com>
gld${EMULATION_NAME}_before_parse (void)
{
ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
- config.dynamic_link = TRUE;
+ input_flags.dynamic = TRUE;
config.has_shared = TRUE;
}
char *alc;
struct stat st;
- if (! inp->search_dirs_flag
- || ! inp->maybe_archive
- || ! inp->dynamic)
+ if (! inp->flags.search_dirs
+ || ! inp->flags.maybe_archive
+ || ! inp->flags.dynamic)
return;
ASSERT (CONST_STRNEQ (inp->local_sym_name, "-l"));
/* Turn off the search_dirs_flag to prevent ldfile_open_file from
searching for this file again. */
- inp->search_dirs_flag = FALSE;
+ inp->flags.search_dirs = FALSE;
free (found);
{
++need_entries;
need_size += NEED_ENTRY_SIZE;
- if (! inp->maybe_archive)
+ if (! inp->flags.maybe_archive)
need_size += strlen (inp->filename) + 1;
else
{
referential locality. */
bfd_put_32 (link_info.output_bfd, need_pnames - need_contents,
need_pinfo);
- if (! inp->maybe_archive)
+ if (! inp->flags.maybe_archive)
{
bfd_put_32 (link_info.output_bfd, (bfd_vma) 0, need_pinfo + 4);
bfd_put_16 (link_info.output_bfd, (bfd_vma) 0, need_pinfo + 8);
# This shell script emits a C file. -*- C -*-
-# Copyright 2010
+# Copyright 2010, 2012
# Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
gld${EMULATION_NAME}_before_parse (void)
{
ldfile_set_output_arch ("${ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
- config.dynamic_link = TRUE;
+ input_flags.dynamic = TRUE;
config.has_shared = FALSE; /* Not yet. */
}
{
char *string;
- if (! entry->maybe_archive)
+ if (! entry->flags.maybe_archive)
return FALSE;
string = (char *) xmalloc (strlen (search->name)
bfd_boolean magic_demand_paged;
bfd_boolean make_executable;
- /* If TRUE, doing a dynamic link. */
- bfd_boolean dynamic_link;
-
/* If TRUE, -shared is supported. */
/* ??? A better way to do this is perhaps to define this in the
ld_emulation_xfer_struct since this is really a target dependent
static bfd_boolean
is_sysrooted_pathname (const char *name, bfd_boolean notsame)
{
- char * realname = ld_canon_sysroot ? lrealpath (name) : NULL;
+ char *realname;
int len;
bfd_boolean result;
- if (! realname)
+ if (ld_canon_sysroot == NULL)
return FALSE;
+ realname = lrealpath (name);
len = strlen (realname);
+ result = FALSE;
+ if (len == ld_canon_sysroot_len)
+ result = !notsame;
+ else if (len > ld_canon_sysroot_len
+ && IS_DIR_SEPARATOR (realname[ld_canon_sysroot_len]))
+ {
+ result = TRUE;
+ realname[ld_canon_sysroot_len] = '\0';
+ }
- if (((! notsame && len == ld_canon_sysroot_len)
- || (len >= ld_canon_sysroot_len
- && IS_DIR_SEPARATOR (realname[ld_canon_sysroot_len])
- && (realname[ld_canon_sysroot_len] = '\0') == '\0'))
- && FILENAME_CMP (ld_canon_sysroot, realname) == 0)
- result = TRUE;
- else
- result = FALSE;
-
- if (realname)
- free (realname);
+ if (result)
+ result = FILENAME_CMP (ld_canon_sysroot, realname) == 0;
+ free (realname);
return result;
}
checks out compatible, do not exit early returning TRUE, or
the plugins will not get a chance to claim the file. */
- if (entry->search_dirs_flag || !entry->dynamic)
+ if (entry->flags.search_dirs || !entry->flags.dynamic)
{
bfd *check;
if (! bfd_check_format (check, bfd_object))
{
if (check == entry->the_bfd
- && entry->search_dirs_flag
+ && entry->flags.search_dirs
&& bfd_get_error () == bfd_error_file_not_recognized
&& ! ldemul_unrecognized_file (entry))
{
goto success;
}
- if (!entry->dynamic && (entry->the_bfd->flags & DYNAMIC) != 0)
+ if (!entry->flags.dynamic && (entry->the_bfd->flags & DYNAMIC) != 0)
{
einfo (_("%F%P: attempted static link of dynamic object `%s'\n"),
attempt);
return FALSE;
}
- if (entry->search_dirs_flag
+ if (entry->flags.search_dirs
&& !bfd_arch_get_compatible (check, link_info.output_bfd,
command_line.accept_unknown_input_arch)
/* XCOFF archives can have 32 and 64 bit objects. */
/* If this is not an archive, try to open it in the current
directory first. */
- if (! entry->maybe_archive)
+ if (! entry->flags.maybe_archive)
{
- if (entry->sysrooted && IS_ABSOLUTE_PATH (entry->filename))
+ if (entry->flags.sysrooted && IS_ABSOLUTE_PATH (entry->filename))
{
char *name = concat (ld_sysroot, entry->filename,
(const char *) NULL);
}
else if (ldfile_try_open_bfd (entry->filename, entry))
{
- entry->sysrooted = IS_ABSOLUTE_PATH (entry->filename)
- && is_sysrooted_pathname (entry->filename, TRUE);
+ entry->flags.sysrooted
+ = (IS_ABSOLUTE_PATH (entry->filename)
+ && is_sysrooted_pathname (entry->filename, TRUE));
return TRUE;
}
{
char *string;
- if (entry->dynamic && ! link_info.relocatable)
+ if (entry->flags.dynamic && ! link_info.relocatable)
{
if (ldemul_open_dynamic_archive (arch, search, entry))
{
- entry->sysrooted = search->sysrooted;
+ entry->flags.sysrooted = search->sysrooted;
return TRUE;
}
}
- if (entry->maybe_archive)
+ if (entry->flags.maybe_archive)
string = concat (search->name, slash, lib, entry->filename,
arch, suffix, (const char *) NULL);
else
if (ldfile_try_open_bfd (string, entry))
{
entry->filename = string;
- entry->sysrooted = search->sysrooted;
+ entry->flags.sysrooted = search->sysrooted;
return TRUE;
}
if (entry->the_bfd != NULL)
return;
- if (! entry->search_dirs_flag)
+ if (! entry->flags.search_dirs)
{
if (ldfile_try_open_bfd (entry->filename, entry))
return;
else
einfo (_("%P: cannot find %s: %E\n"), entry->local_sym_name);
- entry->missing_file = TRUE;
- missing_file = TRUE;
+ entry->flags.missing_file = TRUE;
+ input_flags.missing_file = TRUE;
}
else
{
/* If we have found the file, we don't need to search directories
again. */
if (found)
- entry->search_dirs_flag = FALSE;
+ entry->flags.search_dirs = FALSE;
else
{
- if (entry->sysrooted
+ if (entry->flags.sysrooted
&& ld_sysroot
&& IS_ABSOLUTE_PATH (entry->local_sym_name))
einfo (_("%P: cannot find %s inside %s\n"),
entry->local_sym_name, ld_sysroot);
else
einfo (_("%P: cannot find %s\n"), entry->local_sym_name);
- entry->missing_file = TRUE;
- missing_file = TRUE;
+ entry->flags.missing_file = TRUE;
+ input_flags.missing_file = TRUE;
}
}
}
{ lang_add_input_file($2,lang_input_file_is_l_enum,
(char *)NULL); }
| AS_NEEDED '('
- { $<integer>$ = add_DT_NEEDED_for_regular; add_DT_NEEDED_for_regular = TRUE; }
+ { $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
+ input_flags.add_DT_NEEDED_for_regular = TRUE; }
input_list ')'
- { add_DT_NEEDED_for_regular = $<integer>3; }
+ { input_flags.add_DT_NEEDED_for_regular = $<integer>3; }
| input_list ',' AS_NEEDED '('
- { $<integer>$ = add_DT_NEEDED_for_regular; add_DT_NEEDED_for_regular = TRUE; }
+ { $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
+ input_flags.add_DT_NEEDED_for_regular = TRUE; }
input_list ')'
- { add_DT_NEEDED_for_regular = $<integer>5; }
+ { input_flags.add_DT_NEEDED_for_regular = $<integer>5; }
| input_list AS_NEEDED '('
- { $<integer>$ = add_DT_NEEDED_for_regular; add_DT_NEEDED_for_regular = TRUE; }
+ { $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
+ input_flags.add_DT_NEEDED_for_regular = TRUE; }
input_list ')'
- { add_DT_NEEDED_for_regular = $<integer>4; }
+ { input_flags.add_DT_NEEDED_for_regular = $<integer>4; }
;
sections:
static lang_statement_list_type *stat_save[10];
static lang_statement_list_type **stat_save_ptr = &stat_save[0];
static struct unique_sections *unique_section_list;
-static bfd_boolean ldlang_sysrooted_script = FALSE;
/* Forward declarations. */
static void exp_init_os (etree_type *);
lang_statement_list_type input_file_chain;
struct bfd_sym_chain entry_symbol = { NULL, NULL };
const char *entry_section = ".text";
+struct lang_input_statement_flags input_flags;
bfd_boolean entry_from_cmdline;
bfd_boolean undef_from_cmdline;
bfd_boolean lang_has_input_file = FALSE;
bfd_boolean delete_output_file_on_failure = FALSE;
struct lang_phdr *lang_phdr_list;
struct lang_nocrossrefs *nocrossref_list;
-bfd_boolean missing_file = FALSE;
/* Functions that traverse the linker script and might evaluate
DEFINED() need to increment this. */
callback_t callback,
void *data)
{
- if (file->just_syms_flag)
+ if (file->flags.just_syms)
return;
(*ptr->walk_wild_section_handler) (ptr, file, callback, data);
{
lang_input_statement_type *p;
+ lang_has_input_file = TRUE;
+
if (add_to_list)
p = (lang_input_statement_type *) new_stat (lang_input_statement, stat_ptr);
else
p->header.next = NULL;
}
- lang_has_input_file = TRUE;
+ memset (&p->the_bfd, 0,
+ sizeof (*p) - offsetof (lang_input_statement_type, the_bfd));
p->target = target;
- p->sysrooted = FALSE;
+ p->flags.dynamic = input_flags.dynamic;
+ p->flags.add_DT_NEEDED_for_dynamic = input_flags.add_DT_NEEDED_for_dynamic;
+ p->flags.add_DT_NEEDED_for_regular = input_flags.add_DT_NEEDED_for_regular;
+ p->flags.whole_archive = input_flags.whole_archive;
if (file_type == lang_input_file_is_l_enum
&& name[0] == ':' && name[1] != '\0')
{
case lang_input_file_is_symbols_only_enum:
p->filename = name;
- p->maybe_archive = FALSE;
- p->real = TRUE;
p->local_sym_name = name;
- p->just_syms_flag = TRUE;
- p->search_dirs_flag = FALSE;
+ p->flags.real = TRUE;
+ p->flags.just_syms = TRUE;
break;
case lang_input_file_is_fake_enum:
p->filename = name;
- p->maybe_archive = FALSE;
- p->real = FALSE;
p->local_sym_name = name;
- p->just_syms_flag = FALSE;
- p->search_dirs_flag = FALSE;
break;
case lang_input_file_is_l_enum:
- p->maybe_archive = TRUE;
p->filename = name;
- p->real = TRUE;
p->local_sym_name = concat ("-l", name, (const char *) NULL);
- p->just_syms_flag = FALSE;
- p->search_dirs_flag = TRUE;
+ p->flags.maybe_archive = TRUE;
+ p->flags.real = TRUE;
+ p->flags.search_dirs = TRUE;
break;
case lang_input_file_is_marker_enum:
p->filename = name;
- p->maybe_archive = FALSE;
- p->real = FALSE;
p->local_sym_name = name;
- p->just_syms_flag = FALSE;
- p->search_dirs_flag = TRUE;
+ p->flags.search_dirs = TRUE;
break;
case lang_input_file_is_search_file_enum:
- p->sysrooted = ldlang_sysrooted_script;
p->filename = name;
- p->maybe_archive = FALSE;
- p->real = TRUE;
p->local_sym_name = name;
- p->just_syms_flag = FALSE;
- p->search_dirs_flag = TRUE;
+ p->flags.real = TRUE;
+ p->flags.search_dirs = TRUE;
+ p->flags.sysrooted = input_flags.sysrooted;
break;
case lang_input_file_is_file_enum:
p->filename = name;
- p->maybe_archive = FALSE;
- p->real = TRUE;
p->local_sym_name = name;
- p->just_syms_flag = FALSE;
- p->search_dirs_flag = FALSE;
+ p->flags.real = TRUE;
break;
default:
FAIL ();
}
- p->the_bfd = NULL;
- p->next_real_file = NULL;
- p->next = NULL;
- p->dynamic = config.dynamic_link;
- p->add_DT_NEEDED_for_dynamic = add_DT_NEEDED_for_dynamic;
- p->add_DT_NEEDED_for_regular = add_DT_NEEDED_for_regular;
- p->whole_archive = whole_archive;
- p->loaded = FALSE;
- p->missing_file = FALSE;
-#ifdef ENABLE_PLUGINS
- p->claimed = FALSE;
- p->claim_archive = FALSE;
- p->reload = FALSE;
-#endif /* ENABLE_PLUGINS */
lang_statement_append (&input_file_chain,
(lang_statement_union_type *) p,
asection *s;
if ((file->the_bfd->flags & (BFD_LINKER_CREATED | DYNAMIC)) != 0
- || file->just_syms_flag)
+ || file->flags.just_syms)
continue;
for (s = file->the_bfd->sections; s != NULL; s = s->next)
/* If we are only reading symbols from this object, then we want to
discard all sections. */
- if (entry->just_syms_flag)
+ if (entry->flags.just_syms)
{
bfd_link_just_syms (abfd, sec, &link_info);
return;
/* If we have already added this file, or this file is not real
don't add this file. */
- if (search->loaded || !search->real)
+ if (search->flags.loaded || !search->flags.real)
return search;
if (! load_symbols (search, NULL))
{
char **matching;
- if (entry->loaded)
+ if (entry->flags.loaded)
return TRUE;
ldfile_open_file (entry);
/* Do not process further if the file was missing. */
- if (entry->missing_file)
+ if (entry->flags.missing_file)
return TRUE;
if (! bfd_check_format (entry->the_bfd, bfd_archive)
&& ! bfd_check_format_matches (entry->the_bfd, bfd_object, &matching))
{
bfd_error_type err;
- bfd_boolean save_ldlang_sysrooted_script;
- bfd_boolean save_add_DT_NEEDED_for_regular;
- bfd_boolean save_add_DT_NEEDED_for_dynamic;
- bfd_boolean save_whole_archive;
+ struct lang_input_statement_flags save_flags;
err = bfd_get_error ();
entry->the_bfd = NULL;
/* Try to interpret the file as a linker script. */
+ save_flags = input_flags;
ldfile_open_command_file (entry->filename);
push_stat_ptr (place);
- save_ldlang_sysrooted_script = ldlang_sysrooted_script;
- ldlang_sysrooted_script = entry->sysrooted;
- save_add_DT_NEEDED_for_regular = add_DT_NEEDED_for_regular;
- add_DT_NEEDED_for_regular = entry->add_DT_NEEDED_for_regular;
- save_add_DT_NEEDED_for_dynamic = add_DT_NEEDED_for_dynamic;
- add_DT_NEEDED_for_dynamic = entry->add_DT_NEEDED_for_dynamic;
- save_whole_archive = whole_archive;
- whole_archive = entry->whole_archive;
+ input_flags.sysrooted = entry->flags.sysrooted;
+ input_flags.add_DT_NEEDED_for_regular
+ = entry->flags.add_DT_NEEDED_for_regular;
+ input_flags.add_DT_NEEDED_for_dynamic
+ = entry->flags.add_DT_NEEDED_for_dynamic;
+ input_flags.whole_archive = entry->flags.whole_archive;
+ input_flags.dynamic = entry->flags.dynamic;
ldfile_assumed_script = TRUE;
parser_input = input_script;
- /* We want to use the same -Bdynamic/-Bstatic as the one for
- ENTRY. */
- config.dynamic_link = entry->dynamic;
yyparse ();
ldfile_assumed_script = FALSE;
- ldlang_sysrooted_script = save_ldlang_sysrooted_script;
- add_DT_NEEDED_for_regular = save_add_DT_NEEDED_for_regular;
- add_DT_NEEDED_for_dynamic = save_add_DT_NEEDED_for_dynamic;
- whole_archive = save_whole_archive;
+ /* missing_file is sticky. */
+ save_flags.missing_file |= input_flags.missing_file;
+ input_flags = save_flags;
pop_stat_ptr ();
return TRUE;
case bfd_object:
#ifdef ENABLE_PLUGINS
- if (!entry->reload)
+ if (!entry->flags.reload)
#endif
ldlang_add_file (entry);
if (trace_files || trace_file_tries)
case bfd_archive:
check_excluded_libs (entry->the_bfd);
- if (entry->whole_archive)
+ if (entry->flags.whole_archive)
{
bfd *member = NULL;
bfd_boolean loaded = TRUE;
}
}
- entry->loaded = loaded;
+ entry->flags.loaded = loaded;
return loaded;
}
break;
}
if (bfd_link_add_symbols (entry->the_bfd, &link_info))
- entry->loaded = TRUE;
+ entry->flags.loaded = TRUE;
else
einfo (_("%F%B: could not read symbols: %E\n"), entry->the_bfd);
- return entry->loaded;
+ return entry->flags.loaded;
}
/* Handle a wild statement. S->FILENAME or S->SECTION_LIST or both
LANG_FOR_EACH_INPUT_STATEMENT (s)
{
if (s->header.type == lang_input_statement_enum
- && s->real)
+ && s->flags.real)
{
ldfile_open_file (s);
current_target = s->target_statement.target;
break;
case lang_input_statement_enum:
- if (s->input_statement.real)
+ if (s->input_statement.flags.real)
{
lang_statement_union_type **os_tail;
lang_statement_list_type add;
&& ((mode & OPEN_BFD_RESCAN) == 0
|| plugin_insert == NULL)
#endif
- && !s->input_statement.whole_archive
- && s->input_statement.loaded
+ && !s->input_statement.flags.whole_archive
+ && s->input_statement.flags.loaded
&& bfd_check_format (s->input_statement.the_bfd,
bfd_archive))
- s->input_statement.loaded = FALSE;
+ s->input_statement.flags.loaded = FALSE;
#ifdef ENABLE_PLUGINS
/* When rescanning, reload --as-needed shared libs. */
else if ((mode & OPEN_BFD_RESCAN) != 0
&& plugin_insert == NULL
- && s->input_statement.loaded
- && s->input_statement.add_DT_NEEDED_for_regular
+ && s->input_statement.flags.loaded
+ && s->input_statement.flags.add_DT_NEEDED_for_regular
&& ((s->input_statement.the_bfd->flags) & DYNAMIC) != 0
&& plugin_should_reload (s->input_statement.the_bfd))
{
- s->input_statement.loaded = FALSE;
- s->input_statement.reload = TRUE;
+ s->input_statement.flags.loaded = FALSE;
+ s->input_statement.flags.reload = TRUE;
}
#endif
}
/* Exit if any of the files were missing. */
- if (missing_file)
+ if (input_flags.missing_file)
einfo ("%F");
}
lang_input_section_type *is = &((*this_ptr)->input_section);
asection *i = is->section;
- if (!((lang_input_statement_type *) i->owner->usrdata)->just_syms_flag
+ if (!((lang_input_statement_type *) i->owner->usrdata)->flags.just_syms
&& (i->flags & SEC_EXCLUDE) == 0)
{
bfd_size_type alignment_needed;
{
#ifdef ENABLE_PLUGINS
/* Don't check format of files claimed by plugin. */
- if (file->input_statement.claimed)
+ if (file->input_statement.flags.claimed)
continue;
#endif /* ENABLE_PLUGINS */
input_bfd = file->input_statement.the_bfd;
/* This section of the file is not attached, root
around for a sensible place for it to go. */
- if (file->just_syms_flag)
+ if (file->flags.just_syms)
bfd_link_just_syms (file->the_bfd, s, &link_info);
else if ((s->flags & SEC_EXCLUDE) != 0)
s->output_section = bfd_abs_section_ptr;
{
asection *sec;
#ifdef ENABLE_PLUGINS
- if (f->claimed)
+ if (f->flags.claimed)
continue;
#endif
for (sec = f->the_bfd->sections; sec != NULL; sec = sec->next)
claim1 != NULL;
claim1 = &claim1->next->input_statement)
{
- if (claim1->claimed)
- return claim1->claim_archive ? lastobject : claim1;
+ if (claim1->flags.claimed)
+ return claim1->flags.claim_archive ? lastobject : claim1;
/* Update lastobject if this is a real object file. */
if (claim1->the_bfd && (claim1->the_bfd->my_archive == NULL))
lastobject = claim1;
}
first_file->filename = name;
first_file->local_sym_name = name;
- first_file->real = TRUE;
+ first_file->flags.real = TRUE;
}
void
/* ldlang.h - linker command language support
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+ 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
This file is part of the GNU Binutils.
bfd_vma output_offset;
} lang_reloc_statement_type;
-typedef struct lang_input_statement_struct
+struct lang_input_statement_flags
{
- lang_statement_header_type header;
- /* Name of this file. */
- const char *filename;
- /* Name to use for the symbol giving address of text start.
- Usually the same as filename, but for a file spec'd with
- -l this is the -l switch itself rather than the filename. */
- const char *local_sym_name;
-
- bfd *the_bfd;
-
- struct flag_info *section_flag_list;
-
- /* Point to the next file - whatever it is, wanders up and down
- archives */
- union lang_statement_union *next;
-
- /* Point to the next file, but skips archive contents. */
- union lang_statement_union *next_real_file;
-
- const char *target;
-
+ /* 1 means this file was specified in a -l option. */
unsigned int maybe_archive : 1;
/* 1 means search a set of directories for this file. */
- unsigned int search_dirs_flag : 1;
+ unsigned int search_dirs : 1;
/* 1 means this was found in a search directory marked as sysrooted,
- if search_dirs_flag is false, otherwise, that it should be
+ if search_dirs is false, otherwise, that it should be
searched in ld_sysroot before any other location, as long as it
starts with a slash. */
unsigned int sysrooted : 1;
/* 1 means this is base file of incremental load.
Do not load this file's text or data.
Also default text_start to after this file's bss. */
- unsigned int just_syms_flag : 1;
+ unsigned int just_syms : 1;
/* Whether to search for this entry as a dynamic archive. */
unsigned int dynamic : 1;
/* Set if reloading an --as-needed lib. */
unsigned int reload : 1;
#endif /* ENABLE_PLUGINS */
+};
+
+typedef struct lang_input_statement_struct
+{
+ lang_statement_header_type header;
+ /* Name of this file. */
+ const char *filename;
+ /* Name to use for the symbol giving address of text start.
+ Usually the same as filename, but for a file spec'd with
+ -l this is the -l switch itself rather than the filename. */
+ const char *local_sym_name;
+
+ bfd *the_bfd;
+
+ struct flag_info *section_flag_list;
+
+ /* Point to the next file - whatever it is, wanders up and down
+ archives */
+ union lang_statement_union *next;
+
+ /* Point to the next file, but skips archive contents. */
+ union lang_statement_union *next_real_file;
+
+ const char *target;
+ struct lang_input_statement_flags flags;
} lang_input_statement_type;
typedef struct
etree_type *flags;
};
-extern struct lang_phdr *lang_phdr_list;
-
/* This structure is used to hold a list of sections which may not
cross reference each other. */
lang_nocrossref_type *list;
};
-extern struct lang_nocrossrefs *nocrossref_list;
-
/* This structure is used to hold a list of input section names which
will not match an output section in the linker script. */
lang_output_section_statement_type **os_tail;
};
+extern struct lang_phdr *lang_phdr_list;
+extern struct lang_nocrossrefs *nocrossref_list;
extern const char *output_target;
extern lang_output_section_statement_type *abs_output_section;
extern lang_statement_list_type lang_output_section_statement;
+extern struct lang_input_statement_flags input_flags;
extern bfd_boolean lang_has_input_file;
extern etree_type *base;
extern lang_statement_list_type *stat_ptr;
extern lang_statement_list_type input_file_chain;
extern int lang_statement_iteration;
-extern bfd_boolean missing_file;
extern void lang_init
(void);
instead of complaining if no input files are given. */
bfd_boolean version_printed;
-/* Nonzero means link in every member of an archive. */
-bfd_boolean whole_archive;
-
-/* True means only create DT_NEEDED entries for dynamic libraries
- if they actually satisfy some reference in a regular object. */
-bfd_boolean add_DT_NEEDED_for_regular;
-
-/* True means create DT_NEEDED entries for dynamic libraries that
- are DT_NEEDED by dynamic libraries specifically mentioned on
- the command line. */
-bfd_boolean add_DT_NEEDED_for_dynamic;
-
/* TRUE if we should demangle symbol names. */
bfd_boolean demangling;
file.filesize = arelt_size (abfd);
file.fd = fd;
plugin_maybe_claim (&file, input);
- if (input->claimed)
+ if (input->flags.claimed)
{
- input->claim_archive = TRUE;
+ input->flags.claim_archive = TRUE;
*subsbfd = input->the_bfd;
}
}
/* ldmain.h -
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2002, 2003, 2004,
- 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+ 2005, 2007, 2008, 2009, 2012 Free Software Foundation, Inc.
This file is part of the GNU Binutils.
extern bfd_boolean trace_files;
extern bfd_boolean trace_file_tries;
extern bfd_boolean version_printed;
-extern bfd_boolean whole_archive;
-extern bfd_boolean add_DT_NEEDED_for_regular;
-extern bfd_boolean add_DT_NEEDED_for_dynamic;
extern bfd_boolean demangling;
extern int g_switch_value;
extern const char *output_filename;
attached */
asection *i = statement->input_section.section;
- if (!((lang_input_statement_type *) i->owner->usrdata)->just_syms_flag
+ if (!((lang_input_statement_type *) i->owner->usrdata)->flags.just_syms
&& (i->flags & SEC_EXCLUDE) == 0)
{
asection *output_section = i->output_section;
``use only shared libraries'' but, then, we don't
currently support shared libraries on HP/UX anyhow. */
if (strcmp (optarg, "archive") == 0)
- config.dynamic_link = FALSE;
+ input_flags.dynamic = FALSE;
else if (strcmp (optarg, "shared") == 0
|| strcmp (optarg, "default") == 0)
- config.dynamic_link = TRUE;
+ input_flags.dynamic = TRUE;
else
einfo (_("%P%F: unrecognized -a option `%s'\n"), optarg);
break;
yyparse ();
break;
case OPTION_CALL_SHARED:
- config.dynamic_link = TRUE;
+ input_flags.dynamic = TRUE;
break;
case OPTION_NON_SHARED:
- config.dynamic_link = FALSE;
+ input_flags.dynamic = FALSE;
break;
case OPTION_CREF:
command_line.cref = TRUE;
case 'N':
config.text_read_only = FALSE;
config.magic_demand_paged = FALSE;
- config.dynamic_link = FALSE;
+ input_flags.dynamic = FALSE;
break;
case OPTION_NO_OMAGIC:
config.text_read_only = TRUE;
config.magic_demand_paged = TRUE;
- /* NB/ Does not set dynamic_link to TRUE.
+ /* NB/ Does not set input_flags.dynamic to TRUE.
Use --call-shared or -Bdynamic for this. */
break;
case 'n':
config.magic_demand_paged = FALSE;
- config.dynamic_link = FALSE;
+ input_flags.dynamic = FALSE;
break;
case OPTION_NO_DEFINE_COMMON:
command_line.inhibit_common_definition = TRUE;
config.only_cmd_line_lib_dirs = TRUE;
break;
case OPTION_NO_WHOLE_ARCHIVE:
- whole_archive = FALSE;
+ input_flags.whole_archive = FALSE;
break;
case 'O':
/* FIXME "-O<non-digits> <value>" used to set the address of
config.build_constructors = FALSE;
config.magic_demand_paged = FALSE;
config.text_read_only = FALSE;
- config.dynamic_link = FALSE;
+ input_flags.dynamic = FALSE;
break;
case 'R':
/* The GNU linker traditionally uses -R to mean to include
config.build_constructors = TRUE;
config.magic_demand_paged = FALSE;
config.text_read_only = FALSE;
- config.dynamic_link = FALSE;
+ input_flags.dynamic = FALSE;
break;
case 'u':
ldlang_add_undef (optarg, TRUE);
link_info.warn_alternate_em = TRUE;
break;
case OPTION_WHOLE_ARCHIVE:
- whole_archive = TRUE;
+ input_flags.whole_archive = TRUE;
break;
case OPTION_ADD_DT_NEEDED_FOR_DYNAMIC:
- add_DT_NEEDED_for_dynamic = TRUE;
+ input_flags.add_DT_NEEDED_for_dynamic = TRUE;
break;
case OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC:
- add_DT_NEEDED_for_dynamic = FALSE;
+ input_flags.add_DT_NEEDED_for_dynamic = FALSE;
break;
case OPTION_ADD_DT_NEEDED_FOR_REGULAR:
- add_DT_NEEDED_for_regular = TRUE;
+ input_flags.add_DT_NEEDED_for_regular = TRUE;
break;
case OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR:
- add_DT_NEEDED_for_regular = FALSE;
+ input_flags.add_DT_NEEDED_for_regular = FALSE;
break;
case OPTION_WRAP:
add_wrap (optarg);
/* Plugin control for the GNU linker.
- Copyright 2010, 2011 Free Software Foundation, Inc.
+ Copyright 2010, 2011, 2012 Free Software Foundation, Inc.
This file is part of the GNU Binutils.
when processing DT_NEEDED dependencies. */
return (abfd
&& abfd->usrdata
- && ((lang_input_statement_type *)(abfd->usrdata))->claimed);
+ && ((lang_input_statement_type *)(abfd->usrdata))->flags.claimed);
}
/* Helpers to convert between BFD and GOLD symbol formats. */
if (entry->the_bfd->my_archive == NULL)
bfd_close (entry->the_bfd);
entry->the_bfd = file->handle;
- entry->claimed = TRUE;
+ entry->flags.claimed = TRUE;
bfd_make_readable (entry->the_bfd);
}
else
/* If plugin didn't claim the file, we don't need the dummy bfd.
Can't avoid speculatively creating it, alas. */
bfd_close_all_done (file->handle);
- entry->claimed = FALSE;
+ entry->flags.claimed = FALSE;
}
}