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