1 /* Main program of GNU linker.
2 Copyright (C) 1991, 92, 93, 94, 1995 Free Software Foundation, Inc.
5 This file is part of GLD, the Gnu Linker.
7 GLD is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GLD is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GLD; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
26 #include "libiberty.h"
42 /* Somewhere above, sys/stat.h got included . . . . */
43 #if !defined(S_ISDIR) && defined(S_IFDIR)
44 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
49 static char *get_emulation PARAMS ((int, char **));
50 static void set_scripts_dir PARAMS ((void));
55 const char *output_filename = "a.out";
57 /* Name this program was invoked by. */
60 /* The file that we're creating */
63 /* Set by -G argument, for MIPS ECOFF target. */
64 int g_switch_value = 8;
66 /* Nonzero means print names of input files as processed. */
69 /* Nonzero means same, but note open failures, too. */
70 boolean trace_file_tries;
72 /* Nonzero means version number was printed, so exit successfully
73 instead of complaining if no input files are given. */
74 boolean version_printed;
76 /* Nonzero means link in every member of an archive. */
77 boolean whole_archive;
79 args_type command_line;
81 ld_config_type config;
83 static boolean check_for_scripts_dir PARAMS ((char *dir));
84 static boolean add_archive_element PARAMS ((struct bfd_link_info *, bfd *,
86 static boolean multiple_definition PARAMS ((struct bfd_link_info *,
88 bfd *, asection *, bfd_vma,
89 bfd *, asection *, bfd_vma));
90 static boolean multiple_common PARAMS ((struct bfd_link_info *,
92 enum bfd_link_hash_type, bfd_vma,
93 bfd *, enum bfd_link_hash_type,
95 static boolean add_to_set PARAMS ((struct bfd_link_info *,
96 struct bfd_link_hash_entry *,
97 bfd_reloc_code_real_type,
98 bfd *, asection *, bfd_vma));
99 static boolean constructor_callback PARAMS ((struct bfd_link_info *,
102 bfd *, asection *, bfd_vma));
103 static boolean warning_callback PARAMS ((struct bfd_link_info *,
104 const char *, const char *, bfd *,
105 asection *, bfd_vma));
106 static void warning_find_reloc PARAMS ((bfd *, asection *, PTR));
107 static boolean undefined_symbol PARAMS ((struct bfd_link_info *,
109 asection *, bfd_vma));
110 static boolean reloc_overflow PARAMS ((struct bfd_link_info *, const char *,
111 const char *, bfd_vma,
112 bfd *, asection *, bfd_vma));
113 static boolean reloc_dangerous PARAMS ((struct bfd_link_info *, const char *,
114 bfd *, asection *, bfd_vma));
115 static boolean unattached_reloc PARAMS ((struct bfd_link_info *,
116 const char *, bfd *, asection *,
118 static boolean notice_ysym PARAMS ((struct bfd_link_info *, const char *,
119 bfd *, asection *, bfd_vma));
121 static struct bfd_link_callbacks link_callbacks =
127 constructor_callback,
136 struct bfd_link_info link_info;
143 if (output_bfd && output_bfd->iostream)
144 fclose((FILE *)(output_bfd->iostream));
145 if (delete_output_file_on_failure)
146 unlink (output_filename);
156 long start_time = get_run_time ();
158 program_name = argv[0];
159 xmalloc_set_program_name (program_name);
161 START_PROGRESS (program_name, 0);
165 bfd_set_error_program_name (program_name);
167 xatexit (remove_output);
169 /* Initialize the data about options. */
170 trace_files = trace_file_tries = version_printed = false;
171 whole_archive = false;
172 config.build_constructors = true;
173 config.dynamic_link = false;
174 command_line.force_common_definition = false;
175 command_line.interpreter = NULL;
176 command_line.rpath = NULL;
178 link_info.callbacks = &link_callbacks;
179 link_info.relocateable = false;
180 link_info.shared = false;
181 link_info.symbolic = false;
182 link_info.static_link = false;
183 link_info.traditional_format = false;
184 link_info.strip = strip_none;
185 link_info.discard = discard_none;
186 link_info.lprefix_len = 1;
187 link_info.lprefix = "L";
188 link_info.keep_memory = true;
189 link_info.input_bfds = NULL;
190 link_info.create_object_symbols_section = NULL;
191 link_info.hash = NULL;
192 link_info.keep_hash = NULL;
193 link_info.notice_hash = NULL;
194 link_info.wrap_hash = NULL;
196 ldfile_add_arch ("");
198 config.make_executable = true;
199 force_make_executable = false;
200 config.magic_demand_paged = true;
201 config.text_read_only = true;
202 config.make_executable = true;
204 emulation = get_emulation (argc, argv);
205 ldemul_choose_mode (emulation);
206 default_target = ldemul_choose_target ();
208 ldemul_before_parse ();
209 lang_has_input_file = false;
210 parse_args (argc, argv);
212 ldemul_set_symbols ();
214 if (link_info.relocateable)
216 if (command_line.relax)
217 einfo ("%P%F: -relax and -r may not be used together\n");
218 if (link_info.shared)
219 einfo ("%P%F: -r and -shared may not be used together\n");
222 /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols). I
223 don't see how else this can be handled, since in this case we
224 must preserve all externally visible symbols. */
225 if (link_info.relocateable && link_info.strip == strip_all)
227 link_info.strip = strip_debugger;
228 if (link_info.discard == discard_none)
229 link_info.discard = discard_all;
232 /* This essentially adds another -L directory so this must be done after
233 the -L's in argv have been processed. */
236 if (had_script == false)
238 /* Read the emulation's appropriate default script. */
240 char *s = ldemul_get_script (&isfile);
243 ldfile_open_command_file (s);
246 if (trace_file_tries)
248 info_msg ("using internal linker script:\n");
249 info_msg ("==================================================\n");
251 info_msg ("\n==================================================\n");
256 parser_input = input_script;
263 if (lang_has_input_file == false)
267 einfo ("%P%F: no input files\n");
272 info_msg ("%P: mode %s\n", emulation);
275 ldemul_after_parse ();
278 if (config.map_filename)
280 if (strcmp (config.map_filename, "-") == 0)
282 config.map_file = stdout;
286 config.map_file = fopen (config.map_filename, FOPEN_WT);
287 if (config.map_file == (FILE *) NULL)
289 bfd_set_error (bfd_error_system_call);
290 einfo ("%P%F: cannot open map file %s: %E\n",
291 config.map_filename);
299 /* Print error messages for any missing symbols, for any warning
300 symbols, and possibly multiple definitions */
303 if (config.text_read_only)
305 /* Look for a text section and mark the readonly attribute in it */
306 asection *found = bfd_get_section_by_name (output_bfd, ".text");
308 if (found != (asection *) NULL)
310 found->flags |= SEC_READONLY;
314 if (link_info.relocateable)
315 output_bfd->flags &= ~EXEC_P;
317 output_bfd->flags |= EXEC_P;
321 if (config.map_file != NULL)
324 /* Even if we're producing relocateable output, some non-fatal errors should
325 be reported in the exit status. (What non-fatal errors, if any, do we
326 want to ignore for relocateable output?) */
328 if (config.make_executable == false && force_make_executable == false)
330 if (trace_files == true)
332 einfo ("%P: link errors found, deleting executable `%s'\n",
336 if (output_bfd->iostream)
337 fclose ((FILE *) (output_bfd->iostream));
339 unlink (output_filename);
344 if (! bfd_close (output_bfd))
345 einfo ("%F%B: final close failed: %E\n", output_bfd);
348 END_PROGRESS (program_name);
352 extern char **environ;
354 char *lim = (char *) sbrk (0);
356 long run_time = get_run_time () - start_time;
358 fprintf (stderr, "%s: total time in link: %ld.%06ld\n",
359 program_name, run_time / 1000000, run_time % 1000000);
361 fprintf (stderr, "%s: data size %ld\n", program_name,
362 (long) (lim - (char *) &environ));
366 /* Prevent remove_output from doing anything, after a successful link. */
367 output_filename = NULL;
373 /* We need to find any explicitly given emulation in order to initialize the
374 state that's needed by the lex&yacc argument parser (parse_args). */
377 get_emulation (argc, argv)
384 emulation = (char *) getenv (EMULATION_ENVIRON);
385 if (emulation == NULL)
386 emulation = DEFAULT_EMULATION;
388 for (i = 1; i < argc; i++)
390 if (!strncmp (argv[i], "-m", 2))
392 if (argv[i][2] == '\0')
397 emulation = argv[i + 1];
402 einfo("%P%F: missing argument to -m\n");
405 else if (strcmp (argv[i], "-mips1") == 0
406 || strcmp (argv[i], "-mips2") == 0
407 || strcmp (argv[i], "-mips3") == 0)
409 /* FIXME: The arguments -mips1, -mips2 and -mips3 are
410 passed to the linker by some MIPS compilers. They
411 generally tell the linker to use a slightly different
412 library path. Perhaps someday these should be
413 implemented as emulations; until then, we just ignore
414 the arguments and hope that nobody ever creates
415 emulations named ips1, ips2 or ips3. */
417 else if (strcmp (argv[i], "-m486") == 0)
419 /* FIXME: The argument -m486 is passed to the linker on
420 some Linux systems. Hope that nobody creates an
421 emulation named 486. */
426 emulation = &argv[i][2];
434 /* If directory DIR contains an "ldscripts" subdirectory,
435 add DIR to the library search path and return true,
436 else return false. */
439 check_for_scripts_dir (dir)
447 dirlen = strlen (dir);
448 /* sizeof counts the terminating NUL. */
449 buf = (char *) xmalloc (dirlen + sizeof("/ldscripts"));
450 sprintf (buf, "%s/ldscripts", dir);
452 res = stat (buf, &s) == 0 && S_ISDIR (s.st_mode);
455 ldfile_add_library_path (dir, false);
459 /* Set the default directory for finding script files.
460 Libraries will be searched for here too, but that's ok.
461 We look for the "ldscripts" directory in:
463 SCRIPTDIR (passed from Makefile)
464 the dir where this program is (for using it from the build tree)
465 the dir where this program is/../lib (for installing the tool suite elsewhere) */
473 if (check_for_scripts_dir (SCRIPTDIR))
474 return; /* We've been installed normally. */
476 /* Look for "ldscripts" in the dir where our binary is. */
477 end = strrchr (program_name, '/');
481 /* Don't look for ldscripts in the current directory. There is
482 too much potential for confusion. */
486 dirlen = end - program_name;
487 /* Make a copy of program_name in dir.
488 Leave room for later "/../lib". */
489 dir = (char *) xmalloc (dirlen + 8);
490 strncpy (dir, program_name, dirlen);
493 if (check_for_scripts_dir (dir))
494 return; /* Don't free dir. */
496 /* Look for "ldscripts" in <the dir where our binary is>/../lib. */
497 strcpy (dir + dirlen, "/../lib");
498 if (check_for_scripts_dir (dir))
501 free (dir); /* Well, we tried. */
508 if (link_info.notice_hash == (struct bfd_hash_table *) NULL)
510 link_info.notice_hash = ((struct bfd_hash_table *)
511 xmalloc (sizeof (struct bfd_hash_table)));
512 if (! bfd_hash_table_init_n (link_info.notice_hash,
515 einfo ("%P%F: bfd_hash_table_init failed: %E\n");
518 if (bfd_hash_lookup (link_info.notice_hash, name, true, true)
519 == (struct bfd_hash_entry *) NULL)
520 einfo ("%P%F: bfd_hash_lookup failed: %E\n");
523 /* Record a symbol to be wrapped, from the --wrap option. */
529 if (link_info.wrap_hash == NULL)
531 link_info.wrap_hash = ((struct bfd_hash_table *)
532 xmalloc (sizeof (struct bfd_hash_table)));
533 if (! bfd_hash_table_init_n (link_info.wrap_hash,
536 einfo ("%P%F: bfd_hash_table_init failed: %E\n");
538 if (bfd_hash_lookup (link_info.wrap_hash, name, true, true) == NULL)
539 einfo ("%P%F: bfd_hash_lookup failed: %E\n");
542 /* Handle the -retain-symbols-file option. */
545 add_keepsyms_file (filename)
546 const char *filename;
553 if (link_info.strip == strip_some)
554 einfo ("%X%P: error: duplicate retain-symbols-file\n");
556 file = fopen (filename, "r");
557 if (file == (FILE *) NULL)
559 bfd_set_error (bfd_error_system_call);
560 einfo ("%X%P: %s: %E\n", filename);
564 link_info.keep_hash = ((struct bfd_hash_table *)
565 xmalloc (sizeof (struct bfd_hash_table)));
566 if (! bfd_hash_table_init (link_info.keep_hash, bfd_hash_newfunc))
567 einfo ("%P%F: bfd_hash_table_init failed: %E\n");
570 buf = (char *) xmalloc (bufsize);
582 while (! isspace (c) && c != EOF)
589 buf = xrealloc (buf, bufsize);
596 if (bfd_hash_lookup (link_info.keep_hash, buf, true, true)
597 == (struct bfd_hash_entry *) NULL)
598 einfo ("%P%F: bfd_hash_lookup for insertion failed: %E\n");
602 if (link_info.strip != strip_none)
603 einfo ("%P: `-retain-symbols-file' overrides `-s' and `-S'\n");
605 link_info.strip = strip_some;
608 /* Callbacks from the BFD linker routines. */
610 /* This is called when BFD has decided to include an archive member in
615 add_archive_element (info, abfd, name)
616 struct bfd_link_info *info;
620 lang_input_statement_type *input;
622 input = ((lang_input_statement_type *)
623 xmalloc (sizeof (lang_input_statement_type)));
624 input->filename = abfd->filename;
625 input->local_sym_name = abfd->filename;
626 input->the_bfd = abfd;
627 input->asymbols = NULL;
629 input->just_syms_flag = false;
630 input->loaded = false;
631 input->search_dirs_flag = false;
633 /* FIXME: The following fields are not set: header.next,
634 header.type, closed, passive_position, symbol_count,
635 next_real_file, is_archive, target, real, common_section,
636 common_output_section, complained. This bit of code is from the
637 old decode_library_subfile function. I don't know whether any of
638 those fields matters. */
640 ldlang_add_file (input);
642 if (config.map_file != (FILE *) NULL)
644 static boolean header_printed;
645 struct bfd_link_hash_entry *h;
649 h = bfd_link_hash_lookup (link_info.hash, name, false, false, true);
661 case bfd_link_hash_defined:
662 case bfd_link_hash_defweak:
663 from = h->u.def.section->owner;
666 case bfd_link_hash_undefined:
667 case bfd_link_hash_undefweak:
668 from = h->u.undef.abfd;
671 case bfd_link_hash_common:
672 from = h->u.c.p->section->owner;
677 if (! header_printed)
681 sprintf (buf, "%-29s %s\n\n", "Archive member included",
682 "because of file (symbol)");
684 header_printed = true;
687 if (bfd_my_archive (abfd) == NULL)
689 minfo ("%s", bfd_get_filename (abfd));
690 len = strlen (bfd_get_filename (abfd));
694 minfo ("%s(%s)", bfd_get_filename (bfd_my_archive (abfd)),
695 bfd_get_filename (abfd));
696 len = (strlen (bfd_get_filename (bfd_my_archive (abfd)))
697 + strlen (bfd_get_filename (abfd))
715 minfo ("(%T)\n", h->root.string);
717 minfo ("(%s)\n", name);
720 if (trace_files || trace_file_tries)
721 info_msg ("%I\n", input);
726 /* This is called when BFD has discovered a symbol which is defined
731 multiple_definition (info, name, obfd, osec, oval, nbfd, nsec, nval)
732 struct bfd_link_info *info;
741 /* If either section has the output_section field set to
742 bfd_abs_section_ptr, it means that the section is being
743 discarded, and this is not really a multiple definition at all.
744 FIXME: It would be cleaner to somehow ignore symbols defined in
745 sections which are being discarded. */
746 if ((osec->output_section != NULL
747 && bfd_is_abs_section (osec->output_section))
748 || (nsec->output_section != NULL
749 && bfd_is_abs_section (nsec->output_section)))
752 einfo ("%X%C: multiple definition of `%T'\n",
753 nbfd, nsec, nval, name);
754 if (obfd != (bfd *) NULL)
755 einfo ("%D: first defined here\n", obfd, osec, oval);
759 /* This is called when there is a definition of a common symbol, or
760 when a common symbol is found for a symbol that is already defined,
761 or when two common symbols are found. We only do something if
762 -warn-common was used. */
766 multiple_common (info, name, obfd, otype, osize, nbfd, ntype, nsize)
767 struct bfd_link_info *info;
770 enum bfd_link_hash_type otype;
773 enum bfd_link_hash_type ntype;
776 if (! config.warn_common)
779 if (ntype == bfd_link_hash_defined
780 || ntype == bfd_link_hash_defweak
781 || ntype == bfd_link_hash_indirect)
783 ASSERT (otype == bfd_link_hash_common);
784 einfo ("%B: warning: definition of `%T' overriding common\n",
787 einfo ("%B: warning: common is here\n", obfd);
789 else if (otype == bfd_link_hash_defined
790 || otype == bfd_link_hash_defweak
791 || otype == bfd_link_hash_indirect)
793 ASSERT (ntype == bfd_link_hash_common);
794 einfo ("%B: warning: common of `%T' overridden by definition\n",
797 einfo ("%B: warning: defined here\n", obfd);
801 ASSERT (otype == bfd_link_hash_common && ntype == bfd_link_hash_common);
804 einfo ("%B: warning: common of `%T' overridden by larger common\n",
807 einfo ("%B: warning: larger common is here\n", obfd);
809 else if (nsize > osize)
811 einfo ("%B: warning: common of `%T' overriding smaller common\n",
814 einfo ("%B: warning: smaller common is here\n", obfd);
818 einfo ("%B: warning: multiple common of `%T'\n", nbfd, name);
820 einfo ("%B: warning: previous common is here\n", obfd);
827 /* This is called when BFD has discovered a set element. H is the
828 entry in the linker hash table for the set. SECTION and VALUE
829 represent a value which should be added to the set. */
833 add_to_set (info, h, reloc, abfd, section, value)
834 struct bfd_link_info *info;
835 struct bfd_link_hash_entry *h;
836 bfd_reloc_code_real_type reloc;
841 if (config.warn_constructors)
842 einfo ("%P: warning: global constructor %s used\n",
845 if (! config.build_constructors)
848 ldctor_add_set_entry (h, reloc, (const char *) NULL, section, value);
850 if (h->type == bfd_link_hash_new)
852 h->type = bfd_link_hash_undefined;
853 h->u.undef.abfd = abfd;
854 /* We don't call bfd_link_add_undef to add this to the list of
855 undefined symbols because we are going to define it
862 /* This is called when BFD has discovered a constructor. This is only
863 called for some object file formats--those which do not handle
864 constructors in some more clever fashion. This is similar to
865 adding an element to a set, but less general. */
868 constructor_callback (info, constructor, name, abfd, section, value)
869 struct bfd_link_info *info;
877 struct bfd_link_hash_entry *h;
878 char set_name[1 + sizeof "__CTOR_LIST__"];
880 if (config.warn_constructors)
881 einfo ("%P: warning: global constructor %s used\n", name);
883 if (! config.build_constructors)
886 /* Ensure that BFD_RELOC_CTOR exists now, so that we can give a
887 useful error message. */
888 if (bfd_reloc_type_lookup (output_bfd, BFD_RELOC_CTOR) == NULL
889 && (link_info.relocateable
890 || bfd_reloc_type_lookup (abfd, BFD_RELOC_CTOR) == NULL))
891 einfo ("%P%F: BFD backend error: BFD_RELOC_CTOR unsupported\n");
894 if (bfd_get_symbol_leading_char (abfd) != '\0')
895 *s++ = bfd_get_symbol_leading_char (abfd);
897 strcpy (s, "__CTOR_LIST__");
899 strcpy (s, "__DTOR_LIST__");
901 h = bfd_link_hash_lookup (info->hash, set_name, true, true, true);
902 if (h == (struct bfd_link_hash_entry *) NULL)
903 einfo ("%P%F: bfd_link_hash_lookup failed: %E\n");
904 if (h->type == bfd_link_hash_new)
906 h->type = bfd_link_hash_undefined;
907 h->u.undef.abfd = abfd;
908 /* We don't call bfd_link_add_undef to add this to the list of
909 undefined symbols because we are going to define it
913 ldctor_add_set_entry (h, BFD_RELOC_CTOR, name, section, value);
917 /* A structure used by warning_callback to pass information through
918 bfd_map_over_sections. */
920 struct warning_callback_info
928 /* This is called when there is a reference to a warning symbol. */
932 warning_callback (info, warning, symbol, abfd, section, address)
933 struct bfd_link_info *info;
940 /* This is a hack to support warn_multiple_gp. FIXME: This should
941 have a cleaner interface, but what? */
942 if (! config.warn_multiple_gp
943 && strcmp (warning, "using multiple gp values") == 0)
947 einfo ("%C: %s\n", abfd, section, address, warning);
948 else if (abfd == NULL)
949 einfo ("%P: %s\n", warning);
950 else if (symbol == NULL)
951 einfo ("%B: %s\n", abfd, warning);
954 lang_input_statement_type *entry;
956 struct warning_callback_info info;
958 /* Look through the relocs to see if we can find a plausible
961 entry = (lang_input_statement_type *) abfd->usrdata;
962 if (entry != NULL && entry->asymbols != NULL)
963 asymbols = entry->asymbols;
969 symsize = bfd_get_symtab_upper_bound (abfd);
971 einfo ("%B%F: could not read symbols: %E\n", abfd);
972 asymbols = (asymbol **) xmalloc (symsize);
973 symbol_count = bfd_canonicalize_symtab (abfd, asymbols);
974 if (symbol_count < 0)
975 einfo ("%B%F: could not read symbols: %E\n", abfd);
978 entry->asymbols = asymbols;
979 entry->symbol_count = symbol_count;
984 info.warning = warning;
985 info.symbol = symbol;
986 info.asymbols = asymbols;
987 bfd_map_over_sections (abfd, warning_find_reloc, (PTR) &info);
990 einfo ("%B: %s\n", abfd, warning);
996 /* This is called by warning_callback for each section. It checks the
997 relocs of the section to see if it can find a reference to the
998 symbol which triggered the warning. If it can, it uses the reloc
999 to give an error message with a file and line number. */
1002 warning_find_reloc (abfd, sec, iarg)
1007 struct warning_callback_info *info = (struct warning_callback_info *) iarg;
1011 arelent **p, **pend;
1016 relsize = bfd_get_reloc_upper_bound (abfd, sec);
1018 einfo ("%B%F: could not read relocs: %E\n", abfd);
1022 relpp = (arelent **) xmalloc (relsize);
1023 relcount = bfd_canonicalize_reloc (abfd, sec, relpp, info->asymbols);
1025 einfo ("%B%F: could not read relocs: %E\n", abfd);
1028 pend = p + relcount;
1029 for (; p < pend && *p != NULL; p++)
1033 if (q->sym_ptr_ptr != NULL
1034 && *q->sym_ptr_ptr != NULL
1035 && strcmp (bfd_asymbol_name (*q->sym_ptr_ptr), info->symbol) == 0)
1037 /* We found a reloc for the symbol we are looking for. */
1038 einfo ("%C: %s\n", abfd, sec, q->address, info->warning);
1047 /* This is called when an undefined symbol is found. */
1051 undefined_symbol (info, name, abfd, section, address)
1052 struct bfd_link_info *info;
1058 static char *error_name;
1059 static unsigned int error_count;
1061 #define MAX_ERRORS_IN_A_ROW 5
1063 if (config.warn_once)
1065 static struct bfd_hash_table *hash;
1067 /* Only warn once about a particular undefined symbol. */
1071 hash = ((struct bfd_hash_table *)
1072 xmalloc (sizeof (struct bfd_hash_table)));
1073 if (! bfd_hash_table_init (hash, bfd_hash_newfunc))
1074 einfo ("%F%P: bfd_hash_table_init failed: %E\n");
1077 if (bfd_hash_lookup (hash, name, false, false) != NULL)
1080 if (bfd_hash_lookup (hash, name, true, true) == NULL)
1081 einfo ("%F%P: bfd_hash_lookup failed: %E\n");
1084 /* We never print more than a reasonable number of errors in a row
1085 for a single symbol. */
1086 if (error_name != (char *) NULL
1087 && strcmp (name, error_name) == 0)
1092 if (error_name != (char *) NULL)
1094 error_name = buystring (name);
1097 if (section != NULL)
1099 if (error_count < MAX_ERRORS_IN_A_ROW)
1100 einfo ("%X%C: undefined reference to `%T'\n",
1101 abfd, section, address, name);
1102 else if (error_count == MAX_ERRORS_IN_A_ROW)
1103 einfo ("%D: more undefined references to `%T' follow\n",
1104 abfd, section, address, name);
1108 if (error_count < MAX_ERRORS_IN_A_ROW)
1109 einfo ("%X%B: undefined reference to `%T'\n",
1111 else if (error_count == MAX_ERRORS_IN_A_ROW)
1112 einfo ("%B: more undefined references to `%T' follow\n",
1119 /* This is called when a reloc overflows. */
1123 reloc_overflow (info, name, reloc_name, addend, abfd, section, address)
1124 struct bfd_link_info *info;
1126 const char *reloc_name;
1132 if (abfd == (bfd *) NULL)
1133 einfo ("%P%X: generated");
1135 einfo ("%X%C:", abfd, section, address);
1136 einfo (" relocation truncated to fit: %s %T", reloc_name, name);
1138 einfo ("+%v", addend);
1143 /* This is called when a dangerous relocation is made. */
1147 reloc_dangerous (info, message, abfd, section, address)
1148 struct bfd_link_info *info;
1149 const char *message;
1154 if (abfd == (bfd *) NULL)
1155 einfo ("%P%X: generated");
1157 einfo ("%X%C:", abfd, section, address);
1158 einfo ("dangerous relocation: %s\n", message);
1162 /* This is called when a reloc is being generated attached to a symbol
1163 that is not being output. */
1167 unattached_reloc (info, name, abfd, section, address)
1168 struct bfd_link_info *info;
1174 if (abfd == (bfd *) NULL)
1175 einfo ("%P%X: generated");
1177 einfo ("%X%C:", abfd, section, address);
1178 einfo (" reloc refers to symbol `%T' which is not being output\n", name);
1182 /* This is called when a symbol in notice_hash is found. Symbols are
1183 put in notice_hash using the -y option. */
1187 notice_ysym (info, name, abfd, section, value)
1188 struct bfd_link_info *info;
1194 einfo ("%B: %s %s\n", abfd,
1195 bfd_is_und_section (section) ? "reference to" : "definition of",