ldmain.c revision 1.6.12.1 1 /* Main program of GNU linker.
2 Copyright (C) 1991-2018 Free Software Foundation, Inc.
3 Written by Steve Chamberlain steve (at) cygnus.com
4
5 This file is part of the GNU Binutils.
6
7 This program 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 3 of the License, or
10 (at your option) any later version.
11
12 This program 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 this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
21
22 #include "sysdep.h"
23 #include "bfd.h"
24 #include "safe-ctype.h"
25 #include "libiberty.h"
26 #include "progress.h"
27 #include "bfdlink.h"
28 #include "filenames.h"
29
30 #include "ld.h"
31 #include "ldmain.h"
32 #include "ldmisc.h"
33 #include "ldwrite.h"
34 #include "ldexp.h"
35 #include "ldlang.h"
36 #include <ldgram.h>
37 #include "ldlex.h"
38 #include "ldfile.h"
39 #include "ldemul.h"
40 #include "ldctor.h"
41 #ifdef ENABLE_PLUGINS
42 #include "plugin.h"
43 #include "plugin-api.h"
44 #endif /* ENABLE_PLUGINS */
45
46 /* Somewhere above, sys/stat.h got included. */
47 #if !defined(S_ISDIR) && defined(S_IFDIR)
48 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
49 #endif
50
51 #include <string.h>
52
53 #ifndef TARGET_SYSTEM_ROOT
54 #define TARGET_SYSTEM_ROOT ""
55 #endif
56
57 /* EXPORTS */
58
59 FILE *saved_script_handle = NULL;
60 FILE *previous_script_handle = NULL;
61 bfd_boolean force_make_executable = FALSE;
62
63 char *default_target;
64 const char *output_filename = "a.out";
65
66 /* Name this program was invoked by. */
67 char *program_name;
68
69 /* The prefix for system library directories. */
70 const char *ld_sysroot;
71
72 /* The canonical representation of ld_sysroot. */
73 char *ld_canon_sysroot;
74 int ld_canon_sysroot_len;
75
76 /* Set by -G argument, for targets like MIPS ELF. */
77 int g_switch_value = 8;
78
79 /* Nonzero means print names of input files as processed. */
80 bfd_boolean trace_files;
81
82 /* Nonzero means report actions taken by the linker, and describe the linker script in use. */
83 bfd_boolean verbose;
84
85 /* Nonzero means version number was printed, so exit successfully
86 instead of complaining if no input files are given. */
87 bfd_boolean version_printed;
88
89 /* TRUE if we should demangle symbol names. */
90 bfd_boolean demangling;
91
92 args_type command_line;
93
94 ld_config_type config;
95
96 sort_type sort_section;
97
98 static const char *get_sysroot
99 (int, char **);
100 static char *get_emulation
101 (int, char **);
102 static bfd_boolean add_archive_element
103 (struct bfd_link_info *, bfd *, const char *, bfd **);
104 static void multiple_definition
105 (struct bfd_link_info *, struct bfd_link_hash_entry *,
106 bfd *, asection *, bfd_vma);
107 static void multiple_common
108 (struct bfd_link_info *, struct bfd_link_hash_entry *,
109 bfd *, enum bfd_link_hash_type, bfd_vma);
110 static void add_to_set
111 (struct bfd_link_info *, struct bfd_link_hash_entry *,
112 bfd_reloc_code_real_type, bfd *, asection *, bfd_vma);
113 static void constructor_callback
114 (struct bfd_link_info *, bfd_boolean, const char *, bfd *,
115 asection *, bfd_vma);
116 static void warning_callback
117 (struct bfd_link_info *, const char *, const char *, bfd *,
118 asection *, bfd_vma);
119 static void warning_find_reloc
120 (bfd *, asection *, void *);
121 static void undefined_symbol
122 (struct bfd_link_info *, const char *, bfd *, asection *, bfd_vma,
123 bfd_boolean);
124 static void reloc_overflow
125 (struct bfd_link_info *, struct bfd_link_hash_entry *, const char *,
126 const char *, bfd_vma, bfd *, asection *, bfd_vma);
127 static void reloc_dangerous
128 (struct bfd_link_info *, const char *, bfd *, asection *, bfd_vma);
129 static void unattached_reloc
130 (struct bfd_link_info *, const char *, bfd *, asection *, bfd_vma);
131 static bfd_boolean notice
132 (struct bfd_link_info *, struct bfd_link_hash_entry *,
133 struct bfd_link_hash_entry *, bfd *, asection *, bfd_vma, flagword);
134
135 static struct bfd_link_callbacks link_callbacks =
136 {
137 add_archive_element,
138 multiple_definition,
139 multiple_common,
140 add_to_set,
141 constructor_callback,
142 warning_callback,
143 undefined_symbol,
144 reloc_overflow,
145 reloc_dangerous,
146 unattached_reloc,
147 notice,
148 einfo,
149 info_msg,
150 minfo,
151 ldlang_override_segment_assignment
152 };
153
154 static bfd_assert_handler_type default_bfd_assert_handler;
155 static bfd_error_handler_type default_bfd_error_handler;
156
157 struct bfd_link_info link_info;
158
159 static void
161 ld_cleanup (void)
162 {
163 bfd_cache_close_all ();
164 #ifdef ENABLE_PLUGINS
165 plugin_call_cleanup ();
166 #endif
167 if (output_filename && delete_output_file_on_failure)
168 unlink_if_ordinary (output_filename);
169 }
170
171 /* Hook to notice BFD assertions. */
172
173 static void
174 ld_bfd_assert_handler (const char *fmt, const char *bfdver,
175 const char *file, int line)
176 {
177 config.make_executable = FALSE;
178 (*default_bfd_assert_handler) (fmt, bfdver, file, line);
179 }
180
181 /* Hook the bfd error/warning handler for --fatal-warnings. */
182
183 static void
184 ld_bfd_error_handler (const char *fmt, va_list ap)
185 {
186 if (config.fatal_warnings)
187 config.make_executable = FALSE;
188 (*default_bfd_error_handler) (fmt, ap);
189 }
190
191 int
192 main (int argc, char **argv)
193 {
194 char *emulation;
195 long start_time = get_run_time ();
196
197 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
198 setlocale (LC_MESSAGES, "");
199 #endif
200 #if defined (HAVE_SETLOCALE)
201 setlocale (LC_CTYPE, "");
202 #endif
203 bindtextdomain (PACKAGE, LOCALEDIR);
204 textdomain (PACKAGE);
205
206 program_name = argv[0];
207 xmalloc_set_program_name (program_name);
208
209 START_PROGRESS (program_name, 0);
210
211 expandargv (&argc, &argv);
212
213 bfd_init ();
214
215 bfd_set_error_program_name (program_name);
216
217 /* We want to notice and fail on those nasty BFD assertions which are
218 likely to signal incorrect output being generated but otherwise may
219 leave no trace. */
220 default_bfd_assert_handler = bfd_set_assert_handler (ld_bfd_assert_handler);
221
222 /* Also hook the bfd error/warning handler for --fatal-warnings. */
223 default_bfd_error_handler = bfd_set_error_handler (ld_bfd_error_handler);
224
225 xatexit (ld_cleanup);
226
227 /* Set up the sysroot directory. */
228 ld_sysroot = get_sysroot (argc, argv);
229 if (*ld_sysroot)
230 ld_canon_sysroot = lrealpath (ld_sysroot);
231 if (ld_canon_sysroot)
232 ld_canon_sysroot_len = strlen (ld_canon_sysroot);
233 else
234 ld_canon_sysroot_len = -1;
235
236 /* Set the default BFD target based on the configured target. Doing
237 this permits the linker to be configured for a particular target,
238 and linked against a shared BFD library which was configured for
239 a different target. The macro TARGET is defined by Makefile. */
240 if (!bfd_set_default_target (TARGET))
241 {
242 einfo (_("%X%P: can't set BFD default target to `%s': %E\n"), TARGET);
243 xexit (1);
244 }
245
246 #if YYDEBUG
247 {
248 extern int yydebug;
249 yydebug = 1;
250 }
251 #endif
252
253 config.build_constructors = TRUE;
254 config.rpath_separator = ':';
255 config.split_by_reloc = (unsigned) -1;
256 config.split_by_file = (bfd_size_type) -1;
257 config.make_executable = TRUE;
258 config.magic_demand_paged = TRUE;
259 config.text_read_only = TRUE;
260 link_info.disable_target_specific_optimizations = -1;
261
262 command_line.warn_mismatch = TRUE;
263 command_line.warn_search_mismatch = TRUE;
264 command_line.check_section_addresses = -1;
265
266 /* We initialize DEMANGLING based on the environment variable
267 COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the
268 output of the linker, unless COLLECT_NO_DEMANGLE is set in the
269 environment. Acting the same way here lets us provide the same
270 interface by default. */
271 demangling = getenv ("COLLECT_NO_DEMANGLE") == NULL;
272
273 link_info.allow_undefined_version = TRUE;
274 link_info.keep_memory = TRUE;
275 link_info.combreloc = TRUE;
276 link_info.strip_discarded = TRUE;
277 link_info.emit_hash = DEFAULT_EMIT_SYSV_HASH;
278 link_info.emit_gnu_hash = DEFAULT_EMIT_GNU_HASH;
279 link_info.callbacks = &link_callbacks;
280 link_info.input_bfds_tail = &link_info.input_bfds;
281 /* SVR4 linkers seem to set DT_INIT and DT_FINI based on magic _init
282 and _fini symbols. We are compatible. */
283 link_info.init_function = "_init";
284 link_info.fini_function = "_fini";
285 link_info.relax_pass = 1;
286 link_info.extern_protected_data = -1;
287 link_info.dynamic_undefined_weak = -1;
288 link_info.pei386_auto_import = -1;
289 link_info.spare_dynamic_tags = 5;
290 link_info.path_separator = ':';
291 #ifdef DEFAULT_FLAG_COMPRESS_DEBUG
292 link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
293 #endif
294 #ifdef DEFAULT_NEW_DTAGS
295 link_info.new_dtags = DEFAULT_NEW_DTAGS;
296 #endif
297
298 ldfile_add_arch ("");
299 emulation = get_emulation (argc, argv);
300 ldemul_choose_mode (emulation);
301 default_target = ldemul_choose_target (argc, argv);
302 config.maxpagesize = bfd_emul_get_maxpagesize (default_target);
303 config.commonpagesize = bfd_emul_get_commonpagesize (default_target);
304 lang_init ();
305 ldexp_init ();
306 ldemul_before_parse ();
307 lang_has_input_file = FALSE;
308 parse_args (argc, argv);
309
310 if (config.hash_table_size != 0)
311 bfd_hash_set_default_size (config.hash_table_size);
312
313 #ifdef ENABLE_PLUGINS
314 /* Now all the plugin arguments have been gathered, we can load them. */
315 plugin_load_plugins ();
316 #endif /* ENABLE_PLUGINS */
317
318 ldemul_set_symbols ();
319
320 /* If we have not already opened and parsed a linker script,
321 try the default script from command line first. */
322 if (saved_script_handle == NULL
323 && command_line.default_script != NULL)
324 {
325 ldfile_open_command_file (command_line.default_script);
326 parser_input = input_script;
327 yyparse ();
328 }
329
330 /* If we have not already opened and parsed a linker script
331 read the emulation's appropriate default script. */
332 if (saved_script_handle == NULL)
333 {
334 int isfile;
335 char *s = ldemul_get_script (&isfile);
336
337 if (isfile)
338 ldfile_open_default_command_file (s);
339 else
340 {
341 lex_string = s;
342 lex_redirect (s, _("built in linker script"), 1);
343 }
344 parser_input = input_script;
345 yyparse ();
346 lex_string = NULL;
347 }
348
349 if (verbose)
350 {
351 if (saved_script_handle)
352 info_msg (_("using external linker script:"));
353 else
354 info_msg (_("using internal linker script:"));
355 info_msg ("\n==================================================\n");
356
357 if (saved_script_handle)
358 {
359 static const int ld_bufsz = 8193;
360 size_t n;
361 char *buf = (char *) xmalloc (ld_bufsz);
362
363 rewind (saved_script_handle);
364 while ((n = fread (buf, 1, ld_bufsz - 1, saved_script_handle)) > 0)
365 {
366 buf[n] = 0;
367 info_msg ("%s", buf);
368 }
369 rewind (saved_script_handle);
370 free (buf);
371 }
372 else
373 {
374 int isfile;
375
376 info_msg (ldemul_get_script (&isfile));
377 }
378
379 info_msg ("\n==================================================\n");
380 }
381
382 if (command_line.force_group_allocation
383 || !bfd_link_relocatable (&link_info))
384 link_info.resolve_section_groups = TRUE;
385 else
386 link_info.resolve_section_groups = FALSE;
387
388 if (command_line.print_output_format)
389 info_msg ("%s\n", lang_get_output_target ());
390
391 lang_final ();
392
393 /* If the only command line argument has been -v or --version or --verbose
394 then ignore any input files provided by linker scripts and exit now.
395 We do not want to create an output file when the linker is just invoked
396 to provide version information. */
397 if (argc == 2 && version_printed)
398 xexit (0);
399
400 if (link_info.inhibit_common_definition && !bfd_link_dll (&link_info))
401 einfo (_("%P%F: --no-define-common may not be used without -shared\n"));
402
403 if (!lang_has_input_file)
404 {
405 if (version_printed || command_line.print_output_format)
406 xexit (0);
407 einfo (_("%P%F: no input files\n"));
408 }
409
410 if (trace_files)
411 info_msg (_("%P: mode %s\n"), emulation);
412
413 ldemul_after_parse ();
414
415 if (config.map_filename)
416 {
417 if (strcmp (config.map_filename, "-") == 0)
418 {
419 config.map_file = stdout;
420 }
421 else
422 {
423 config.map_file = fopen (config.map_filename, FOPEN_WT);
424 if (config.map_file == (FILE *) NULL)
425 {
426 bfd_set_error (bfd_error_system_call);
427 einfo (_("%P%F: cannot open map file %s: %E\n"),
428 config.map_filename);
429 }
430 }
431 }
432
433 lang_process ();
434
435 /* Print error messages for any missing symbols, for any warning
436 symbols, and possibly multiple definitions. */
437 if (bfd_link_relocatable (&link_info))
438 link_info.output_bfd->flags &= ~EXEC_P;
439 else
440 link_info.output_bfd->flags |= EXEC_P;
441
442 if ((link_info.compress_debug & COMPRESS_DEBUG))
443 {
444 link_info.output_bfd->flags |= BFD_COMPRESS;
445 if (link_info.compress_debug == COMPRESS_DEBUG_GABI_ZLIB)
446 link_info.output_bfd->flags |= BFD_COMPRESS_GABI;
447 }
448
449 ldwrite ();
450
451 if (config.map_file != NULL)
452 lang_map ();
453 if (command_line.cref)
454 output_cref (config.map_file != NULL ? config.map_file : stdout);
455 if (nocrossref_list != NULL)
456 check_nocrossrefs ();
457 if (command_line.print_memory_usage)
458 lang_print_memory_usage ();
459 #if 0
460 {
461 struct bfd_link_hash_entry *h;
462
463 h = bfd_link_hash_lookup (link_info.hash, "__image_base__", 0,0,1);
464 fprintf (stderr, "lookup = %p val %lx\n", h, h ? h->u.def.value : 1);
465 }
466 #endif
467 ldexp_finish ();
468 lang_finish ();
469
470 /* Even if we're producing relocatable output, some non-fatal errors should
471 be reported in the exit status. (What non-fatal errors, if any, do we
472 want to ignore for relocatable output?) */
473 if (!config.make_executable && !force_make_executable)
474 {
475 if (trace_files)
476 einfo (_("%P: link errors found, deleting executable `%s'\n"),
477 output_filename);
478
479 /* The file will be removed by ld_cleanup. */
480 xexit (1);
481 }
482 else
483 {
484 if (!bfd_close (link_info.output_bfd))
485 einfo (_("%F%B: final close failed: %E\n"), link_info.output_bfd);
486
487 /* If the --force-exe-suffix is enabled, and we're making an
488 executable file and it doesn't end in .exe, copy it to one
489 which does. */
490 if (!bfd_link_relocatable (&link_info)
491 && command_line.force_exe_suffix)
492 {
493 int len = strlen (output_filename);
494
495 if (len < 4
496 || (strcasecmp (output_filename + len - 4, ".exe") != 0
497 && strcasecmp (output_filename + len - 4, ".dll") != 0))
498 {
499 FILE *src;
500 FILE *dst;
501 const int bsize = 4096;
502 char *buf = (char *) xmalloc (bsize);
503 int l;
504 char *dst_name = (char *) xmalloc (len + 5);
505
506 strcpy (dst_name, output_filename);
507 strcat (dst_name, ".exe");
508 src = fopen (output_filename, FOPEN_RB);
509 dst = fopen (dst_name, FOPEN_WB);
510
511 if (!src)
512 einfo (_("%P%F: unable to open for source of copy `%s'\n"),
513 output_filename);
514 if (!dst)
515 einfo (_("%P%F: unable to open for destination of copy `%s'\n"),
516 dst_name);
517 while ((l = fread (buf, 1, bsize, src)) > 0)
518 {
519 int done = fwrite (buf, 1, l, dst);
520
521 if (done != l)
522 einfo (_("%P: Error writing file `%s'\n"), dst_name);
523 }
524
525 fclose (src);
526 if (fclose (dst) == EOF)
527 einfo (_("%P: Error closing file `%s'\n"), dst_name);
528 free (dst_name);
529 free (buf);
530 }
531 }
532 }
533
534 END_PROGRESS (program_name);
535
536 if (config.stats)
537 {
538 long run_time = get_run_time () - start_time;
539
540 fflush (stdout);
541 fprintf (stderr, _("%s: total time in link: %ld.%06ld\n"),
542 program_name, run_time / 1000000, run_time % 1000000);
543 fflush (stderr);
544 }
545
546 /* Prevent ld_cleanup from doing anything, after a successful link. */
547 output_filename = NULL;
548
549 xexit (0);
550 return 0;
551 }
552
553 /* If the configured sysroot is relocatable, try relocating it based on
554 default prefix FROM. Return the relocated directory if it exists,
555 otherwise return null. */
556
557 static char *
558 get_relative_sysroot (const char *from ATTRIBUTE_UNUSED)
559 {
560 #ifdef TARGET_SYSTEM_ROOT_RELOCATABLE
561 char *path;
562 struct stat s;
563
564 path = make_relative_prefix (program_name, from, TARGET_SYSTEM_ROOT);
565 if (path)
566 {
567 if (stat (path, &s) == 0 && S_ISDIR (s.st_mode))
568 return path;
569 free (path);
570 }
571 #endif
572 return 0;
573 }
574
575 /* Return the sysroot directory. Return "" if no sysroot is being used. */
576
577 static const char *
578 get_sysroot (int argc, char **argv)
579 {
580 int i;
581 const char *path;
582
583 for (i = 1; i < argc; i++)
584 if (CONST_STRNEQ (argv[i], "--sysroot="))
585 return argv[i] + strlen ("--sysroot=");
586
587 path = get_relative_sysroot (BINDIR);
588 if (path)
589 return path;
590
591 path = get_relative_sysroot (TOOLBINDIR);
592 if (path)
593 return path;
594
595 return TARGET_SYSTEM_ROOT;
596 }
597
598 /* We need to find any explicitly given emulation in order to initialize the
599 state that's needed by the lex&yacc argument parser (parse_args). */
600
601 static char *
602 get_emulation (int argc, char **argv)
603 {
604 char *emulation;
605 int i;
606
607 emulation = getenv (EMULATION_ENVIRON);
608 if (emulation == NULL)
609 emulation = DEFAULT_EMULATION;
610
611 for (i = 1; i < argc; i++)
612 {
613 if (CONST_STRNEQ (argv[i], "-m"))
614 {
615 if (argv[i][2] == '\0')
616 {
617 /* -m EMUL */
618 if (i < argc - 1)
619 {
620 emulation = argv[i + 1];
621 i++;
622 }
623 else
624 einfo (_("%P%F: missing argument to -m\n"));
625 }
626 else if (strcmp (argv[i], "-mips1") == 0
627 || strcmp (argv[i], "-mips2") == 0
628 || strcmp (argv[i], "-mips3") == 0
629 || strcmp (argv[i], "-mips4") == 0
630 || strcmp (argv[i], "-mips5") == 0
631 || strcmp (argv[i], "-mips32") == 0
632 || strcmp (argv[i], "-mips32r2") == 0
633 || strcmp (argv[i], "-mips32r6") == 0
634 || strcmp (argv[i], "-mips64") == 0
635 || strcmp (argv[i], "-mips64r2") == 0
636 || strcmp (argv[i], "-mips64r6") == 0)
637 {
638 /* FIXME: The arguments -mips1, -mips2, -mips3, etc. are
639 passed to the linker by some MIPS compilers. They
640 generally tell the linker to use a slightly different
641 library path. Perhaps someday these should be
642 implemented as emulations; until then, we just ignore
643 the arguments and hope that nobody ever creates
644 emulations named ips1, ips2 or ips3. */
645 }
646 else if (strcmp (argv[i], "-m486") == 0)
647 {
648 /* FIXME: The argument -m486 is passed to the linker on
649 some Linux systems. Hope that nobody creates an
650 emulation named 486. */
651 }
652 else
653 {
654 /* -mEMUL */
655 emulation = &argv[i][2];
656 }
657 }
658 }
659
660 return emulation;
661 }
662
663 void
664 add_ysym (const char *name)
665 {
666 if (link_info.notice_hash == NULL)
667 {
668 link_info.notice_hash
669 = (struct bfd_hash_table *) xmalloc (sizeof (struct bfd_hash_table));
670 if (!bfd_hash_table_init_n (link_info.notice_hash,
671 bfd_hash_newfunc,
672 sizeof (struct bfd_hash_entry),
673 61))
674 einfo (_("%P%F: bfd_hash_table_init failed: %E\n"));
675 }
676
677 if (bfd_hash_lookup (link_info.notice_hash, name, TRUE, TRUE) == NULL)
678 einfo (_("%P%F: bfd_hash_lookup failed: %E\n"));
679 }
680
681 void
682 add_ignoresym (struct bfd_link_info *info, const char *name)
683 {
684 if (info->ignore_hash == NULL)
685 {
686 info->ignore_hash = xmalloc (sizeof (struct bfd_hash_table));
687 if (!bfd_hash_table_init_n (info->ignore_hash,
688 bfd_hash_newfunc,
689 sizeof (struct bfd_hash_entry),
690 61))
691 einfo (_("%P%F: bfd_hash_table_init failed: %E\n"));
692 }
693
694 if (bfd_hash_lookup (info->ignore_hash, name, TRUE, TRUE) == NULL)
695 einfo (_("%P%F: bfd_hash_lookup failed: %E\n"));
696 }
697
698 /* Record a symbol to be wrapped, from the --wrap option. */
699
700 void
701 add_wrap (const char *name)
702 {
703 if (link_info.wrap_hash == NULL)
704 {
705 link_info.wrap_hash
706 = (struct bfd_hash_table *) xmalloc (sizeof (struct bfd_hash_table));
707 if (!bfd_hash_table_init_n (link_info.wrap_hash,
708 bfd_hash_newfunc,
709 sizeof (struct bfd_hash_entry),
710 61))
711 einfo (_("%P%F: bfd_hash_table_init failed: %E\n"));
712 }
713
714 if (bfd_hash_lookup (link_info.wrap_hash, name, TRUE, TRUE) == NULL)
715 einfo (_("%P%F: bfd_hash_lookup failed: %E\n"));
716 }
717
718 /* Handle the -retain-symbols-file option. */
719
720 void
721 add_keepsyms_file (const char *filename)
722 {
723 FILE *file;
724 char *buf;
725 size_t bufsize;
726 int c;
727
728 if (link_info.strip == strip_some)
729 einfo (_("%X%P: error: duplicate retain-symbols-file\n"));
730
731 file = fopen (filename, "r");
732 if (file == NULL)
733 {
734 bfd_set_error (bfd_error_system_call);
735 einfo ("%X%P: %s: %E\n", filename);
736 return;
737 }
738
739 link_info.keep_hash = (struct bfd_hash_table *)
740 xmalloc (sizeof (struct bfd_hash_table));
741 if (!bfd_hash_table_init (link_info.keep_hash, bfd_hash_newfunc,
742 sizeof (struct bfd_hash_entry)))
743 einfo (_("%P%F: bfd_hash_table_init failed: %E\n"));
744
745 bufsize = 100;
746 buf = (char *) xmalloc (bufsize);
747
748 c = getc (file);
749 while (c != EOF)
750 {
751 while (ISSPACE (c))
752 c = getc (file);
753
754 if (c != EOF)
755 {
756 size_t len = 0;
757
758 while (!ISSPACE (c) && c != EOF)
759 {
760 buf[len] = c;
761 ++len;
762 if (len >= bufsize)
763 {
764 bufsize *= 2;
765 buf = (char *) xrealloc (buf, bufsize);
766 }
767 c = getc (file);
768 }
769
770 buf[len] = '\0';
771
772 if (bfd_hash_lookup (link_info.keep_hash, buf, TRUE, TRUE) == NULL)
773 einfo (_("%P%F: bfd_hash_lookup for insertion failed: %E\n"));
774 }
775 }
776
777 if (link_info.strip != strip_none)
778 einfo (_("%P: `-retain-symbols-file' overrides `-s' and `-S'\n"));
779
780 free (buf);
781 link_info.strip = strip_some;
782 fclose (file);
783 }
784
785 /* Callbacks from the BFD linker routines. */
787
788 /* This is called when BFD has decided to include an archive member in
789 a link. */
790
791 static bfd_boolean
792 add_archive_element (struct bfd_link_info *info,
793 bfd *abfd,
794 const char *name,
795 bfd **subsbfd ATTRIBUTE_UNUSED)
796 {
797 lang_input_statement_type *input;
798 lang_input_statement_type orig_input;
799
800 input = (lang_input_statement_type *)
801 xcalloc (1, sizeof (lang_input_statement_type));
802 input->header.type = lang_input_statement_enum;
803 input->filename = abfd->filename;
804 input->local_sym_name = abfd->filename;
805 input->the_bfd = abfd;
806
807 /* Save the original data for trace files/tries below, as plugins
808 (if enabled) may possibly alter it to point to a replacement
809 BFD, but we still want to output the original BFD filename. */
810 orig_input = *input;
811 #ifdef ENABLE_PLUGINS
812 if (link_info.lto_plugin_active)
813 {
814 /* We must offer this archive member to the plugins to claim. */
815 plugin_maybe_claim (input);
816 if (input->flags.claimed)
817 {
818 if (no_more_claiming)
819 {
820 /* Don't claim new IR symbols after all IR symbols have
821 been claimed. */
822 if (trace_files || verbose)
823 info_msg ("%I: no new IR symbols to claimi\n",
824 &orig_input);
825 input->flags.claimed = 0;
826 return FALSE;
827 }
828 input->flags.claim_archive = TRUE;
829 *subsbfd = input->the_bfd;
830 }
831 }
832 #endif /* ENABLE_PLUGINS */
833
834 ldlang_add_file (input);
835
836 if (config.map_file != NULL)
837 {
838 static bfd_boolean header_printed;
839 struct bfd_link_hash_entry *h;
840 bfd *from;
841 int len;
842
843 h = bfd_link_hash_lookup (info->hash, name, FALSE, FALSE, TRUE);
844
845 if (h == NULL)
846 from = NULL;
847 else
848 {
849 switch (h->type)
850 {
851 default:
852 from = NULL;
853 break;
854
855 case bfd_link_hash_defined:
856 case bfd_link_hash_defweak:
857 from = h->u.def.section->owner;
858 break;
859
860 case bfd_link_hash_undefined:
861 case bfd_link_hash_undefweak:
862 from = h->u.undef.abfd;
863 break;
864
865 case bfd_link_hash_common:
866 from = h->u.c.p->section->owner;
867 break;
868 }
869 }
870
871 if (!header_printed)
872 {
873 minfo (_("Archive member included to satisfy reference by file (symbol)\n\n"));
874 header_printed = TRUE;
875 }
876
877 if (abfd->my_archive == NULL
878 || bfd_is_thin_archive (abfd->my_archive))
879 {
880 minfo ("%s", bfd_get_filename (abfd));
881 len = strlen (bfd_get_filename (abfd));
882 }
883 else
884 {
885 minfo ("%s(%s)", bfd_get_filename (abfd->my_archive),
886 bfd_get_filename (abfd));
887 len = (strlen (bfd_get_filename (abfd->my_archive))
888 + strlen (bfd_get_filename (abfd))
889 + 2);
890 }
891
892 if (len >= 29)
893 {
894 print_nl ();
895 len = 0;
896 }
897 while (len < 30)
898 {
899 print_space ();
900 ++len;
901 }
902
903 if (from != NULL)
904 minfo ("%B ", from);
905 if (h != NULL)
906 minfo ("(%T)\n", h->root.string);
907 else
908 minfo ("(%s)\n", name);
909 }
910
911 if (trace_files || verbose)
912 info_msg ("%I\n", &orig_input);
913 return TRUE;
914 }
915
916 /* This is called when BFD has discovered a symbol which is defined
917 multiple times. */
918
919 static void
920 multiple_definition (struct bfd_link_info *info,
921 struct bfd_link_hash_entry *h,
922 bfd *nbfd,
923 asection *nsec,
924 bfd_vma nval)
925 {
926 const char *name;
927 bfd *obfd;
928 asection *osec;
929 bfd_vma oval;
930
931 if (info->allow_multiple_definition)
932 return;
933
934 switch (h->type)
935 {
936 case bfd_link_hash_defined:
937 osec = h->u.def.section;
938 oval = h->u.def.value;
939 obfd = h->u.def.section->owner;
940 break;
941 case bfd_link_hash_indirect:
942 osec = bfd_ind_section_ptr;
943 oval = 0;
944 obfd = NULL;
945 break;
946 default:
947 abort ();
948 }
949
950 /* Ignore a redefinition of an absolute symbol to the
951 same value; it's harmless. */
952 if (h->type == bfd_link_hash_defined
953 && bfd_is_abs_section (osec)
954 && bfd_is_abs_section (nsec)
955 && nval == oval)
956 return;
957
958 /* If either section has the output_section field set to
959 bfd_abs_section_ptr, it means that the section is being
960 discarded, and this is not really a multiple definition at all.
961 FIXME: It would be cleaner to somehow ignore symbols defined in
962 sections which are being discarded. */
963 if ((osec->output_section != NULL
964 && !bfd_is_abs_section (osec)
965 && bfd_is_abs_section (osec->output_section))
966 || (nsec->output_section != NULL
967 && !bfd_is_abs_section (nsec)
968 && bfd_is_abs_section (nsec->output_section)))
969 return;
970
971 name = h->root.string;
972 if (nbfd == NULL)
973 {
974 nbfd = obfd;
975 nsec = osec;
976 nval = oval;
977 obfd = NULL;
978 }
979 einfo (_("%X%C: multiple definition of `%T'\n"),
980 nbfd, nsec, nval, name);
981 if (obfd != NULL)
982 einfo (_("%D: first defined here\n"), obfd, osec, oval);
983
984 if (RELAXATION_ENABLED_BY_USER)
985 {
986 einfo (_("%P: Disabling relaxation: it will not work with multiple definitions\n"));
987 DISABLE_RELAXATION;
988 }
989 }
990
991 /* This is called when there is a definition of a common symbol, or
992 when a common symbol is found for a symbol that is already defined,
993 or when two common symbols are found. We only do something if
994 -warn-common was used. */
995
996 static void
997 multiple_common (struct bfd_link_info *info ATTRIBUTE_UNUSED,
998 struct bfd_link_hash_entry *h,
999 bfd *nbfd,
1000 enum bfd_link_hash_type ntype,
1001 bfd_vma nsize)
1002 {
1003 const char *name;
1004 bfd *obfd;
1005 enum bfd_link_hash_type otype;
1006 bfd_vma osize;
1007
1008 if (!config.warn_common)
1009 return;
1010
1011 name = h->root.string;
1012 otype = h->type;
1013 if (otype == bfd_link_hash_common)
1014 {
1015 obfd = h->u.c.p->section->owner;
1016 osize = h->u.c.size;
1017 }
1018 else if (otype == bfd_link_hash_defined
1019 || otype == bfd_link_hash_defweak)
1020 {
1021 obfd = h->u.def.section->owner;
1022 osize = 0;
1023 }
1024 else
1025 {
1026 /* FIXME: It would nice if we could report the BFD which defined
1027 an indirect symbol, but we don't have anywhere to store the
1028 information. */
1029 obfd = NULL;
1030 osize = 0;
1031 }
1032
1033 if (ntype == bfd_link_hash_defined
1034 || ntype == bfd_link_hash_defweak
1035 || ntype == bfd_link_hash_indirect)
1036 {
1037 ASSERT (otype == bfd_link_hash_common);
1038 einfo (_("%B: warning: definition of `%T' overriding common\n"),
1039 nbfd, name);
1040 if (obfd != NULL)
1041 einfo (_("%B: warning: common is here\n"), obfd);
1042 }
1043 else if (otype == bfd_link_hash_defined
1044 || otype == bfd_link_hash_defweak
1045 || otype == bfd_link_hash_indirect)
1046 {
1047 ASSERT (ntype == bfd_link_hash_common);
1048 einfo (_("%B: warning: common of `%T' overridden by definition\n"),
1049 nbfd, name);
1050 if (obfd != NULL)
1051 einfo (_("%B: warning: defined here\n"), obfd);
1052 }
1053 else
1054 {
1055 ASSERT (otype == bfd_link_hash_common && ntype == bfd_link_hash_common);
1056 if (osize > nsize)
1057 {
1058 einfo (_("%B: warning: common of `%T' overridden by larger common\n"),
1059 nbfd, name);
1060 if (obfd != NULL)
1061 einfo (_("%B: warning: larger common is here\n"), obfd);
1062 }
1063 else if (nsize > osize)
1064 {
1065 einfo (_("%B: warning: common of `%T' overriding smaller common\n"),
1066 nbfd, name);
1067 if (obfd != NULL)
1068 einfo (_("%B: warning: smaller common is here\n"), obfd);
1069 }
1070 else
1071 {
1072 einfo (_("%B: warning: multiple common of `%T'\n"), nbfd, name);
1073 if (obfd != NULL)
1074 einfo (_("%B: warning: previous common is here\n"), obfd);
1075 }
1076 }
1077 }
1078
1079 /* This is called when BFD has discovered a set element. H is the
1080 entry in the linker hash table for the set. SECTION and VALUE
1081 represent a value which should be added to the set. */
1082
1083 static void
1084 add_to_set (struct bfd_link_info *info ATTRIBUTE_UNUSED,
1085 struct bfd_link_hash_entry *h,
1086 bfd_reloc_code_real_type reloc,
1087 bfd *abfd,
1088 asection *section,
1089 bfd_vma value)
1090 {
1091 if (config.warn_constructors)
1092 einfo (_("%P: warning: global constructor %s used\n"),
1093 h->root.string);
1094
1095 if (!config.build_constructors)
1096 return;
1097
1098 ldctor_add_set_entry (h, reloc, NULL, section, value);
1099
1100 if (h->type == bfd_link_hash_new)
1101 {
1102 h->type = bfd_link_hash_undefined;
1103 h->u.undef.abfd = abfd;
1104 /* We don't call bfd_link_add_undef to add this to the list of
1105 undefined symbols because we are going to define it
1106 ourselves. */
1107 }
1108 }
1109
1110 /* This is called when BFD has discovered a constructor. This is only
1111 called for some object file formats--those which do not handle
1112 constructors in some more clever fashion. This is similar to
1113 adding an element to a set, but less general. */
1114
1115 static void
1116 constructor_callback (struct bfd_link_info *info,
1117 bfd_boolean constructor,
1118 const char *name,
1119 bfd *abfd,
1120 asection *section,
1121 bfd_vma value)
1122 {
1123 char *s;
1124 struct bfd_link_hash_entry *h;
1125 char set_name[1 + sizeof "__CTOR_LIST__"];
1126
1127 if (config.warn_constructors)
1128 einfo (_("%P: warning: global constructor %s used\n"), name);
1129
1130 if (!config.build_constructors)
1131 return;
1132
1133 /* Ensure that BFD_RELOC_CTOR exists now, so that we can give a
1134 useful error message. */
1135 if (bfd_reloc_type_lookup (info->output_bfd, BFD_RELOC_CTOR) == NULL
1136 && (bfd_link_relocatable (info)
1137 || bfd_reloc_type_lookup (abfd, BFD_RELOC_CTOR) == NULL))
1138 einfo (_("%P%F: BFD backend error: BFD_RELOC_CTOR unsupported\n"));
1139
1140 s = set_name;
1141 if (bfd_get_symbol_leading_char (abfd) != '\0')
1142 *s++ = bfd_get_symbol_leading_char (abfd);
1143 if (constructor)
1144 strcpy (s, "__CTOR_LIST__");
1145 else
1146 strcpy (s, "__DTOR_LIST__");
1147
1148 h = bfd_link_hash_lookup (info->hash, set_name, TRUE, TRUE, TRUE);
1149 if (h == (struct bfd_link_hash_entry *) NULL)
1150 einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n"));
1151 if (h->type == bfd_link_hash_new)
1152 {
1153 h->type = bfd_link_hash_undefined;
1154 h->u.undef.abfd = abfd;
1155 /* We don't call bfd_link_add_undef to add this to the list of
1156 undefined symbols because we are going to define it
1157 ourselves. */
1158 }
1159
1160 ldctor_add_set_entry (h, BFD_RELOC_CTOR, name, section, value);
1161 }
1162
1163 /* A structure used by warning_callback to pass information through
1164 bfd_map_over_sections. */
1165
1166 struct warning_callback_info
1167 {
1168 bfd_boolean found;
1169 const char *warning;
1170 const char *symbol;
1171 asymbol **asymbols;
1172 };
1173
1174 /* Look through the relocs to see if we can find a plausible address
1175 for SYMBOL in ABFD. Return TRUE if found. Otherwise return FALSE. */
1176
1177 static bfd_boolean
1178 symbol_warning (const char *warning, const char *symbol, bfd *abfd)
1179 {
1180 struct warning_callback_info cinfo;
1181
1182 if (!bfd_generic_link_read_symbols (abfd))
1183 einfo (_("%B%F: could not read symbols: %E\n"), abfd);
1184
1185 cinfo.found = FALSE;
1186 cinfo.warning = warning;
1187 cinfo.symbol = symbol;
1188 cinfo.asymbols = bfd_get_outsymbols (abfd);
1189 bfd_map_over_sections (abfd, warning_find_reloc, &cinfo);
1190 return cinfo.found;
1191 }
1192
1193 /* This is called when there is a reference to a warning symbol. */
1194
1195 static void
1196 warning_callback (struct bfd_link_info *info ATTRIBUTE_UNUSED,
1197 const char *warning,
1198 const char *symbol,
1199 bfd *abfd,
1200 asection *section,
1201 bfd_vma address)
1202 {
1203 /* This is a hack to support warn_multiple_gp. FIXME: This should
1204 have a cleaner interface, but what? */
1205 if (!config.warn_multiple_gp
1206 && strcmp (warning, "using multiple gp values") == 0)
1207 return;
1208
1209 if (section != NULL)
1210 einfo ("%C: %s%s\n", abfd, section, address, _("warning: "), warning);
1211 else if (abfd == NULL)
1212 einfo ("%P: %s%s\n", _("warning: "), warning);
1213 else if (symbol == NULL)
1214 einfo ("%B: %s%s\n", abfd, _("warning: "), warning);
1215 else if (!symbol_warning (warning, symbol, abfd))
1216 {
1217 bfd *b;
1218 /* Search all input files for a reference to SYMBOL. */
1219 for (b = info->input_bfds; b; b = b->link.next)
1220 if (b != abfd && symbol_warning (warning, symbol, b))
1221 return;
1222 einfo ("%B: %s%s\n", abfd, _("warning: "), warning);
1223 }
1224 }
1225
1226 /* This is called by warning_callback for each section. It checks the
1227 relocs of the section to see if it can find a reference to the
1228 symbol which triggered the warning. If it can, it uses the reloc
1229 to give an error message with a file and line number. */
1230
1231 static void
1232 warning_find_reloc (bfd *abfd, asection *sec, void *iarg)
1233 {
1234 struct warning_callback_info *info = (struct warning_callback_info *) iarg;
1235 long relsize;
1236 arelent **relpp;
1237 long relcount;
1238 arelent **p, **pend;
1239
1240 if (info->found)
1241 return;
1242
1243 relsize = bfd_get_reloc_upper_bound (abfd, sec);
1244 if (relsize < 0)
1245 einfo (_("%B%F: could not read relocs: %E\n"), abfd);
1246 if (relsize == 0)
1247 return;
1248
1249 relpp = (arelent **) xmalloc (relsize);
1250 relcount = bfd_canonicalize_reloc (abfd, sec, relpp, info->asymbols);
1251 if (relcount < 0)
1252 einfo (_("%B%F: could not read relocs: %E\n"), abfd);
1253
1254 p = relpp;
1255 pend = p + relcount;
1256 for (; p < pend && *p != NULL; p++)
1257 {
1258 arelent *q = *p;
1259
1260 if (q->sym_ptr_ptr != NULL
1261 && *q->sym_ptr_ptr != NULL
1262 && strcmp (bfd_asymbol_name (*q->sym_ptr_ptr), info->symbol) == 0)
1263 {
1264 /* We found a reloc for the symbol we are looking for. */
1265 einfo ("%C: %s%s\n", abfd, sec, q->address, _("warning: "),
1266 info->warning);
1267 info->found = TRUE;
1268 break;
1269 }
1270 }
1271
1272 free (relpp);
1273 }
1274
1275 /* This is called when an undefined symbol is found. */
1276
1277 static void
1278 undefined_symbol (struct bfd_link_info *info,
1279 const char *name,
1280 bfd *abfd,
1281 asection *section,
1282 bfd_vma address,
1283 bfd_boolean error)
1284 {
1285 static char *error_name;
1286 static unsigned int error_count;
1287
1288 #define MAX_ERRORS_IN_A_ROW 5
1289
1290 if (info->ignore_hash != NULL
1291 && bfd_hash_lookup (info->ignore_hash, name, FALSE, FALSE) != NULL)
1292 return;
1293
1294 if (config.warn_once)
1295 {
1296 /* Only warn once about a particular undefined symbol. */
1297 add_ignoresym (info, name);
1298 }
1299
1300 /* We never print more than a reasonable number of errors in a row
1301 for a single symbol. */
1302 if (error_name != NULL
1303 && strcmp (name, error_name) == 0)
1304 ++error_count;
1305 else
1306 {
1307 error_count = 0;
1308 if (error_name != NULL)
1309 free (error_name);
1310 error_name = xstrdup (name);
1311 }
1312
1313 if (section != NULL)
1314 {
1315 if (error_count < MAX_ERRORS_IN_A_ROW)
1316 {
1317 if (error)
1318 einfo (_("%X%C: undefined reference to `%T'\n"),
1319 abfd, section, address, name);
1320 else
1321 einfo (_("%C: warning: undefined reference to `%T'\n"),
1322 abfd, section, address, name);
1323 }
1324 else if (error_count == MAX_ERRORS_IN_A_ROW)
1325 {
1326 if (error)
1327 einfo (_("%X%D: more undefined references to `%T' follow\n"),
1328 abfd, section, address, name);
1329 else
1330 einfo (_("%D: warning: more undefined references to `%T' follow\n"),
1331 abfd, section, address, name);
1332 }
1333 else if (error)
1334 einfo ("%X");
1335 }
1336 else
1337 {
1338 if (error_count < MAX_ERRORS_IN_A_ROW)
1339 {
1340 if (error)
1341 einfo (_("%X%B: undefined reference to `%T'\n"),
1342 abfd, name);
1343 else
1344 einfo (_("%B: warning: undefined reference to `%T'\n"),
1345 abfd, name);
1346 }
1347 else if (error_count == MAX_ERRORS_IN_A_ROW)
1348 {
1349 if (error)
1350 einfo (_("%X%B: more undefined references to `%T' follow\n"),
1351 abfd, name);
1352 else
1353 einfo (_("%B: warning: more undefined references to `%T' follow\n"),
1354 abfd, name);
1355 }
1356 else if (error)
1357 einfo ("%X");
1358 }
1359 }
1360
1361 /* Counter to limit the number of relocation overflow error messages
1362 to print. Errors are printed as it is decremented. When it's
1363 called and the counter is zero, a final message is printed
1364 indicating more relocations were omitted. When it gets to -1, no
1365 such errors are printed. If it's initially set to a value less
1366 than -1, all such errors will be printed (--verbose does this). */
1367
1368 int overflow_cutoff_limit = 10;
1369
1370 /* This is called when a reloc overflows. */
1371
1372 static void
1373 reloc_overflow (struct bfd_link_info *info,
1374 struct bfd_link_hash_entry *entry,
1375 const char *name,
1376 const char *reloc_name,
1377 bfd_vma addend,
1378 bfd *abfd,
1379 asection *section,
1380 bfd_vma address)
1381 {
1382 if (overflow_cutoff_limit == -1)
1383 return;
1384
1385 einfo ("%X%H:", abfd, section, address);
1386
1387 if (overflow_cutoff_limit >= 0
1388 && overflow_cutoff_limit-- == 0)
1389 {
1390 einfo (_(" additional relocation overflows omitted from the output\n"));
1391 return;
1392 }
1393
1394 if (entry)
1395 {
1396 while (entry->type == bfd_link_hash_indirect
1397 || entry->type == bfd_link_hash_warning)
1398 entry = entry->u.i.link;
1399 switch (entry->type)
1400 {
1401 case bfd_link_hash_undefined:
1402 case bfd_link_hash_undefweak:
1403 einfo (_(" relocation truncated to fit: "
1404 "%s against undefined symbol `%T'"),
1405 reloc_name, entry->root.string);
1406 break;
1407 case bfd_link_hash_defined:
1408 case bfd_link_hash_defweak:
1409 einfo (_(" relocation truncated to fit: "
1410 "%s against symbol `%T' defined in %A section in %B"),
1411 reloc_name, entry->root.string,
1412 entry->u.def.section,
1413 entry->u.def.section == bfd_abs_section_ptr
1414 ? info->output_bfd : entry->u.def.section->owner);
1415 break;
1416 default:
1417 abort ();
1418 break;
1419 }
1420 }
1421 else
1422 einfo (_(" relocation truncated to fit: %s against `%T'"),
1423 reloc_name, name);
1424 if (addend != 0)
1425 einfo ("+%v", addend);
1426 einfo ("\n");
1427 }
1428
1429 /* This is called when a dangerous relocation is made. */
1430
1431 static void
1432 reloc_dangerous (struct bfd_link_info *info ATTRIBUTE_UNUSED,
1433 const char *message,
1434 bfd *abfd,
1435 asection *section,
1436 bfd_vma address)
1437 {
1438 einfo (_("%X%H: dangerous relocation: %s\n"),
1439 abfd, section, address, message);
1440 }
1441
1442 /* This is called when a reloc is being generated attached to a symbol
1443 that is not being output. */
1444
1445 static void
1446 unattached_reloc (struct bfd_link_info *info ATTRIBUTE_UNUSED,
1447 const char *name,
1448 bfd *abfd,
1449 asection *section,
1450 bfd_vma address)
1451 {
1452 einfo (_("%X%H: reloc refers to symbol `%T' which is not being output\n"),
1453 abfd, section, address, name);
1454 }
1455
1456 /* This is called if link_info.notice_all is set, or when a symbol in
1457 link_info.notice_hash is found. Symbols are put in notice_hash
1458 using the -y option, while notice_all is set if the --cref option
1459 has been supplied, or if there are any NOCROSSREFS sections in the
1460 linker script; and if plugins are active, since they need to monitor
1461 all references from non-IR files. */
1462
1463 static bfd_boolean
1464 notice (struct bfd_link_info *info,
1465 struct bfd_link_hash_entry *h,
1466 struct bfd_link_hash_entry *inh ATTRIBUTE_UNUSED,
1467 bfd *abfd,
1468 asection *section,
1469 bfd_vma value,
1470 flagword flags ATTRIBUTE_UNUSED)
1471 {
1472 const char *name;
1473
1474 if (h == NULL)
1475 {
1476 if (command_line.cref || nocrossref_list != NULL)
1477 return handle_asneeded_cref (abfd, (enum notice_asneeded_action) value);
1478 return TRUE;
1479 }
1480
1481 name = h->root.string;
1482 if (info->notice_hash != NULL
1483 && bfd_hash_lookup (info->notice_hash, name, FALSE, FALSE) != NULL)
1484 {
1485 if (bfd_is_und_section (section))
1486 einfo (_("%B: reference to %s\n"), abfd, name);
1487 else
1488 einfo (_("%B: definition of %s\n"), abfd, name);
1489 }
1490
1491 if (command_line.cref || nocrossref_list != NULL)
1492 add_cref (name, abfd, section, value);
1493
1494 return TRUE;
1495 }
1496