* ldmisc.c (ldmalloc, xmalloc, ldrealloc, xrealloc): Functions
[binutils-gdb.git] / ld / ldmain.c
1 /* Main program of GNU linker.
2 Copyright (C) 1991, 92, 93, 94 Free Software Foundation, Inc.
3 Written by Steve Chamberlain steve@cygnus.com
4
5 This file is part of GLD, the Gnu Linker.
6
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)
10 any later version.
11
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.
16
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21
22 #include "bfd.h"
23 #include "sysdep.h"
24 #include <stdio.h>
25 #include "bfdlink.h"
26
27 #include "config.h"
28 #include "ld.h"
29 #include "ldmain.h"
30 #include "ldmisc.h"
31 #include "ldwrite.h"
32 #include "ldgram.h"
33 #include "ldexp.h"
34 #include "ldlang.h"
35 #include "ldemul.h"
36 #include "ldlex.h"
37 #include "ldfile.h"
38 #include "ldctor.h"
39
40 /* Somewhere above, sys/stat.h got included . . . . */
41 #if !defined(S_ISDIR) && defined(S_IFDIR)
42 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
43 #endif
44
45 #include <string.h>
46
47 static char *get_emulation PARAMS ((int, char **));
48 static void set_scripts_dir PARAMS ((void));
49
50 /* EXPORTS */
51
52 char *default_target;
53 const char *output_filename = "a.out";
54
55 /* Name this program was invoked by. */
56 char *program_name;
57
58 /* The file that we're creating */
59 bfd *output_bfd = 0;
60
61 /* Set by -G argument, for MIPS ECOFF target. */
62 int g_switch_value = 8;
63
64 /* Nonzero means print names of input files as processed. */
65 boolean trace_files;
66
67 /* Nonzero means same, but note open failures, too. */
68 boolean trace_file_tries;
69
70 /* Nonzero means version number was printed, so exit successfully
71 instead of complaining if no input files are given. */
72 boolean version_printed;
73
74 /* 1 => write load map. */
75 boolean write_map;
76
77 args_type command_line;
78
79 ld_config_type config;
80
81 static boolean check_for_scripts_dir PARAMS ((char *dir));
82 static boolean add_archive_element PARAMS ((struct bfd_link_info *, bfd *,
83 const char *));
84 static boolean multiple_definition PARAMS ((struct bfd_link_info *,
85 const char *,
86 bfd *, asection *, bfd_vma,
87 bfd *, asection *, bfd_vma));
88 static boolean multiple_common PARAMS ((struct bfd_link_info *,
89 const char *, bfd *,
90 enum bfd_link_hash_type, bfd_vma,
91 bfd *, enum bfd_link_hash_type,
92 bfd_vma));
93 static boolean add_to_set PARAMS ((struct bfd_link_info *,
94 struct bfd_link_hash_entry *,
95 unsigned int bitsize,
96 bfd *, asection *, bfd_vma));
97 static boolean constructor_callback PARAMS ((struct bfd_link_info *,
98 boolean constructor,
99 unsigned int bitsize,
100 const char *name,
101 bfd *, asection *, bfd_vma));
102 static boolean warning_callback PARAMS ((struct bfd_link_info *,
103 const char *));
104 static boolean undefined_symbol PARAMS ((struct bfd_link_info *,
105 const char *, bfd *,
106 asection *, bfd_vma));
107 static boolean reloc_overflow PARAMS ((struct bfd_link_info *, const char *,
108 const char *, bfd_vma,
109 bfd *, asection *, bfd_vma));
110 static boolean reloc_dangerous PARAMS ((struct bfd_link_info *, const char *,
111 bfd *, asection *, bfd_vma));
112 static boolean unattached_reloc PARAMS ((struct bfd_link_info *,
113 const char *, bfd *, asection *,
114 bfd_vma));
115 static boolean notice_ysym PARAMS ((struct bfd_link_info *, const char *,
116 bfd *, asection *, bfd_vma));
117
118 static struct bfd_link_callbacks link_callbacks =
119 {
120 add_archive_element,
121 multiple_definition,
122 multiple_common,
123 add_to_set,
124 constructor_callback,
125 warning_callback,
126 undefined_symbol,
127 reloc_overflow,
128 reloc_dangerous,
129 unattached_reloc,
130 notice_ysym
131 };
132
133 struct bfd_link_info link_info;
134 \f
135 static void
136 remove_output ()
137 {
138 if (output_filename)
139 {
140 if (output_bfd && output_bfd->iostream)
141 fclose((FILE *)(output_bfd->iostream));
142 if (delete_output_file_on_failure)
143 unlink (output_filename);
144 }
145 }
146
147 /* Prevent remove_output from doing anything.
148 Called after a successful link. */
149
150 static void
151 preserve_output ()
152 {
153 output_filename = NULL;
154 }
155
156 int
157 main (argc, argv)
158 int argc;
159 char **argv;
160 {
161 char *emulation;
162 long start_time = get_run_time ();
163
164 program_name = argv[0];
165
166 bfd_init ();
167
168 atexit (remove_output);
169
170 /* Initialize the data about options. */
171 trace_files = trace_file_tries = version_printed = false;
172 write_map = false;
173 config.build_constructors = true;
174 command_line.force_common_definition = false;
175
176 link_info.callbacks = &link_callbacks;
177 link_info.relocateable = false;
178 link_info.strip = strip_none;
179 link_info.discard = discard_none;
180 link_info.lprefix_len = 1;
181 link_info.lprefix = "L";
182 link_info.keep_memory = true;
183 link_info.input_bfds = NULL;
184 link_info.create_object_symbols_section = NULL;
185 link_info.hash = NULL;
186 link_info.keep_hash = NULL;
187 link_info.notice_hash = NULL;
188
189 ldfile_add_arch ("");
190
191 config.make_executable = true;
192 force_make_executable = false;
193 config.magic_demand_paged = true;
194 config.text_read_only = true;
195 config.make_executable = true;
196
197 emulation = get_emulation (argc, argv);
198 ldemul_choose_mode (emulation);
199 default_target = ldemul_choose_target ();
200 lang_init ();
201 ldemul_before_parse ();
202 lang_has_input_file = false;
203 parse_args (argc, argv);
204
205 /* This essentially adds another -L directory so this must be done after
206 the -L's in argv have been processed. */
207 set_scripts_dir ();
208
209 if (had_script == false)
210 {
211 /* Read the emulation's appropriate default script. */
212 int isfile;
213 char *s = ldemul_get_script (&isfile);
214
215 if (isfile)
216 {
217 /* sizeof counts the terminating NUL. */
218 size_t size = strlen (s) + sizeof ("-T ");
219 char *buf = (char *) xmalloc(size);
220 sprintf (buf, "-T %s", s);
221 parse_line (buf, 0);
222 free (buf);
223 }
224 else
225 parse_line (s, 1);
226 }
227
228 if (link_info.relocateable && command_line.relax)
229 {
230 einfo ("%P%F: -relax and -r may not be used together\n");
231 }
232 lang_final ();
233
234 if (lang_has_input_file == false)
235 {
236 if (version_printed)
237 xexit (0);
238 einfo ("%P%F: no input files\n");
239 }
240
241 if (trace_files)
242 {
243 info_msg ("%P: mode %s\n", emulation);
244 }
245
246 ldemul_after_parse ();
247
248
249 if (config.map_filename)
250 {
251 if (strcmp (config.map_filename, "-") == 0)
252 {
253 config.map_file = stdout;
254 }
255 else
256 {
257 config.map_file = fopen (config.map_filename, FOPEN_WT);
258 if (config.map_file == (FILE *) NULL)
259 {
260 einfo ("%P%F: cannot open map file %s: %E\n",
261 config.map_filename);
262 }
263 }
264 }
265
266
267 lang_process ();
268
269 /* Print error messages for any missing symbols, for any warning
270 symbols, and possibly multiple definitions */
271
272
273 if (config.text_read_only)
274 {
275 /* Look for a text section and mark the readonly attribute in it */
276 asection *found = bfd_get_section_by_name (output_bfd, ".text");
277
278 if (found != (asection *) NULL)
279 {
280 found->flags |= SEC_READONLY;
281 }
282 }
283
284 if (link_info.relocateable)
285 output_bfd->flags &= ~EXEC_P;
286 else
287 output_bfd->flags |= EXEC_P;
288
289 ldwrite ();
290
291 /* Even if we're producing relocateable output, some non-fatal errors should
292 be reported in the exit status. (What non-fatal errors, if any, do we
293 want to ignore for relocateable output?) */
294
295 if (config.make_executable == false && force_make_executable == false)
296 {
297 if (trace_files == true)
298 {
299 einfo ("%P: link errors found, deleting executable `%s'\n",
300 output_filename);
301 }
302
303 if (output_bfd->iostream)
304 fclose ((FILE *) (output_bfd->iostream));
305
306 unlink (output_filename);
307 xexit (1);
308 }
309 else
310 {
311 bfd_close (output_bfd);
312 }
313
314 if (config.stats)
315 {
316 extern char **environ;
317 char *lim = (char *) sbrk (0);
318 long run_time = get_run_time () - start_time;
319
320 fprintf (stderr, "%s: total time in link: %d.%06d\n",
321 program_name, run_time / 1000000, run_time % 1000000);
322 fprintf (stderr, "%s: data size %ld\n", program_name,
323 (long) (lim - (char *) &environ));
324 }
325
326 atexit (preserve_output);
327 xexit (0);
328 return 0;
329 }
330
331 /* We need to find any explicitly given emulation in order to initialize the
332 state that's needed by the lex&yacc argument parser (parse_args). */
333
334 static char *
335 get_emulation (argc, argv)
336 int argc;
337 char **argv;
338 {
339 char *emulation;
340 int i;
341
342 emulation = (char *) getenv (EMULATION_ENVIRON);
343 if (emulation == NULL)
344 emulation = DEFAULT_EMULATION;
345
346 for (i = 1; i < argc; i++)
347 {
348 if (!strncmp (argv[i], "-m", 2))
349 {
350 if (argv[i][2] == '\0')
351 {
352 /* -m EMUL */
353 if (i < argc - 1)
354 {
355 emulation = argv[i + 1];
356 i++;
357 }
358 else
359 {
360 einfo("%P%F: missing argument to -m\n");
361 }
362 }
363 else if (strcmp (argv[i], "-mips1") == 0
364 || strcmp (argv[i], "-mips2") == 0
365 || strcmp (argv[i], "-mips3") == 0)
366 {
367 /* FIXME: The arguments -mips1, -mips2 and -mips3 are
368 passed to the linker by some MIPS compilers. They
369 generally tell the linker to use a slightly different
370 library path. Perhaps someday these should be
371 implemented as emulations; until then, we just ignore
372 the arguments and hope that nobody ever creates
373 emulations named ips1, ips2 or ips3. */
374 }
375 else
376 {
377 /* -mEMUL */
378 emulation = &argv[i][2];
379 }
380 }
381 }
382
383 return emulation;
384 }
385
386 /* If directory DIR contains an "ldscripts" subdirectory,
387 add DIR to the library search path and return true,
388 else return false. */
389
390 static boolean
391 check_for_scripts_dir (dir)
392 char *dir;
393 {
394 size_t dirlen;
395 char *buf;
396 struct stat s;
397 boolean res;
398
399 dirlen = strlen (dir);
400 /* sizeof counts the terminating NUL. */
401 buf = (char *) xmalloc (dirlen + sizeof("/ldscripts"));
402 sprintf (buf, "%s/ldscripts", dir);
403
404 res = stat (buf, &s) == 0 && S_ISDIR (s.st_mode);
405 free (buf);
406 if (res)
407 ldfile_add_library_path (dir);
408 return res;
409 }
410
411 /* Set the default directory for finding script files.
412 Libraries will be searched for here too, but that's ok.
413 We look for the "ldscripts" directory in:
414
415 SCRIPTDIR (passed from Makefile)
416 the dir where this program is (for using it from the build tree)
417 the dir where this program is/../lib (for installing the tool suite elsewhere) */
418
419 static void
420 set_scripts_dir ()
421 {
422 char *end, *dir;
423 size_t dirlen;
424
425 if (check_for_scripts_dir (SCRIPTDIR))
426 return; /* We've been installed normally. */
427
428 /* Look for "ldscripts" in the dir where our binary is. */
429 end = strrchr (program_name, '/');
430 if (end)
431 {
432 dirlen = end - program_name;
433 /* Make a copy of program_name in dir.
434 Leave room for later "/../lib". */
435 dir = (char *) xmalloc (dirlen + 8);
436 strncpy (dir, program_name, dirlen);
437 dir[dirlen] = '\0';
438 }
439 else
440 {
441 dirlen = 1;
442 dir = (char *) xmalloc (dirlen + 8);
443 strcpy (dir, ".");
444 }
445
446 if (check_for_scripts_dir (dir))
447 return; /* Don't free dir. */
448
449 /* Look for "ldscripts" in <the dir where our binary is>/../lib. */
450 strcpy (dir + dirlen, "/../lib");
451 if (check_for_scripts_dir (dir))
452 return;
453
454 free (dir); /* Well, we tried. */
455 }
456
457 void
458 add_ysym (name)
459 const char *name;
460 {
461 if (link_info.notice_hash == (struct bfd_hash_table *) NULL)
462 {
463 link_info.notice_hash = ((struct bfd_hash_table *)
464 xmalloc (sizeof (struct bfd_hash_table)));
465 if (! bfd_hash_table_init_n (link_info.notice_hash,
466 bfd_hash_newfunc,
467 61))
468 einfo ("%P%F: bfd_hash_table_init failed: %E\n");
469 }
470
471 if (bfd_hash_lookup (link_info.notice_hash, name, true, true)
472 == (struct bfd_hash_entry *) NULL)
473 einfo ("%P%F: bfd_hash_lookup failed: %E\n");
474 }
475
476 /* Handle the -retain-symbols-file option. */
477
478 void
479 add_keepsyms_file (filename)
480 const char *filename;
481 {
482 FILE *file;
483 char *buf;
484 size_t bufsize;
485 int c;
486
487 if (link_info.strip == strip_some)
488 einfo ("%X%P: error: duplicate retain-symbols-file\n");
489
490 file = fopen (filename, "r");
491 if (file == (FILE *) NULL)
492 {
493 bfd_error = system_call_error;
494 einfo ("%X%P: %s: %E", filename);
495 return;
496 }
497
498 link_info.keep_hash = ((struct bfd_hash_table *)
499 xmalloc (sizeof (struct bfd_hash_table)));
500 if (! bfd_hash_table_init (link_info.keep_hash, bfd_hash_newfunc))
501 einfo ("%P%F: bfd_hash_table_init failed: %E\n");
502
503 bufsize = 100;
504 buf = (char *) xmalloc (bufsize);
505
506 c = getc (file);
507 while (c != EOF)
508 {
509 while (isspace (c))
510 c = getc (file);
511
512 if (c != EOF)
513 {
514 size_t len = 0;
515
516 while (! isspace (c) && c != EOF)
517 {
518 buf[len] = c;
519 ++len;
520 if (len >= bufsize)
521 {
522 bufsize *= 2;
523 buf = xrealloc (buf, bufsize);
524 }
525 c = getc (file);
526 }
527
528 buf[len] = '\0';
529
530 if (bfd_hash_lookup (link_info.keep_hash, buf, true, true)
531 == (struct bfd_hash_entry *) NULL)
532 einfo ("%P%F: bfd_hash_lookup for insertion failed: %E");
533 }
534 }
535
536 if (link_info.strip != strip_none)
537 einfo ("%P: `-retain-symbols-file' overrides `-s' and `-S'\n");
538
539 link_info.strip = strip_some;
540 }
541 \f
542 /* Callbacks from the BFD linker routines. */
543
544 /* This is called when BFD has decided to include an archive member in
545 a link. */
546
547 /*ARGSUSED*/
548 static boolean
549 add_archive_element (info, abfd, name)
550 struct bfd_link_info *info;
551 bfd *abfd;
552 const char *name;
553 {
554 lang_input_statement_type *input;
555
556 input = ((lang_input_statement_type *)
557 xmalloc ((bfd_size_type) sizeof (lang_input_statement_type)));
558 input->filename = abfd->filename;
559 input->local_sym_name = abfd->filename;
560 input->the_bfd = abfd;
561 input->asymbols = NULL;
562 input->subfiles = NULL;
563 input->next = NULL;
564 input->just_syms_flag = false;
565 input->loaded = false;
566 input->chain = NULL;
567
568 /* FIXME: This is wrong. It should point to an entry for the
569 archive itself. However, it doesn't seem to matter. */
570 input->superfile = NULL;
571
572 /* FIXME: The following fields are not set: header.next,
573 header.type, closed, passive_position, symbol_count, total_size,
574 next_real_file, is_archive, search_dirs_flag, target, real,
575 common_section, common_output_section, complained. This bit of
576 code is from the old decode_library_subfile function. I don't
577 know whether any of those fields matters. */
578
579 ldlang_add_file (input);
580
581 if (write_map)
582 info_msg ("%s needed due to %T\n", abfd->filename, name);
583
584 if (trace_files || trace_file_tries)
585 info_msg ("%I\n", input);
586
587 return true;
588 }
589
590 /* This is called when BFD has discovered a symbol which is defined
591 multiple times. */
592
593 /*ARGSUSED*/
594 static boolean
595 multiple_definition (info, name, obfd, osec, oval, nbfd, nsec, nval)
596 struct bfd_link_info *info;
597 const char *name;
598 bfd *obfd;
599 asection *osec;
600 bfd_vma oval;
601 bfd *nbfd;
602 asection *nsec;
603 bfd_vma nval;
604 {
605 einfo ("%X%C: multiple definition of `%T'\n",
606 nbfd, nsec, nval, name);
607 if (obfd != (bfd *) NULL)
608 einfo ("%C: first defined here\n", obfd, osec, oval);
609 return true;
610 }
611
612 /* This is called when there is a definition of a common symbol, or
613 when a common symbol is found for a symbol that is already defined,
614 or when two common symbols are found. We only do something if
615 -warn-common was used. */
616
617 /*ARGSUSED*/
618 static boolean
619 multiple_common (info, name, obfd, otype, osize, nbfd, ntype, nsize)
620 struct bfd_link_info *info;
621 const char *name;
622 bfd *obfd;
623 enum bfd_link_hash_type otype;
624 bfd_vma osize;
625 bfd *nbfd;
626 enum bfd_link_hash_type ntype;
627 bfd_vma nsize;
628 {
629 if (! config.warn_common)
630 return true;
631
632 if (ntype == bfd_link_hash_defined)
633 {
634 ASSERT (otype == bfd_link_hash_common);
635 einfo ("%B: warning: definition of `%T' overriding common\n",
636 nbfd, name);
637 einfo ("%B: warning: common is here\n", obfd);
638 }
639 else if (otype == bfd_link_hash_defined)
640 {
641 ASSERT (ntype == bfd_link_hash_common);
642 einfo ("%B: warning: common of `%T' overridden by definition\n",
643 nbfd, name);
644 einfo ("%B: warning: defined here\n", obfd);
645 }
646 else
647 {
648 ASSERT (otype == bfd_link_hash_common && ntype == bfd_link_hash_common);
649 if (osize > nsize)
650 {
651 einfo ("%B: warning: common of `%T' overridden by larger common\n",
652 nbfd, name);
653 einfo ("%B: warning: larger common is here\n", obfd);
654 }
655 else if (nsize > osize)
656 {
657 einfo ("%B: warning: common of `%T' overriding smaller common\n",
658 nbfd, name);
659 einfo ("%B: warning: smaller common is here\n", obfd);
660 }
661 else
662 {
663 einfo ("%B: warning: multiple common of `%T'\n", nbfd, name);
664 einfo ("%B: warning: previous common is here\n", obfd);
665 }
666 }
667
668 return true;
669 }
670
671 /* This is called when BFD has discovered a set element. H is the
672 entry in the linker hash table for the set. SECTION and VALUE
673 represent a value which should be added to the set. */
674
675 /*ARGSUSED*/
676 static boolean
677 add_to_set (info, h, bitsize, abfd, section, value)
678 struct bfd_link_info *info;
679 struct bfd_link_hash_entry *h;
680 unsigned int bitsize;
681 bfd *abfd;
682 asection *section;
683 bfd_vma value;
684 {
685 ldctor_add_set_entry (h, bitsize, section, value);
686 return true;
687 }
688
689 /* This is called when BFD has discovered a constructor. This is only
690 called for some object file formats--those which do not handle
691 constructors in some more clever fashion. This is similar to
692 adding an element to a set, but less general. */
693
694 static boolean
695 constructor_callback (info, constructor, bitsize, name, abfd, section, value)
696 struct bfd_link_info *info;
697 boolean constructor;
698 unsigned int bitsize;
699 const char *name;
700 bfd *abfd;
701 asection *section;
702 bfd_vma value;
703 {
704 char *set_name;
705 char *s;
706 struct bfd_link_hash_entry *h;
707
708 if (! config.build_constructors)
709 return true;
710
711 set_name = (char *) alloca (1 + sizeof "__CTOR_LIST__");
712 s = set_name;
713 if (bfd_get_symbol_leading_char (abfd) != '\0')
714 *s++ = bfd_get_symbol_leading_char (abfd);
715 if (constructor)
716 strcpy (s, "__CTOR_LIST__");
717 else
718 strcpy (s, "__DTOR_LIST__");
719
720 if (write_map)
721 info_msg ("Adding %s to constructor/destructor set %s\n", name, set_name);
722
723 h = bfd_link_hash_lookup (info->hash, set_name, true, true, true);
724 if (h == (struct bfd_link_hash_entry *) NULL)
725 einfo ("%P%F: bfd_link_hash_lookup failed: %E");
726 if (h->type == bfd_link_hash_new)
727 {
728 h->type = bfd_link_hash_undefined;
729 h->u.undef.abfd = abfd;
730 /* We don't call bfd_link_add_undef to add this to the list of
731 undefined symbols because we are going to define it
732 ourselves. */
733 }
734
735 ldctor_add_set_entry (h, bitsize, section, value);
736 return true;
737 }
738
739 /* This is called when there is a reference to a warning symbol. */
740
741 /*ARGSUSED*/
742 static boolean
743 warning_callback (info, warning)
744 struct bfd_link_info *info;
745 const char *warning;
746 {
747 einfo ("%P: %s\n", warning);
748 return true;
749 }
750
751 /* This is called when an undefined symbol is found. */
752
753 /*ARGSUSED*/
754 static boolean
755 undefined_symbol (info, name, abfd, section, address)
756 struct bfd_link_info *info;
757 const char *name;
758 bfd *abfd;
759 asection *section;
760 bfd_vma address;
761 {
762 static char *error_name;
763 static unsigned int error_count;
764
765 #define MAX_ERRORS_IN_A_ROW 5
766
767 /* We never print more than a reasonable number of errors in a row
768 for a single symbol. */
769 if (error_name != (char *) NULL
770 && strcmp (name, error_name) == 0)
771 ++error_count;
772 else
773 {
774 error_count = 0;
775 if (error_name != (char *) NULL)
776 free (error_name);
777 error_name = buystring (name);
778 }
779
780 if (error_count < MAX_ERRORS_IN_A_ROW)
781 einfo ("%X%C: undefined reference to `%T'\n",
782 abfd, section, address, name);
783 else if (error_count == MAX_ERRORS_IN_A_ROW)
784 einfo ("%C: more undefined references to `%T' follow\n",
785 abfd, section, address, name);
786
787 return true;
788 }
789
790 /* This is called when a reloc overflows. */
791
792 /*ARGSUSED*/
793 static boolean
794 reloc_overflow (info, name, reloc_name, addend, abfd, section, address)
795 struct bfd_link_info *info;
796 const char *name;
797 const char *reloc_name;
798 bfd_vma addend;
799 bfd *abfd;
800 asection *section;
801 bfd_vma address;
802 {
803 einfo ("%X%C: relocation truncated to fit: %s %T", abfd, section,
804 address, reloc_name, name);
805 if (addend != 0)
806 einfo ("+%v", addend);
807 einfo ("\n");
808 return true;
809 }
810
811 /* This is called when a dangerous relocation is made. */
812
813 /*ARGSUSED*/
814 static boolean
815 reloc_dangerous (info, message, abfd, section, address)
816 struct bfd_link_info *info;
817 const char *message;
818 bfd *abfd;
819 asection *section;
820 bfd_vma address;
821 {
822 einfo ("%X%C: dangerous relocation: %s\n", abfd, section, address, message);
823 return true;
824 }
825
826 /* This is called when a reloc is being generated attached to a symbol
827 that is not being output. */
828
829 /*ARGSUSED*/
830 static boolean
831 unattached_reloc (info, name, abfd, section, address)
832 struct bfd_link_info *info;
833 const char *name;
834 bfd *abfd;
835 asection *section;
836 bfd_vma address;
837 {
838 einfo ("%X%C: reloc refers to symbol `%T' which is not being output\n",
839 abfd, section, address, name);
840 return true;
841 }
842
843 /* This is called when a symbol in notice_hash is found. Symbols are
844 put in notice_hash using the -y option. */
845
846 /*ARGSUSED*/
847 static boolean
848 notice_ysym (info, name, abfd, section, value)
849 struct bfd_link_info *info;
850 const char *name;
851 bfd *abfd;
852 asection *section;
853 bfd_vma value;
854 {
855 einfo ("%B: %s %s\n", abfd,
856 section != &bfd_und_section ? "definition of" : "reference to",
857 name);
858 return true;
859 }