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