From c4b7819565e41809d80f66febb0c89a6204e1ad8 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 21 Jan 2010 10:31:32 +0000 Subject: PR 4437 * ldfile.c: (ldfile_open_file): Do not stop link upon encountering a missing file or library. Instead mark the entry as missing and set the global flag to indicate that missing files were encountered. * ldlang.c (missing_files): New exported variable. (load_symbols): Skip loading if the file is missing. (open_input_bfds): Terminate link if any input files were missing. * ldlang.h (struct lang_input_statement_struct): Add missing_file field. Add export of missing_file variable. --- ld/ChangeLog | 16 ++++++++++++++++ ld/ldfile.c | 30 +++++++++++++++++++++--------- ld/ldlang.c | 17 ++++++++++++++--- ld/ldlang.h | 7 ++++++- 4 files changed, 57 insertions(+), 13 deletions(-) (limited to 'ld') diff --git a/ld/ChangeLog b/ld/ChangeLog index a009480..baaf4df 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,19 @@ +2010-01-21 Jon Grant + Nick Clifton + + PR 4437 + * ldfile.c: (ldfile_open_file): Do not stop link upon encountering + a missing file or library. Instead mark the entry as missing and + set the global flag to indicate that missing files were + encountered. + * ldlang.c (missing_files): New exported variable. + (load_symbols): Skip loading if the file is missing. + (open_input_bfds): Terminate link if any input files were + missing. + * ldlang.h (struct lang_input_statement_struct): Add missing_file + field. + Add export of missing_file variable. + 2010-01-13 DJ Delorie * emultempl/elf32.em (_place_orphan): If an input section doesn't diff --git a/ld/ldfile.c b/ld/ldfile.c index a6844c1..4661897 100644 --- a/ld/ldfile.c +++ b/ld/ldfile.c @@ -1,6 +1,6 @@ /* Linker file opening and searching. Copyright 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001, 2002, - 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. + 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU Binutils. @@ -363,7 +363,10 @@ ldfile_open_file_search (const char *arch, return FALSE; } -/* Open the input file specified by ENTRY. */ +/* Open the input file specified by ENTRY. + PR 4437: Do not stop on the first missing file, but + continue processing other input files in case there + are more errors to report. */ void ldfile_open_file (lang_input_statement_type *entry) @@ -375,11 +378,15 @@ ldfile_open_file (lang_input_statement_type *entry) { if (ldfile_try_open_bfd (entry->filename, entry)) return; + if (strcmp (entry->filename, entry->local_sym_name) != 0) - einfo (_("%F%P: %s (%s): No such file: %E\n"), + einfo (_("%P: cannot find %s (%s): %E\n"), entry->filename, entry->local_sym_name); else - einfo (_("%F%P: %s: No such file: %E\n"), entry->local_sym_name); + einfo (_("%P: cannot find %s: %E\n"), entry->local_sym_name); + + entry->missing_file = TRUE; + missing_file = TRUE; } else { @@ -406,13 +413,18 @@ ldfile_open_file (lang_input_statement_type *entry) again. */ if (found) entry->search_dirs_flag = FALSE; - else if (entry->sysrooted + else + { + if (entry->sysrooted && ld_sysroot && IS_ABSOLUTE_PATH (entry->local_sym_name)) - einfo (_("%F%P: cannot find %s inside %s\n"), - entry->local_sym_name, ld_sysroot); - else - einfo (_("%F%P: cannot find %s\n"), 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; + } } } diff --git a/ld/ldlang.c b/ld/ldlang.c index 2321ae2..fd75a5b 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -1,6 +1,6 @@ /* Linker command language support. Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU Binutils. @@ -64,6 +64,8 @@ static lang_statement_list_type statement_list; static struct bfd_hash_table lang_definedness_table; 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 *); @@ -101,8 +103,7 @@ bfd_boolean lang_float_flag = FALSE; bfd_boolean delete_output_file_on_failure = FALSE; struct lang_phdr *lang_phdr_list; struct lang_nocrossrefs *nocrossref_list; -static struct unique_sections *unique_section_list; -static bfd_boolean ldlang_sysrooted_script = FALSE; +bfd_boolean missing_file = FALSE; /* Functions that traverse the linker script and might evaluate DEFINED() need to increment this. */ @@ -1060,6 +1061,8 @@ new_afile (const char *name, p->add_DT_NEEDED_for_regular = add_DT_NEEDED_for_regular; p->whole_archive = whole_archive; p->loaded = FALSE; + p->missing_file = FALSE; + lang_statement_append (&input_file_chain, (lang_statement_union_type *) p, &p->next_real_file); @@ -2583,6 +2586,10 @@ load_symbols (lang_input_statement_type *entry, ldfile_open_file (entry); + /* Do not process further if the file was missing. */ + if (entry->missing_file) + return TRUE; + if (! bfd_check_format (entry->the_bfd, bfd_archive) && ! bfd_check_format_matches (entry->the_bfd, bfd_object, &matching)) { @@ -3164,6 +3171,10 @@ open_input_bfds (lang_statement_union_type *s, bfd_boolean force) break; } } + + /* Exit if any of the files were missing. */ + if (missing_file) + einfo ("%F"); } /* Add a symbol to a hash of symbols used in DEFINED (NAME) expressions. */ diff --git a/ld/ldlang.h b/ld/ldlang.h index 897ef56..58d03f0 100644 --- a/ld/ldlang.h +++ b/ld/ldlang.h @@ -1,6 +1,6 @@ /* 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 + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU Binutils. @@ -279,9 +279,13 @@ typedef struct lang_input_statement_struct /* Whether to include the entire contents of an archive. */ unsigned int whole_archive : 1; + /* Set when bfd opening is successful. */ unsigned int loaded : 1; unsigned int real : 1; + + /* Set if the file does not exist. */ + unsigned int missing_file : 1; } lang_input_statement_type; typedef struct @@ -462,6 +466,7 @@ extern lang_statement_list_type file_chain; extern lang_statement_list_type input_file_chain; extern int lang_statement_iteration; +extern bfd_boolean missing_file; extern void lang_init (void); -- cgit v1.1