X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=ld%2Fldmain.c;h=019df71a2c40c734bec59de7bd442f83a7f1073f;hb=d9313f4f43f9bb23fb1ef3a93c4879c706d5e881;hp=3bdaf4df2088d29271673d11d55b5eb4fac830ea;hpb=3b66a14146bd861b160d19a101ba63dceb47c55f;p=platform%2Fupstream%2Fbinutils.git diff --git a/ld/ldmain.c b/ld/ldmain.c index 3bdaf4d..019df71 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -1,7 +1,5 @@ /* Main program of GNU linker. - Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, - 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 - Free Software Foundation, Inc. + Copyright 1991-2013 Free Software Foundation, Inc. Written by Steve Chamberlain steve@cygnus.com This file is part of the GNU Binutils. @@ -82,14 +80,14 @@ const char *ld_sysroot; char * ld_canon_sysroot; int ld_canon_sysroot_len; -/* Set by -G argument, for MIPS ECOFF target. */ +/* Set by -G argument, for targets like MIPS ELF. */ int g_switch_value = 8; /* Nonzero means print names of input files as processed. */ bfd_boolean trace_files; -/* Nonzero means same, but note open failures, too. */ -bfd_boolean trace_file_tries; +/* Nonzero means report actions taken by the linker, and describe the linker script in use. */ +bfd_boolean verbose; /* Nonzero means version number was printed, so exit successfully instead of complaining if no input files are given. */ @@ -191,6 +189,9 @@ main (int argc, char **argv) { char *emulation; long start_time = get_run_time (); +#ifdef HAVE_SBRK + char *start_sbrk = (char *) sbrk (0); +#endif #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) setlocale (LC_MESSAGES, ""); @@ -260,11 +261,11 @@ main (int argc, char **argv) config.make_executable = TRUE; config.magic_demand_paged = TRUE; config.text_read_only = TRUE; + link_info.disable_target_specific_optimizations = -1; command_line.warn_mismatch = TRUE; command_line.warn_search_mismatch = TRUE; command_line.check_section_addresses = -1; - command_line.disable_target_specific_optimizations = -1; /* We initialize DEMANGLING based on the environment variable COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the @@ -305,8 +306,7 @@ main (int argc, char **argv) #ifdef ENABLE_PLUGINS /* Now all the plugin arguments have been gathered, we can load them. */ - if (plugin_load_plugins ()) - einfo (_("%P%F: %s: error loading plugin\n"), plugin_error_plugin ()); + plugin_load_plugins (); #endif /* ENABLE_PLUGINS */ ldemul_set_symbols (); @@ -340,7 +340,7 @@ main (int argc, char **argv) lex_string = NULL; } - if (trace_file_tries) + if (verbose) { if (saved_script_handle) info_msg (_("using external linker script:")); @@ -505,7 +505,7 @@ main (int argc, char **argv) program_name, run_time / 1000000, run_time % 1000000); #ifdef HAVE_SBRK fprintf (stderr, _("%s: data size %ld\n"), program_name, - (long) (lim - (char *) &environ)); + (long) (lim - start_sbrk)); #endif fflush (stderr); } @@ -643,6 +643,23 @@ add_ysym (const char *name) einfo (_("%P%F: bfd_hash_lookup failed: %E\n")); } +void +add_ignoresym (struct bfd_link_info *info, const char *name) +{ + if (info->ignore_hash == NULL) + { + info->ignore_hash = xmalloc (sizeof (struct bfd_hash_table)); + if (! bfd_hash_table_init_n (info->ignore_hash, + bfd_hash_newfunc, + sizeof (struct bfd_hash_entry), + 61)) + einfo (_("%P%F: bfd_hash_table_init failed: %E\n")); + } + + if (bfd_hash_lookup (info->ignore_hash, name, TRUE, TRUE) == NULL) + einfo (_("%P%F: bfd_hash_lookup failed: %E\n")); +} + /* Record a symbol to be wrapped, from the --wrap option. */ void @@ -727,6 +744,7 @@ add_keepsyms_file (const char *filename) free (buf); link_info.strip = strip_some; + fclose (file); } /* Callbacks from the BFD linker routines. */ @@ -861,7 +879,7 @@ add_archive_element (struct bfd_link_info *info, minfo ("(%s)\n", name); } - if (trace_files || trace_file_tries) + if (trace_files || verbose) info_msg ("%I\n", &orig_input); return TRUE; } @@ -934,10 +952,10 @@ multiple_definition (struct bfd_link_info *info, if (obfd != NULL) einfo (_("%D: first defined here\n"), obfd, osec, oval); - if (RELAXATION_ENABLED) + if (RELAXATION_ENABLED_BY_USER) { einfo (_("%P: Disabling relaxation: it will not work with multiple definitions\n")); - command_line.disable_target_specific_optimizations = -1; + DISABLE_RELAXATION; } return TRUE; @@ -1091,7 +1109,7 @@ constructor_callback (struct bfd_link_info *info, /* Ensure that BFD_RELOC_CTOR exists now, so that we can give a useful error message. */ - if (bfd_reloc_type_lookup (link_info.output_bfd, BFD_RELOC_CTOR) == NULL + if (bfd_reloc_type_lookup (info->output_bfd, BFD_RELOC_CTOR) == NULL && (info->relocatable || bfd_reloc_type_lookup (abfd, BFD_RELOC_CTOR) == NULL)) einfo (_("%P%F: BFD backend error: BFD_RELOC_CTOR unsupported\n")); @@ -1228,7 +1246,7 @@ warning_find_reloc (bfd *abfd, asection *sec, void *iarg) /* This is called when an undefined symbol is found. */ static bfd_boolean -undefined_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED, +undefined_symbol (struct bfd_link_info *info, const char *name, bfd *abfd, asection *section, @@ -1240,25 +1258,14 @@ undefined_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED, #define MAX_ERRORS_IN_A_ROW 5 + if (info->ignore_hash != NULL + && bfd_hash_lookup (info->ignore_hash, name, FALSE, FALSE) != NULL) + return TRUE; + if (config.warn_once) { - static struct bfd_hash_table *hash; - /* Only warn once about a particular undefined symbol. */ - if (hash == NULL) - { - hash = (struct bfd_hash_table *) - xmalloc (sizeof (struct bfd_hash_table)); - if (!bfd_hash_table_init (hash, bfd_hash_newfunc, - sizeof (struct bfd_hash_entry))) - einfo (_("%F%P: bfd_hash_table_init failed: %E\n")); - } - - if (bfd_hash_lookup (hash, name, FALSE, FALSE) != NULL) - return TRUE; - - if (bfd_hash_lookup (hash, name, TRUE, TRUE) == NULL) - einfo (_("%F%P: bfd_hash_lookup failed: %E\n")); + add_ignoresym (info, name); } /* We never print more than a reasonable number of errors in a row @@ -1336,7 +1343,7 @@ int overflow_cutoff_limit = 10; /* This is called when a reloc overflows. */ static bfd_boolean -reloc_overflow (struct bfd_link_info *info ATTRIBUTE_UNUSED, +reloc_overflow (struct bfd_link_info *info, struct bfd_link_hash_entry *entry, const char *name, const char *reloc_name, @@ -1375,7 +1382,7 @@ reloc_overflow (struct bfd_link_info *info ATTRIBUTE_UNUSED, reloc_name, entry->root.string, entry->u.def.section, entry->u.def.section == bfd_abs_section_ptr - ? link_info.output_bfd : entry->u.def.section->owner); + ? info->output_bfd : entry->u.def.section->owner); break; default: abort ();