bfe74f049f1b15e73eee3575d77b447813a4d32b
[deliverable/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 "libiberty.h"
26 #include "bfdlink.h"
27
28 #include "config.h"
29 #include "ld.h"
30 #include "ldmain.h"
31 #include "ldmisc.h"
32 #include "ldwrite.h"
33 #include "ldgram.h"
34 #include "ldexp.h"
35 #include "ldlang.h"
36 #include "ldemul.h"
37 #include "ldlex.h"
38 #include "ldfile.h"
39 #include "ldctor.h"
40
41 /* Somewhere above, sys/stat.h got included . . . . */
42 #if !defined(S_ISDIR) && defined(S_IFDIR)
43 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
44 #endif
45
46 #include <string.h>
47
48 static char *get_emulation PARAMS ((int, char **));
49 static void set_scripts_dir PARAMS ((void));
50
51 /* EXPORTS */
52
53 char *default_target;
54 const char *output_filename = "a.out";
55
56 /* Name this program was invoked by. */
57 char *program_name;
58
59 /* The file that we're creating */
60 bfd *output_bfd = 0;
61
62 /* Set by -G argument, for MIPS ECOFF target. */
63 int g_switch_value = 8;
64
65 /* Nonzero means print names of input files as processed. */
66 boolean trace_files;
67
68 /* Nonzero means same, but note open failures, too. */
69 boolean trace_file_tries;
70
71 /* Nonzero means version number was printed, so exit successfully
72 instead of complaining if no input files are given. */
73 boolean version_printed;
74
75 args_type command_line;
76
77 ld_config_type config;
78
79 static boolean check_for_scripts_dir PARAMS ((char *dir));
80 static boolean add_archive_element PARAMS ((struct bfd_link_info *, bfd *,
81 const char *));
82 static boolean multiple_definition PARAMS ((struct bfd_link_info *,
83 const char *,
84 bfd *, asection *, bfd_vma,
85 bfd *, asection *, bfd_vma));
86 static boolean multiple_common PARAMS ((struct bfd_link_info *,
87 const char *, bfd *,
88 enum bfd_link_hash_type, bfd_vma,
89 bfd *, enum bfd_link_hash_type,
90 bfd_vma));
91 static boolean add_to_set PARAMS ((struct bfd_link_info *,
92 struct bfd_link_hash_entry *,
93 bfd_reloc_code_real_type,
94 bfd *, asection *, bfd_vma));
95 static boolean constructor_callback PARAMS ((struct bfd_link_info *,
96 boolean constructor,
97 const char *name,
98 bfd *, asection *, bfd_vma));
99 static boolean warning_callback PARAMS ((struct bfd_link_info *,
100 const char *));
101 static boolean undefined_symbol PARAMS ((struct bfd_link_info *,
102 const char *, bfd *,
103 asection *, bfd_vma));
104 static boolean reloc_overflow PARAMS ((struct bfd_link_info *, const char *,
105 const char *, bfd_vma,
106 bfd *, asection *, bfd_vma));
107 static boolean reloc_dangerous PARAMS ((struct bfd_link_info *, const char *,
108 bfd *, asection *, bfd_vma));
109 static boolean unattached_reloc PARAMS ((struct bfd_link_info *,
110 const char *, bfd *, asection *,
111 bfd_vma));
112 static boolean notice_ysym PARAMS ((struct bfd_link_info *, const char *,
113 bfd *, asection *, bfd_vma));
114
115 static struct bfd_link_callbacks link_callbacks =
116 {
117 add_archive_element,
118 multiple_definition,
119 multiple_common,
120 add_to_set,
121 constructor_callback,
122 warning_callback,
123 undefined_symbol,
124 reloc_overflow,
125 reloc_dangerous,
126 unattached_reloc,
127 notice_ysym
128 };
129
130 struct bfd_link_info link_info;
131 \f
132 static void
133 remove_output ()
134 {
135 if (output_filename)
136 {
137 if (output_bfd && output_bfd->iostream)
138 fclose((FILE *)(output_bfd->iostream));
139 if (delete_output_file_on_failure)
140 unlink (output_filename);
141 }
142 }
143
144 int
145 main (argc, argv)
146 int argc;
147 char **argv;
148 {
149 char *emulation;
150 long start_time = get_run_time ();
151
152 program_name = argv[0];
153 xmalloc_set_program_name (program_name);
154
155 bfd_init ();
156
157 xatexit (remove_output);
158
159 /* Initialize the data about options. */
160 trace_files = trace_file_tries = version_printed = false;
161 config.traditional_format = false;
162 config.build_constructors = true;
163 config.dynamic_link = false;
164 command_line.force_common_definition = false;
165
166 link_info.callbacks = &link_callbacks;
167 link_info.relocateable = false;
168 link_info.strip = strip_none;
169 link_info.discard = discard_none;
170 link_info.lprefix_len = 1;
171 link_info.lprefix = "L";
172 link_info.keep_memory = true;
173 link_info.input_bfds = NULL;
174 link_info.create_object_symbols_section = NULL;
175 link_info.hash = NULL;
176 link_info.keep_hash = NULL;
177 link_info.notice_hash = NULL;
178
179 ldfile_add_arch ("");
180
181 config.make_executable = true;
182 force_make_executable = false;
183 config.magic_demand_paged = true;
184 config.text_read_only = true;
185 config.make_executable = true;
186
187 emulation = get_emulation (argc, argv);
188 ldemul_choose_mode (emulation);
189 default_target = ldemul_choose_target ();
190 lang_init ();
191 ldemul_before_parse ();
192 lang_has_input_file = false;
193 parse_args (argc, argv);
194
195 if (link_info.relocateable)
196 {
197 if (command_line.relax)
198 einfo ("%P%F: -relax and -r may not be used together\n");
199 if (config.dynamic_link)
200 einfo ("%P%F: -r and -call_shared may not be used together\n");
201 if (link_info.strip == strip_all)
202 einfo ("%P%F: -r and -s may not be used together\n");
203 }
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 ldfile_open_command_file (s);
217 else
218 lex_redirect (s);
219 parser_input = input_script;
220 yyparse ();
221 }
222
223 lang_final ();
224
225 if (lang_has_input_file == false)
226 {
227 if (version_printed)
228 xexit (0);
229 einfo ("%P%F: no input files\n");
230 }
231
232 if (trace_files)
233 {
234 info_msg ("%P: mode %s\n", emulation);
235 }
236
237 ldemul_after_parse ();
238
239
240 if (config.map_filename)
241 {
242 if (strcmp (config.map_filename, "-") == 0)
243 {
244 config.map_file = stdout;
245 }
246 else
247 {
248 config.map_file = fopen (config.map_filename, FOPEN_WT);
249 if (config.map_file == (FILE *) NULL)
250 {
251 einfo ("%P%F: cannot open map file %s: %E\n",
252 config.map_filename);
253 }
254 }
255 }
256
257
258 lang_process ();
259
260 /* Print error messages for any missing symbols, for any warning
261 symbols, and possibly multiple definitions */
262
263
264 if (config.text_read_only)
265 {
266 /* Look for a text section and mark the readonly attribute in it */
267 asection *found = bfd_get_section_by_name (output_bfd, ".text");
268
269 if (found != (asection *) NULL)
270 {
271 found->flags |= SEC_READONLY;
272 }
273 }
274
275 if (link_info.relocateable)
276 output_bfd->flags &= ~EXEC_P;
277 else
278 output_bfd->flags |= EXEC_P;
279
280 ldwrite ();
281
282 /* Even if we're producing relocateable output, some non-fatal errors should
283 be reported in the exit status. (What non-fatal errors, if any, do we
284 want to ignore for relocateable output?) */
285
286 if (config.make_executable == false && force_make_executable == false)
287 {
288 if (trace_files == true)
289 {
290 einfo ("%P: link errors found, deleting executable `%s'\n",
291 output_filename);
292 }
293
294 if (output_bfd->iostream)
295 fclose ((FILE *) (output_bfd->iostream));
296
297 unlink (output_filename);
298 xexit (1);
299 }
300 else
301 {
302 if (! bfd_close (output_bfd))
303 einfo ("%F%B: final close failed: %E\n", 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, false);
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->next = NULL;
557 input->just_syms_flag = false;
558 input->loaded = false;
559 input->search_dirs_flag = false;
560
561 /* FIXME: The following fields are not set: header.next,
562 header.type, closed, passive_position, symbol_count,
563 next_real_file, is_archive, target, real, common_section,
564 common_output_section, complained. This bit of code is from the
565 old decode_library_subfile function. I don't know whether any of
566 those fields matters. */
567
568 ldlang_add_file (input);
569
570 if (config.map_file != (FILE *) NULL)
571 minfo ("%s needed due to %T\n", abfd->filename, name);
572
573 if (trace_files || trace_file_tries)
574 info_msg ("%I\n", input);
575
576 return true;
577 }
578
579 /* This is called when BFD has discovered a symbol which is defined
580 multiple times. */
581
582 /*ARGSUSED*/
583 static boolean
584 multiple_definition (info, name, obfd, osec, oval, nbfd, nsec, nval)
585 struct bfd_link_info *info;
586 const char *name;
587 bfd *obfd;
588 asection *osec;
589 bfd_vma oval;
590 bfd *nbfd;
591 asection *nsec;
592 bfd_vma nval;
593 {
594 einfo ("%X%C: multiple definition of `%T'\n",
595 nbfd, nsec, nval, name);
596 if (obfd != (bfd *) NULL)
597 einfo ("%C: first defined here\n", obfd, osec, oval);
598 return true;
599 }
600
601 /* This is called when there is a definition of a common symbol, or
602 when a common symbol is found for a symbol that is already defined,
603 or when two common symbols are found. We only do something if
604 -warn-common was used. */
605
606 /*ARGSUSED*/
607 static boolean
608 multiple_common (info, name, obfd, otype, osize, nbfd, ntype, nsize)
609 struct bfd_link_info *info;
610 const char *name;
611 bfd *obfd;
612 enum bfd_link_hash_type otype;
613 bfd_vma osize;
614 bfd *nbfd;
615 enum bfd_link_hash_type ntype;
616 bfd_vma nsize;
617 {
618 if (! config.warn_common)
619 return true;
620
621 if (ntype == bfd_link_hash_defined)
622 {
623 ASSERT (otype == bfd_link_hash_common);
624 einfo ("%B: warning: definition of `%T' overriding common\n",
625 nbfd, name);
626 einfo ("%B: warning: common is here\n", obfd);
627 }
628 else if (otype == bfd_link_hash_defined)
629 {
630 ASSERT (ntype == bfd_link_hash_common);
631 einfo ("%B: warning: common of `%T' overridden by definition\n",
632 nbfd, name);
633 einfo ("%B: warning: defined here\n", obfd);
634 }
635 else
636 {
637 ASSERT (otype == bfd_link_hash_common && ntype == bfd_link_hash_common);
638 if (osize > nsize)
639 {
640 einfo ("%B: warning: common of `%T' overridden by larger common\n",
641 nbfd, name);
642 einfo ("%B: warning: larger common is here\n", obfd);
643 }
644 else if (nsize > osize)
645 {
646 einfo ("%B: warning: common of `%T' overriding smaller common\n",
647 nbfd, name);
648 einfo ("%B: warning: smaller common is here\n", obfd);
649 }
650 else
651 {
652 einfo ("%B: warning: multiple common of `%T'\n", nbfd, name);
653 einfo ("%B: warning: previous common is here\n", obfd);
654 }
655 }
656
657 return true;
658 }
659
660 /* This is called when BFD has discovered a set element. H is the
661 entry in the linker hash table for the set. SECTION and VALUE
662 represent a value which should be added to the set. */
663
664 /*ARGSUSED*/
665 static boolean
666 add_to_set (info, h, reloc, abfd, section, value)
667 struct bfd_link_info *info;
668 struct bfd_link_hash_entry *h;
669 bfd_reloc_code_real_type reloc;
670 bfd *abfd;
671 asection *section;
672 bfd_vma value;
673 {
674 if (! config.build_constructors)
675 return true;
676
677 ldctor_add_set_entry (h, reloc, section, value);
678
679 if (h->type == bfd_link_hash_new)
680 {
681 h->type = bfd_link_hash_undefined;
682 h->u.undef.abfd = abfd;
683 /* We don't call bfd_link_add_undef to add this to the list of
684 undefined symbols because we are going to define it
685 ourselves. */
686 }
687
688 return true;
689 }
690
691 /* This is called when BFD has discovered a constructor. This is only
692 called for some object file formats--those which do not handle
693 constructors in some more clever fashion. This is similar to
694 adding an element to a set, but less general. */
695
696 static boolean
697 constructor_callback (info, constructor, name, abfd, section, value)
698 struct bfd_link_info *info;
699 boolean constructor;
700 const char *name;
701 bfd *abfd;
702 asection *section;
703 bfd_vma value;
704 {
705 char *set_name;
706 char *s;
707 struct bfd_link_hash_entry *h;
708
709 if (! config.build_constructors)
710 return true;
711
712 /* Ensure that BFD_RELOC_CTOR exists now, so that we can give a
713 useful error message. */
714 if (bfd_reloc_type_lookup (output_bfd, BFD_RELOC_CTOR) == NULL)
715 einfo ("%P%F: BFD backend error: BFD_RELOC_CTOR unsupported");
716
717 set_name = (char *) alloca (1 + sizeof "__CTOR_LIST__");
718 s = set_name;
719 if (bfd_get_symbol_leading_char (abfd) != '\0')
720 *s++ = bfd_get_symbol_leading_char (abfd);
721 if (constructor)
722 strcpy (s, "__CTOR_LIST__");
723 else
724 strcpy (s, "__DTOR_LIST__");
725
726 if (config.map_file != (FILE *) NULL)
727 fprintf (config.map_file,
728 "Adding %s to constructor/destructor set %s\n", name, set_name);
729
730 h = bfd_link_hash_lookup (info->hash, set_name, true, true, true);
731 if (h == (struct bfd_link_hash_entry *) NULL)
732 einfo ("%P%F: bfd_link_hash_lookup failed: %E");
733 if (h->type == bfd_link_hash_new)
734 {
735 h->type = bfd_link_hash_undefined;
736 h->u.undef.abfd = abfd;
737 /* We don't call bfd_link_add_undef to add this to the list of
738 undefined symbols because we are going to define it
739 ourselves. */
740 }
741
742 ldctor_add_set_entry (h, BFD_RELOC_CTOR, section, value);
743 return true;
744 }
745
746 /* This is called when there is a reference to a warning symbol. */
747
748 /*ARGSUSED*/
749 static boolean
750 warning_callback (info, warning)
751 struct bfd_link_info *info;
752 const char *warning;
753 {
754 einfo ("%P: %s\n", warning);
755 return true;
756 }
757
758 /* This is called when an undefined symbol is found. */
759
760 /*ARGSUSED*/
761 static boolean
762 undefined_symbol (info, name, abfd, section, address)
763 struct bfd_link_info *info;
764 const char *name;
765 bfd *abfd;
766 asection *section;
767 bfd_vma address;
768 {
769 static char *error_name;
770 static unsigned int error_count;
771
772 #define MAX_ERRORS_IN_A_ROW 5
773
774 /* We never print more than a reasonable number of errors in a row
775 for a single symbol. */
776 if (error_name != (char *) NULL
777 && strcmp (name, error_name) == 0)
778 ++error_count;
779 else
780 {
781 error_count = 0;
782 if (error_name != (char *) NULL)
783 free (error_name);
784 error_name = buystring (name);
785 }
786
787 if (error_count < MAX_ERRORS_IN_A_ROW)
788 einfo ("%X%C: undefined reference to `%T'\n",
789 abfd, section, address, name);
790 else if (error_count == MAX_ERRORS_IN_A_ROW)
791 einfo ("%C: more undefined references to `%T' follow\n",
792 abfd, section, address, name);
793
794 return true;
795 }
796
797 /* This is called when a reloc overflows. */
798
799 /*ARGSUSED*/
800 static boolean
801 reloc_overflow (info, name, reloc_name, addend, abfd, section, address)
802 struct bfd_link_info *info;
803 const char *name;
804 const char *reloc_name;
805 bfd_vma addend;
806 bfd *abfd;
807 asection *section;
808 bfd_vma address;
809 {
810 if (abfd == (bfd *) NULL)
811 einfo ("%P%X: generated");
812 else
813 einfo ("%X%C:", abfd, section, address);
814 einfo (" relocation truncated to fit: %s %T", reloc_name, name);
815 if (addend != 0)
816 einfo ("+%v", addend);
817 einfo ("\n");
818 return true;
819 }
820
821 /* This is called when a dangerous relocation is made. */
822
823 /*ARGSUSED*/
824 static boolean
825 reloc_dangerous (info, message, abfd, section, address)
826 struct bfd_link_info *info;
827 const char *message;
828 bfd *abfd;
829 asection *section;
830 bfd_vma address;
831 {
832 if (abfd == (bfd *) NULL)
833 einfo ("%P%X: generated");
834 else
835 einfo ("%X%C:", abfd, section, address);
836 einfo ("dangerous relocation: %s\n", message);
837 return true;
838 }
839
840 /* This is called when a reloc is being generated attached to a symbol
841 that is not being output. */
842
843 /*ARGSUSED*/
844 static boolean
845 unattached_reloc (info, name, abfd, section, address)
846 struct bfd_link_info *info;
847 const char *name;
848 bfd *abfd;
849 asection *section;
850 bfd_vma address;
851 {
852 if (abfd == (bfd *) NULL)
853 einfo ("%P%X: generated");
854 else
855 einfo ("%X%C:", abfd, section, address);
856 einfo (" reloc refers to symbol `%T' which is not being output\n", name);
857 return true;
858 }
859
860 /* This is called when a symbol in notice_hash is found. Symbols are
861 put in notice_hash using the -y option. */
862
863 /*ARGSUSED*/
864 static boolean
865 notice_ysym (info, name, abfd, section, value)
866 struct bfd_link_info *info;
867 const char *name;
868 bfd *abfd;
869 asection *section;
870 bfd_vma value;
871 {
872 einfo ("%B: %s %s\n", abfd,
873 section != &bfd_und_section ? "definition of" : "reference to",
874 name);
875 return true;
876 }
This page took 0.046296 seconds and 4 git commands to generate.