* m10300-opc.c (mn10300_opcodes): Fix opcode for 4 operand "mul" and
[deliverable/binutils-gdb.git] / ld / ldmain.c
CommitLineData
8594f568 1/* Main program of GNU linker.
8bc8f4bc 2 Copyright (C) 1991, 92, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
ce4d59e2 3 Written by Steve Chamberlain steve@cygnus.com
e47bfa63 4
2fa0b342
DHW
5This file is part of GLD, the Gnu Linker.
6
7GLD is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
ce4d59e2 9the Free Software Foundation; either version 2, or (at your option)
2fa0b342
DHW
10any later version.
11
12GLD is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
2ed9fe47
ILT
18along with GLD; see the file COPYING. If not, write to the Free
19Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2002111-1307, USA. */
2fa0b342 21
2fa0b342 22#include "bfd.h"
f177a611 23#include "sysdep.h"
b9395be3 24#include <stdio.h>
7d6439d9 25#include <ctype.h>
d4e5e3c3 26#include "libiberty.h"
a735edad 27#include "progress.h"
b9395be3 28#include "bfdlink.h"
2fa0b342 29
2fa0b342
DHW
30#include "ld.h"
31#include "ldmain.h"
32#include "ldmisc.h"
33#include "ldwrite.h"
34#include "ldgram.h"
fcf276c4 35#include "ldexp.h"
2fa0b342 36#include "ldlang.h"
8c514453 37#include "ldemul.h"
2fa0b342
DHW
38#include "ldlex.h"
39#include "ldfile.h"
c611e285 40#include "ldctor.h"
9d1fe8a4 41
922018a1 42/* Somewhere above, sys/stat.h got included . . . . */
d723cd17
DM
43#if !defined(S_ISDIR) && defined(S_IFDIR)
44#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
45#endif
46
47#include <string.h>
48
45408cd7
ILT
49#ifdef HAVE_SBRK
50#ifdef NEED_DECLARATION_SBRK
51extern PTR sbrk ();
52#endif
53#endif
54
fcf276c4
ILT
55static char *get_emulation PARAMS ((int, char **));
56static void set_scripts_dir PARAMS ((void));
e47bfa63 57
2fa0b342
DHW
58/* EXPORTS */
59
60char *default_target;
fcf276c4 61const char *output_filename = "a.out";
e47bfa63 62
2fa0b342
DHW
63/* Name this program was invoked by. */
64char *program_name;
65
66/* The file that we're creating */
b6316534 67bfd *output_bfd = 0;
2fa0b342 68
173a0c3d
DM
69/* Set by -G argument, for MIPS ECOFF target. */
70int g_switch_value = 8;
71
2fa0b342
DHW
72/* Nonzero means print names of input files as processed. */
73boolean trace_files;
74
bbd2521f
DM
75/* Nonzero means same, but note open failures, too. */
76boolean trace_file_tries;
77
7b40f2b1
DM
78/* Nonzero means version number was printed, so exit successfully
79 instead of complaining if no input files are given. */
80boolean version_printed;
81
f2f55b16
ILT
82/* Nonzero means link in every member of an archive. */
83boolean whole_archive;
84
2fa0b342 85args_type command_line;
173a0c3d 86
2fa0b342 87ld_config_type config;
9f629407 88
8bc8f4bc 89static void remove_output PARAMS ((void));
9f629407 90static boolean check_for_scripts_dir PARAMS ((char *dir));
b9395be3
ILT
91static boolean add_archive_element PARAMS ((struct bfd_link_info *, bfd *,
92 const char *));
93static boolean multiple_definition PARAMS ((struct bfd_link_info *,
94 const char *,
95 bfd *, asection *, bfd_vma,
96 bfd *, asection *, bfd_vma));
97static boolean multiple_common PARAMS ((struct bfd_link_info *,
98 const char *, bfd *,
99 enum bfd_link_hash_type, bfd_vma,
100 bfd *, enum bfd_link_hash_type,
101 bfd_vma));
102static boolean add_to_set PARAMS ((struct bfd_link_info *,
103 struct bfd_link_hash_entry *,
2a9fa50c 104 bfd_reloc_code_real_type,
b9395be3
ILT
105 bfd *, asection *, bfd_vma));
106static boolean constructor_callback PARAMS ((struct bfd_link_info *,
107 boolean constructor,
b9395be3
ILT
108 const char *name,
109 bfd *, asection *, bfd_vma));
110static boolean warning_callback PARAMS ((struct bfd_link_info *,
7d6439d9
ILT
111 const char *, const char *, bfd *,
112 asection *, bfd_vma));
113static void warning_find_reloc PARAMS ((bfd *, asection *, PTR));
b9395be3
ILT
114static boolean undefined_symbol PARAMS ((struct bfd_link_info *,
115 const char *, bfd *,
116 asection *, bfd_vma));
5dad4c97
ILT
117static boolean reloc_overflow PARAMS ((struct bfd_link_info *, const char *,
118 const char *, bfd_vma,
119 bfd *, asection *, bfd_vma));
b9395be3
ILT
120static boolean reloc_dangerous PARAMS ((struct bfd_link_info *, const char *,
121 bfd *, asection *, bfd_vma));
122static boolean unattached_reloc PARAMS ((struct bfd_link_info *,
123 const char *, bfd *, asection *,
124 bfd_vma));
cd09553a
ILT
125static boolean notice PARAMS ((struct bfd_link_info *, const char *,
126 bfd *, asection *, bfd_vma));
b9395be3
ILT
127
128static struct bfd_link_callbacks link_callbacks =
129{
130 add_archive_element,
131 multiple_definition,
132 multiple_common,
133 add_to_set,
134 constructor_callback,
135 warning_callback,
136 undefined_symbol,
137 reloc_overflow,
138 reloc_dangerous,
139 unattached_reloc,
cd09553a 140 notice
b9395be3
ILT
141};
142
143struct bfd_link_info link_info;
173a0c3d 144\f
0b2f8d2e
DM
145static void
146remove_output ()
147{
148 if (output_filename)
149 {
150 if (output_bfd && output_bfd->iostream)
151 fclose((FILE *)(output_bfd->iostream));
152 if (delete_output_file_on_failure)
153 unlink (output_filename);
154 }
155}
156
9f629407 157int
2fa0b342 158main (argc, argv)
2fa0b342 159 int argc;
9f629407 160 char **argv;
2fa0b342
DHW
161{
162 char *emulation;
8594f568 163 long start_time = get_run_time ();
e47bfa63 164
8bc8f4bc
TT
165 setlocale (LC_MESSAGES, "");
166 bindtextdomain (PACKAGE, LOCALEDIR);
167 textdomain (PACKAGE);
168
2fa0b342 169 program_name = argv[0];
5bcb7f28 170 xmalloc_set_program_name (program_name);
99fe4553 171
a735edad
ILT
172 START_PROGRESS (program_name, 0);
173
e47bfa63 174 bfd_init ();
bfbdc80f 175
28113e82
ILT
176 bfd_set_error_program_name (program_name);
177
5bcb7f28 178 xatexit (remove_output);
0b2f8d2e 179
d7339c87
ILT
180 /* Set the default BFD target based on the configured target. Doing
181 this permits the linker to be configured for a particular target,
182 and linked against a shared BFD library which was configured for
183 a different target. The macro TARGET is defined by Makefile. */
184 if (! bfd_set_default_target (TARGET))
185 {
8bc8f4bc 186 einfo (_("%X%P: can't set BFD default target to `%s': %E\n"), TARGET);
d7339c87
ILT
187 xexit (1);
188 }
189
2fa0b342 190 /* Initialize the data about options. */
7b40f2b1 191 trace_files = trace_file_tries = version_printed = false;
f2f55b16 192 whole_archive = false;
b9395be3 193 config.build_constructors = true;
2a9fa50c 194 config.dynamic_link = false;
2fa0b342 195 command_line.force_common_definition = false;
7fb9ca5f 196 command_line.interpreter = NULL;
cc23cc69 197 command_line.rpath = NULL;
8bc8f4bc 198 command_line.warn_mismatch = true;
2fa0b342 199
b9395be3
ILT
200 link_info.callbacks = &link_callbacks;
201 link_info.relocateable = false;
64887de2 202 link_info.shared = false;
4551e108 203 link_info.symbolic = false;
7d6439d9 204 link_info.static_link = false;
6799c638 205 link_info.traditional_format = false;
b9395be3
ILT
206 link_info.strip = strip_none;
207 link_info.discard = discard_none;
b9395be3
ILT
208 link_info.keep_memory = true;
209 link_info.input_bfds = NULL;
210 link_info.create_object_symbols_section = NULL;
211 link_info.hash = NULL;
212 link_info.keep_hash = NULL;
cd09553a 213 link_info.notice_all = false;
b9395be3 214 link_info.notice_hash = NULL;
e3d73386 215 link_info.wrap_hash = NULL;
7d6439d9 216
e47bfa63 217 ldfile_add_arch ("");
a72f4e5f 218
2fa0b342
DHW
219 config.make_executable = true;
220 force_make_executable = false;
ce4d59e2
SC
221 config.magic_demand_paged = true;
222 config.text_read_only = true;
2fa0b342 223 config.make_executable = true;
1418c83b 224
d723cd17 225 emulation = get_emulation (argc, argv);
e47bfa63
SC
226 ldemul_choose_mode (emulation);
227 default_target = ldemul_choose_target ();
228 lang_init ();
229 ldemul_before_parse ();
2fa0b342 230 lang_has_input_file = false;
e47bfa63 231 parse_args (argc, argv);
f3739bc3 232
7d6439d9
ILT
233 ldemul_set_symbols ();
234
2a9fa50c
ILT
235 if (link_info.relocateable)
236 {
237 if (command_line.relax)
8bc8f4bc 238 einfo (_("%P%F: -relax and -r may not be used together\n"));
64887de2 239 if (link_info.shared)
8bc8f4bc 240 einfo (_("%P%F: -r and -shared may not be used together\n"));
2a9fa50c
ILT
241 }
242
8ed88239
ILT
243 /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols). I
244 don't see how else this can be handled, since in this case we
245 must preserve all externally visible symbols. */
246 if (link_info.relocateable && link_info.strip == strip_all)
247 {
248 link_info.strip = strip_debugger;
249 if (link_info.discard == discard_none)
250 link_info.discard = discard_all;
251 }
252
973e421e
ILT
253 /* This essentially adds another -L directory so this must be done after
254 the -L's in argv have been processed. */
255 set_scripts_dir ();
256
bbd2521f
DM
257 if (had_script == false)
258 {
259 /* Read the emulation's appropriate default script. */
2a28d8b0
DM
260 int isfile;
261 char *s = ldemul_get_script (&isfile);
262
263 if (isfile)
d4e5e3c3 264 ldfile_open_command_file (s);
2a28d8b0 265 else
22c41f00
ILT
266 {
267 if (trace_file_tries)
268 {
8bc8f4bc 269 info_msg (_("using internal linker script:\n"));
22c41f00
ILT
270 info_msg ("==================================================\n");
271 info_msg (s);
272 info_msg ("\n==================================================\n");
273 }
7d6439d9 274 lex_string = s;
22c41f00
ILT
275 lex_redirect (s);
276 }
d4e5e3c3
DM
277 parser_input = input_script;
278 yyparse ();
7d6439d9 279 lex_string = NULL;
bbd2521f
DM
280 }
281
e47bfa63 282 lang_final ();
9d1fe8a4 283
e47bfa63
SC
284 if (lang_has_input_file == false)
285 {
7b40f2b1 286 if (version_printed)
0b2f8d2e 287 xexit (0);
8bc8f4bc 288 einfo (_("%P%F: no input files\n"));
870f54b2 289 }
2fa0b342 290
bbd2521f
DM
291 if (trace_files)
292 {
8bc8f4bc 293 info_msg (_("%P: mode %s\n"), emulation);
bbd2521f
DM
294 }
295
e47bfa63 296 ldemul_after_parse ();
870f54b2 297
9d1fe8a4 298
e47bfa63 299 if (config.map_filename)
870f54b2 300 {
e47bfa63 301 if (strcmp (config.map_filename, "-") == 0)
2e2bf962 302 {
e47bfa63 303 config.map_file = stdout;
2e2bf962 304 }
e47bfa63
SC
305 else
306 {
307 config.map_file = fopen (config.map_filename, FOPEN_WT);
308 if (config.map_file == (FILE *) NULL)
309 {
de71eb77 310 bfd_set_error (bfd_error_system_call);
8bc8f4bc 311 einfo (_("%P%F: cannot open map file %s: %E\n"),
e47bfa63
SC
312 config.map_filename);
313 }
314 }
315 }
870f54b2 316
2e2bf962 317
e47bfa63 318 lang_process ();
2fa0b342 319
2fa0b342
DHW
320 /* Print error messages for any missing symbols, for any warning
321 symbols, and possibly multiple definitions */
322
2fa0b342 323
e47bfa63
SC
324 if (config.text_read_only)
325 {
326 /* Look for a text section and mark the readonly attribute in it */
327 asection *found = bfd_get_section_by_name (output_bfd, ".text");
328
329 if (found != (asection *) NULL)
330 {
331 found->flags |= SEC_READONLY;
332 }
3e4c643d 333 }
2fa0b342 334
a735edad 335 if (link_info.relocateable)
f3739bc3 336 output_bfd->flags &= ~EXEC_P;
a72f4e5f 337 else
f3739bc3 338 output_bfd->flags |= EXEC_P;
b257477f 339
f3739bc3 340 ldwrite ();
b257477f 341
0cacbcbe
ILT
342 if (config.map_file != NULL)
343 lang_map ();
cd09553a
ILT
344 if (command_line.cref)
345 output_cref (config.map_file != NULL ? config.map_file : stdout);
582dd77f
ILT
346 if (nocrossref_list != NULL)
347 check_nocrossrefs ();
0cacbcbe 348
f3739bc3
SC
349 /* Even if we're producing relocateable output, some non-fatal errors should
350 be reported in the exit status. (What non-fatal errors, if any, do we
351 want to ignore for relocateable output?) */
a72f4e5f 352
f3739bc3
SC
353 if (config.make_executable == false && force_make_executable == false)
354 {
355 if (trace_files == true)
e47bfa63 356 {
8bc8f4bc 357 einfo (_("%P: link errors found, deleting executable `%s'\n"),
f3739bc3 358 output_filename);
e47bfa63 359 }
a72f4e5f 360
cd09553a 361 /* The file will be removed by remove_output. */
a72f4e5f 362
0b2f8d2e 363 xexit (1);
f3739bc3
SC
364 }
365 else
366 {
2a9fa50c 367 if (! bfd_close (output_bfd))
8bc8f4bc 368 einfo (_("%F%B: final close failed: %E\n"), output_bfd);
cd09553a
ILT
369
370 /* If the --force-exe-suffix is enabled, and we're making an
371 executable file and it doesn't end in .exe, copy it to one which does. */
372
373 if (! link_info.relocateable && command_line.force_exe_suffix)
374 {
375 int len = strlen (output_filename);
376 if (len < 4
377 || (strcasecmp (output_filename + len - 4, ".exe") != 0
378 && strcasecmp (output_filename + len - 4, ".dll") != 0))
379 {
380 FILE *src;
381 FILE *dst;
382 const int bsize = 4096;
383 char *buf = xmalloc (bsize);
384 int l;
385 char *dst_name = xmalloc (len + 5);
386 strcpy (dst_name, output_filename);
387 strcat (dst_name, ".exe");
388 src = fopen (output_filename, FOPEN_RB);
389 dst = fopen (dst_name, FOPEN_WB);
390
391 if (!src)
8bc8f4bc 392 einfo (_("%X%P: unable to open for source of copy `%s'\n"), output_filename);
cd09553a 393 if (!dst)
8bc8f4bc 394 einfo (_("%X%P: unable to open for destination of copy `%s'\n"), dst_name);
cd09553a
ILT
395 while ((l = fread (buf, 1, bsize, src)) > 0)
396 {
397 int done = fwrite (buf, 1, l, dst);
398 if (done != l)
399 {
8bc8f4bc 400 einfo (_("%P: Error writing file `%s'\n"), dst_name);
cd09553a
ILT
401 }
402 }
403 fclose (src);
8bc8f4bc 404 if (fclose (dst) == EOF)
cd09553a 405 {
8bc8f4bc 406 einfo (_("%P: Error closing file `%s'\n"), dst_name);
cd09553a
ILT
407 }
408 free (dst_name);
409 free (buf);
410 }
411 }
f3739bc3 412 }
2fa0b342 413
a735edad
ILT
414 END_PROGRESS (program_name);
415
b9395be3
ILT
416 if (config.stats)
417 {
418 extern char **environ;
eac6290c 419#ifdef HAVE_SBRK
b9395be3 420 char *lim = (char *) sbrk (0);
de71eb77 421#endif
8594f568 422 long run_time = get_run_time () - start_time;
b9395be3 423
8bc8f4bc 424 fprintf (stderr, _("%s: total time in link: %ld.%06ld\n"),
8594f568 425 program_name, run_time / 1000000, run_time % 1000000);
eac6290c 426#ifdef HAVE_SBRK
8bc8f4bc 427 fprintf (stderr, _("%s: data size %ld\n"), program_name,
b9395be3 428 (long) (lim - (char *) &environ));
de71eb77 429#endif
b9395be3
ILT
430 }
431
52a8ebfe
DM
432 /* Prevent remove_output from doing anything, after a successful link. */
433 output_filename = NULL;
434
0b2f8d2e 435 xexit (0);
9f629407 436 return 0;
d723cd17
DM
437}
438
439/* We need to find any explicitly given emulation in order to initialize the
440 state that's needed by the lex&yacc argument parser (parse_args). */
441
442static char *
443get_emulation (argc, argv)
444 int argc;
445 char **argv;
446{
447 char *emulation;
448 int i;
449
45408cd7 450 emulation = getenv (EMULATION_ENVIRON);
d723cd17
DM
451 if (emulation == NULL)
452 emulation = DEFAULT_EMULATION;
d723cd17
DM
453
454 for (i = 1; i < argc; i++)
455 {
456 if (!strncmp (argv[i], "-m", 2))
457 {
458 if (argv[i][2] == '\0')
459 {
460 /* -m EMUL */
461 if (i < argc - 1)
462 {
463 emulation = argv[i + 1];
464 i++;
465 }
466 else
467 {
8bc8f4bc 468 einfo(_("%P%F: missing argument to -m\n"));
d723cd17
DM
469 }
470 }
973e421e
ILT
471 else if (strcmp (argv[i], "-mips1") == 0
472 || strcmp (argv[i], "-mips2") == 0
45408cd7
ILT
473 || strcmp (argv[i], "-mips3") == 0
474 || strcmp (argv[i], "-mips4") == 0)
973e421e
ILT
475 {
476 /* FIXME: The arguments -mips1, -mips2 and -mips3 are
477 passed to the linker by some MIPS compilers. They
478 generally tell the linker to use a slightly different
479 library path. Perhaps someday these should be
480 implemented as emulations; until then, we just ignore
481 the arguments and hope that nobody ever creates
482 emulations named ips1, ips2 or ips3. */
483 }
cbbf9608
ILT
484 else if (strcmp (argv[i], "-m486") == 0)
485 {
486 /* FIXME: The argument -m486 is passed to the linker on
487 some Linux systems. Hope that nobody creates an
488 emulation named 486. */
489 }
d723cd17
DM
490 else
491 {
492 /* -mEMUL */
493 emulation = &argv[i][2];
494 }
495 }
496 }
497
498 return emulation;
499}
500
501/* If directory DIR contains an "ldscripts" subdirectory,
502 add DIR to the library search path and return true,
503 else return false. */
504
505static boolean
506check_for_scripts_dir (dir)
507 char *dir;
508{
509 size_t dirlen;
510 char *buf;
511 struct stat s;
512 boolean res;
513
514 dirlen = strlen (dir);
515 /* sizeof counts the terminating NUL. */
0b2f8d2e 516 buf = (char *) xmalloc (dirlen + sizeof("/ldscripts"));
d723cd17
DM
517 sprintf (buf, "%s/ldscripts", dir);
518
519 res = stat (buf, &s) == 0 && S_ISDIR (s.st_mode);
f4208462 520 free (buf);
d723cd17 521 if (res)
0cd82d00 522 ldfile_add_library_path (dir, false);
d723cd17
DM
523 return res;
524}
525
526/* Set the default directory for finding script files.
f4208462
DM
527 Libraries will be searched for here too, but that's ok.
528 We look for the "ldscripts" directory in:
529
f4208462 530 SCRIPTDIR (passed from Makefile)
bbd2521f
DM
531 the dir where this program is (for using it from the build tree)
532 the dir where this program is/../lib (for installing the tool suite elsewhere) */
d723cd17
DM
533
534static void
535set_scripts_dir ()
536{
f4208462
DM
537 char *end, *dir;
538 size_t dirlen;
539
d723cd17 540 if (check_for_scripts_dir (SCRIPTDIR))
f4208462 541 return; /* We've been installed normally. */
d723cd17
DM
542
543 /* Look for "ldscripts" in the dir where our binary is. */
544 end = strrchr (program_name, '/');
7d6439d9
ILT
545
546 if (end == NULL)
bbd2521f 547 {
7d6439d9
ILT
548 /* Don't look for ldscripts in the current directory. There is
549 too much potential for confusion. */
550 return;
bbd2521f 551 }
f4208462 552
7d6439d9
ILT
553 dirlen = end - program_name;
554 /* Make a copy of program_name in dir.
555 Leave room for later "/../lib". */
556 dir = (char *) xmalloc (dirlen + 8);
557 strncpy (dir, program_name, dirlen);
558 dir[dirlen] = '\0';
559
f4208462
DM
560 if (check_for_scripts_dir (dir))
561 return; /* Don't free dir. */
562
563 /* Look for "ldscripts" in <the dir where our binary is>/../lib. */
564 strcpy (dir + dirlen, "/../lib");
565 if (check_for_scripts_dir (dir))
566 return;
567
568 free (dir); /* Well, we tried. */
d723cd17 569}
2fa0b342 570
e47bfa63 571void
b9395be3
ILT
572add_ysym (name)
573 const char *name;
2fa0b342 574{
b9395be3
ILT
575 if (link_info.notice_hash == (struct bfd_hash_table *) NULL)
576 {
577 link_info.notice_hash = ((struct bfd_hash_table *)
0b2f8d2e 578 xmalloc (sizeof (struct bfd_hash_table)));
b9395be3
ILT
579 if (! bfd_hash_table_init_n (link_info.notice_hash,
580 bfd_hash_newfunc,
581 61))
8bc8f4bc 582 einfo (_("%P%F: bfd_hash_table_init failed: %E\n"));
b9395be3
ILT
583 }
584
585 if (bfd_hash_lookup (link_info.notice_hash, name, true, true)
586 == (struct bfd_hash_entry *) NULL)
8bc8f4bc 587 einfo (_("%P%F: bfd_hash_lookup failed: %E\n"));
2fa0b342 588}
e47bfa63 589
28113e82
ILT
590/* Record a symbol to be wrapped, from the --wrap option. */
591
592void
593add_wrap (name)
594 const char *name;
595{
596 if (link_info.wrap_hash == NULL)
597 {
598 link_info.wrap_hash = ((struct bfd_hash_table *)
599 xmalloc (sizeof (struct bfd_hash_table)));
600 if (! bfd_hash_table_init_n (link_info.wrap_hash,
601 bfd_hash_newfunc,
602 61))
8bc8f4bc 603 einfo (_("%P%F: bfd_hash_table_init failed: %E\n"));
28113e82
ILT
604 }
605 if (bfd_hash_lookup (link_info.wrap_hash, name, true, true) == NULL)
8bc8f4bc 606 einfo (_("%P%F: bfd_hash_lookup failed: %E\n"));
28113e82
ILT
607}
608
b9395be3 609/* Handle the -retain-symbols-file option. */
2fa0b342 610
2fa0b342 611void
b9395be3
ILT
612add_keepsyms_file (filename)
613 const char *filename;
2fa0b342 614{
b9395be3
ILT
615 FILE *file;
616 char *buf;
617 size_t bufsize;
618 int c;
2fa0b342 619
b9395be3 620 if (link_info.strip == strip_some)
8bc8f4bc 621 einfo (_("%X%P: error: duplicate retain-symbols-file\n"));
3e4c643d 622
b9395be3
ILT
623 file = fopen (filename, "r");
624 if (file == (FILE *) NULL)
e47bfa63 625 {
5bcb7f28 626 bfd_set_error (bfd_error_system_call);
7d6439d9 627 einfo ("%X%P: %s: %E\n", filename);
b9395be3 628 return;
be1627d3 629 }
be1627d3 630
b9395be3 631 link_info.keep_hash = ((struct bfd_hash_table *)
0b2f8d2e 632 xmalloc (sizeof (struct bfd_hash_table)));
b9395be3 633 if (! bfd_hash_table_init (link_info.keep_hash, bfd_hash_newfunc))
8bc8f4bc 634 einfo (_("%P%F: bfd_hash_table_init failed: %E\n"));
2fa0b342 635
b9395be3 636 bufsize = 100;
0b2f8d2e 637 buf = (char *) xmalloc (bufsize);
c611e285 638
b9395be3
ILT
639 c = getc (file);
640 while (c != EOF)
29f33467 641 {
b9395be3
ILT
642 while (isspace (c))
643 c = getc (file);
e47bfa63 644
b9395be3 645 if (c != EOF)
29f33467 646 {
b9395be3 647 size_t len = 0;
8a045e50 648
b9395be3 649 while (! isspace (c) && c != EOF)
29f33467 650 {
b9395be3
ILT
651 buf[len] = c;
652 ++len;
653 if (len >= bufsize)
29f33467 654 {
b9395be3 655 bufsize *= 2;
0b2f8d2e 656 buf = xrealloc (buf, bufsize);
29f33467 657 }
b9395be3 658 c = getc (file);
29f33467 659 }
81016051 660
b9395be3
ILT
661 buf[len] = '\0';
662
663 if (bfd_hash_lookup (link_info.keep_hash, buf, true, true)
664 == (struct bfd_hash_entry *) NULL)
8bc8f4bc 665 einfo (_("%P%F: bfd_hash_lookup for insertion failed: %E\n"));
29f33467 666 }
e47bfa63 667 }
2fa0b342 668
b9395be3 669 if (link_info.strip != strip_none)
8bc8f4bc 670 einfo (_("%P: `-retain-symbols-file' overrides `-s' and `-S'\n"));
8a045e50 671
b9395be3
ILT
672 link_info.strip = strip_some;
673}
674\f
675/* Callbacks from the BFD linker routines. */
2fa0b342 676
b9395be3
ILT
677/* This is called when BFD has decided to include an archive member in
678 a link. */
2fa0b342 679
b9395be3
ILT
680/*ARGSUSED*/
681static boolean
682add_archive_element (info, abfd, name)
683 struct bfd_link_info *info;
684 bfd *abfd;
685 const char *name;
2fa0b342 686{
b9395be3
ILT
687 lang_input_statement_type *input;
688
689 input = ((lang_input_statement_type *)
7d6439d9 690 xmalloc (sizeof (lang_input_statement_type)));
b9395be3
ILT
691 input->filename = abfd->filename;
692 input->local_sym_name = abfd->filename;
693 input->the_bfd = abfd;
694 input->asymbols = NULL;
b9395be3
ILT
695 input->next = NULL;
696 input->just_syms_flag = false;
697 input->loaded = false;
210c52ac 698 input->search_dirs_flag = false;
b9395be3
ILT
699
700 /* FIXME: The following fields are not set: header.next,
210c52ac 701 header.type, closed, passive_position, symbol_count,
cd09553a
ILT
702 next_real_file, is_archive, target, real. This bit of code is
703 from the old decode_library_subfile function. I don't know
704 whether any of those fields matters. */
b9395be3
ILT
705
706 ldlang_add_file (input);
707
2a9fa50c 708 if (config.map_file != (FILE *) NULL)
efa6c497
ILT
709 {
710 static boolean header_printed;
711 struct bfd_link_hash_entry *h;
712 bfd *from;
713 int len;
714
715 h = bfd_link_hash_lookup (link_info.hash, name, false, false, true);
716
717 if (h == NULL)
718 from = NULL;
719 else
720 {
721 switch (h->type)
722 {
723 default:
724 from = NULL;
725 break;
726
727 case bfd_link_hash_defined:
728 case bfd_link_hash_defweak:
729 from = h->u.def.section->owner;
730 break;
731
732 case bfd_link_hash_undefined:
733 case bfd_link_hash_undefweak:
734 from = h->u.undef.abfd;
735 break;
736
737 case bfd_link_hash_common:
738 from = h->u.c.p->section->owner;
739 break;
740 }
741 }
742
743 if (! header_printed)
744 {
745 char buf[100];
746
8bc8f4bc
TT
747 sprintf (buf, "%-29s %s\n\n", _("Archive member included"),
748 _("because of file (symbol)"));
efa6c497
ILT
749 minfo ("%s", buf);
750 header_printed = true;
751 }
752
753 if (bfd_my_archive (abfd) == NULL)
754 {
755 minfo ("%s", bfd_get_filename (abfd));
756 len = strlen (bfd_get_filename (abfd));
757 }
758 else
759 {
760 minfo ("%s(%s)", bfd_get_filename (bfd_my_archive (abfd)),
761 bfd_get_filename (abfd));
762 len = (strlen (bfd_get_filename (bfd_my_archive (abfd)))
763 + strlen (bfd_get_filename (abfd))
764 + 2);
765 }
766
767 if (len >= 29)
768 {
769 print_nl ();
770 len = 0;
771 }
772 while (len < 30)
773 {
774 print_space ();
775 ++len;
776 }
777
778 if (from != NULL)
779 minfo ("%B ", from);
780 if (h != NULL)
781 minfo ("(%T)\n", h->root.string);
782 else
783 minfo ("(%s)\n", name);
784 }
b9395be3 785
5dad4c97
ILT
786 if (trace_files || trace_file_tries)
787 info_msg ("%I\n", input);
788
b9395be3
ILT
789 return true;
790}
2fa0b342 791
b9395be3
ILT
792/* This is called when BFD has discovered a symbol which is defined
793 multiple times. */
2fa0b342 794
b9395be3
ILT
795/*ARGSUSED*/
796static boolean
797multiple_definition (info, name, obfd, osec, oval, nbfd, nsec, nval)
798 struct bfd_link_info *info;
799 const char *name;
800 bfd *obfd;
801 asection *osec;
802 bfd_vma oval;
803 bfd *nbfd;
804 asection *nsec;
805 bfd_vma nval;
806{
6799c638
ILT
807 /* If either section has the output_section field set to
808 bfd_abs_section_ptr, it means that the section is being
809 discarded, and this is not really a multiple definition at all.
810 FIXME: It would be cleaner to somehow ignore symbols defined in
811 sections which are being discarded. */
812 if ((osec->output_section != NULL
d7339c87 813 && ! bfd_is_abs_section (osec)
6799c638
ILT
814 && bfd_is_abs_section (osec->output_section))
815 || (nsec->output_section != NULL
d7339c87 816 && ! bfd_is_abs_section (nsec)
6799c638
ILT
817 && bfd_is_abs_section (nsec->output_section)))
818 return true;
819
8bc8f4bc 820 einfo (_("%X%C: multiple definition of `%T'\n"),
b9395be3
ILT
821 nbfd, nsec, nval, name);
822 if (obfd != (bfd *) NULL)
8bc8f4bc 823 einfo (_("%D: first defined here\n"), obfd, osec, oval);
b9395be3 824 return true;
2fa0b342
DHW
825}
826
b9395be3
ILT
827/* This is called when there is a definition of a common symbol, or
828 when a common symbol is found for a symbol that is already defined,
829 or when two common symbols are found. We only do something if
830 -warn-common was used. */
831
832/*ARGSUSED*/
833static boolean
834multiple_common (info, name, obfd, otype, osize, nbfd, ntype, nsize)
835 struct bfd_link_info *info;
836 const char *name;
837 bfd *obfd;
838 enum bfd_link_hash_type otype;
839 bfd_vma osize;
840 bfd *nbfd;
841 enum bfd_link_hash_type ntype;
842 bfd_vma nsize;
99fe4553 843{
b9395be3
ILT
844 if (! config.warn_common)
845 return true;
99fe4553 846
8ed88239
ILT
847 if (ntype == bfd_link_hash_defined
848 || ntype == bfd_link_hash_defweak
849 || ntype == bfd_link_hash_indirect)
e47bfa63 850 {
b9395be3 851 ASSERT (otype == bfd_link_hash_common);
8bc8f4bc 852 einfo (_("%B: warning: definition of `%T' overriding common\n"),
b9395be3 853 nbfd, name);
8ed88239 854 if (obfd != NULL)
8bc8f4bc 855 einfo (_("%B: warning: common is here\n"), obfd);
e47bfa63 856 }
8ed88239
ILT
857 else if (otype == bfd_link_hash_defined
858 || otype == bfd_link_hash_defweak
859 || otype == bfd_link_hash_indirect)
2fa0b342 860 {
b9395be3 861 ASSERT (ntype == bfd_link_hash_common);
8bc8f4bc 862 einfo (_("%B: warning: common of `%T' overridden by definition\n"),
b9395be3 863 nbfd, name);
8ed88239 864 if (obfd != NULL)
8bc8f4bc 865 einfo (_("%B: warning: defined here\n"), obfd);
b9395be3
ILT
866 }
867 else
868 {
869 ASSERT (otype == bfd_link_hash_common && ntype == bfd_link_hash_common);
870 if (osize > nsize)
2fa0b342 871 {
8bc8f4bc 872 einfo (_("%B: warning: common of `%T' overridden by larger common\n"),
b9395be3 873 nbfd, name);
8ed88239 874 if (obfd != NULL)
8bc8f4bc 875 einfo (_("%B: warning: larger common is here\n"), obfd);
2fa0b342 876 }
b9395be3 877 else if (nsize > osize)
2fa0b342 878 {
8bc8f4bc 879 einfo (_("%B: warning: common of `%T' overriding smaller common\n"),
b9395be3 880 nbfd, name);
8ed88239 881 if (obfd != NULL)
8bc8f4bc 882 einfo (_("%B: warning: smaller common is here\n"), obfd);
2fa0b342 883 }
e47bfa63 884 else
2fa0b342 885 {
8bc8f4bc 886 einfo (_("%B: warning: multiple common of `%T'\n"), nbfd, name);
8ed88239 887 if (obfd != NULL)
8bc8f4bc 888 einfo (_("%B: warning: previous common is here\n"), obfd);
2fa0b342
DHW
889 }
890 }
891
b9395be3 892 return true;
2fa0b342
DHW
893}
894
b9395be3
ILT
895/* This is called when BFD has discovered a set element. H is the
896 entry in the linker hash table for the set. SECTION and VALUE
897 represent a value which should be added to the set. */
2fa0b342 898
b9395be3
ILT
899/*ARGSUSED*/
900static boolean
2a9fa50c 901add_to_set (info, h, reloc, abfd, section, value)
b9395be3
ILT
902 struct bfd_link_info *info;
903 struct bfd_link_hash_entry *h;
2a9fa50c 904 bfd_reloc_code_real_type reloc;
b9395be3
ILT
905 bfd *abfd;
906 asection *section;
907 bfd_vma value;
2fa0b342 908{
7d6439d9 909 if (config.warn_constructors)
8bc8f4bc 910 einfo (_("%P: warning: global constructor %s used\n"),
7d6439d9
ILT
911 h->root.string);
912
2a9fa50c
ILT
913 if (! config.build_constructors)
914 return true;
915
4b7d2399 916 ldctor_add_set_entry (h, reloc, (const char *) NULL, section, value);
2a9fa50c
ILT
917
918 if (h->type == bfd_link_hash_new)
919 {
920 h->type = bfd_link_hash_undefined;
921 h->u.undef.abfd = abfd;
922 /* We don't call bfd_link_add_undef to add this to the list of
923 undefined symbols because we are going to define it
924 ourselves. */
925 }
926
b9395be3
ILT
927 return true;
928}
1418c83b 929
b9395be3
ILT
930/* This is called when BFD has discovered a constructor. This is only
931 called for some object file formats--those which do not handle
932 constructors in some more clever fashion. This is similar to
933 adding an element to a set, but less general. */
2fa0b342 934
b9395be3 935static boolean
2a9fa50c 936constructor_callback (info, constructor, name, abfd, section, value)
b9395be3
ILT
937 struct bfd_link_info *info;
938 boolean constructor;
b9395be3
ILT
939 const char *name;
940 bfd *abfd;
941 asection *section;
942 bfd_vma value;
943{
b9395be3
ILT
944 char *s;
945 struct bfd_link_hash_entry *h;
7d6439d9
ILT
946 char set_name[1 + sizeof "__CTOR_LIST__"];
947
948 if (config.warn_constructors)
8bc8f4bc 949 einfo (_("%P: warning: global constructor %s used\n"), name);
b9395be3
ILT
950
951 if (! config.build_constructors)
952 return true;
953
2a9fa50c
ILT
954 /* Ensure that BFD_RELOC_CTOR exists now, so that we can give a
955 useful error message. */
4b7d2399
ILT
956 if (bfd_reloc_type_lookup (output_bfd, BFD_RELOC_CTOR) == NULL
957 && (link_info.relocateable
958 || bfd_reloc_type_lookup (abfd, BFD_RELOC_CTOR) == NULL))
8bc8f4bc 959 einfo (_("%P%F: BFD backend error: BFD_RELOC_CTOR unsupported\n"));
2a9fa50c 960
b9395be3
ILT
961 s = set_name;
962 if (bfd_get_symbol_leading_char (abfd) != '\0')
963 *s++ = bfd_get_symbol_leading_char (abfd);
964 if (constructor)
965 strcpy (s, "__CTOR_LIST__");
29f33467 966 else
b9395be3 967 strcpy (s, "__DTOR_LIST__");
2fa0b342 968
b9395be3
ILT
969 h = bfd_link_hash_lookup (info->hash, set_name, true, true, true);
970 if (h == (struct bfd_link_hash_entry *) NULL)
8bc8f4bc 971 einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n"));
b9395be3 972 if (h->type == bfd_link_hash_new)
e47bfa63 973 {
b9395be3
ILT
974 h->type = bfd_link_hash_undefined;
975 h->u.undef.abfd = abfd;
976 /* We don't call bfd_link_add_undef to add this to the list of
977 undefined symbols because we are going to define it
978 ourselves. */
2fa0b342 979 }
2fa0b342 980
4b7d2399 981 ldctor_add_set_entry (h, BFD_RELOC_CTOR, name, section, value);
b9395be3 982 return true;
2fa0b342
DHW
983}
984
7d6439d9
ILT
985/* A structure used by warning_callback to pass information through
986 bfd_map_over_sections. */
987
988struct warning_callback_info
989{
990 boolean found;
991 const char *warning;
992 const char *symbol;
993 asymbol **asymbols;
994};
995
b9395be3 996/* This is called when there is a reference to a warning symbol. */
2fa0b342 997
b9395be3
ILT
998/*ARGSUSED*/
999static boolean
7d6439d9 1000warning_callback (info, warning, symbol, abfd, section, address)
b9395be3
ILT
1001 struct bfd_link_info *info;
1002 const char *warning;
7d6439d9
ILT
1003 const char *symbol;
1004 bfd *abfd;
1005 asection *section;
1006 bfd_vma address;
2fa0b342 1007{
4b7d2399
ILT
1008 /* This is a hack to support warn_multiple_gp. FIXME: This should
1009 have a cleaner interface, but what? */
1010 if (! config.warn_multiple_gp
1011 && strcmp (warning, "using multiple gp values") == 0)
1012 return true;
1013
7d6439d9
ILT
1014 if (section != NULL)
1015 einfo ("%C: %s\n", abfd, section, address, warning);
1016 else if (abfd == NULL)
1017 einfo ("%P: %s\n", warning);
1018 else if (symbol == NULL)
1019 einfo ("%B: %s\n", abfd, warning);
1020 else
1021 {
1022 lang_input_statement_type *entry;
1023 asymbol **asymbols;
1024 struct warning_callback_info info;
1025
1026 /* Look through the relocs to see if we can find a plausible
1027 address. */
1028
1029 entry = (lang_input_statement_type *) abfd->usrdata;
1030 if (entry != NULL && entry->asymbols != NULL)
1031 asymbols = entry->asymbols;
1032 else
1033 {
1034 long symsize;
1035 long symbol_count;
1036
1037 symsize = bfd_get_symtab_upper_bound (abfd);
1038 if (symsize < 0)
8bc8f4bc 1039 einfo (_("%B%F: could not read symbols: %E\n"), abfd);
7d6439d9
ILT
1040 asymbols = (asymbol **) xmalloc (symsize);
1041 symbol_count = bfd_canonicalize_symtab (abfd, asymbols);
1042 if (symbol_count < 0)
8bc8f4bc 1043 einfo (_("%B%F: could not read symbols: %E\n"), abfd);
7d6439d9
ILT
1044 if (entry != NULL)
1045 {
1046 entry->asymbols = asymbols;
1047 entry->symbol_count = symbol_count;
1048 }
1049 }
1050
1051 info.found = false;
1052 info.warning = warning;
1053 info.symbol = symbol;
1054 info.asymbols = asymbols;
1055 bfd_map_over_sections (abfd, warning_find_reloc, (PTR) &info);
1056
1057 if (! info.found)
1058 einfo ("%B: %s\n", abfd, warning);
582dd77f
ILT
1059
1060 if (entry == NULL)
1061 free (asymbols);
7d6439d9
ILT
1062 }
1063
b9395be3 1064 return true;
2fa0b342
DHW
1065}
1066
7d6439d9
ILT
1067/* This is called by warning_callback for each section. It checks the
1068 relocs of the section to see if it can find a reference to the
1069 symbol which triggered the warning. If it can, it uses the reloc
1070 to give an error message with a file and line number. */
1071
1072static void
1073warning_find_reloc (abfd, sec, iarg)
1074 bfd *abfd;
1075 asection *sec;
1076 PTR iarg;
1077{
1078 struct warning_callback_info *info = (struct warning_callback_info *) iarg;
1079 long relsize;
1080 arelent **relpp;
1081 long relcount;
1082 arelent **p, **pend;
1083
1084 if (info->found)
1085 return;
1086
1087 relsize = bfd_get_reloc_upper_bound (abfd, sec);
1088 if (relsize < 0)
8bc8f4bc 1089 einfo (_("%B%F: could not read relocs: %E\n"), abfd);
7d6439d9
ILT
1090 if (relsize == 0)
1091 return;
1092
1093 relpp = (arelent **) xmalloc (relsize);
1094 relcount = bfd_canonicalize_reloc (abfd, sec, relpp, info->asymbols);
1095 if (relcount < 0)
8bc8f4bc 1096 einfo (_("%B%F: could not read relocs: %E\n"), abfd);
7d6439d9
ILT
1097
1098 p = relpp;
1099 pend = p + relcount;
1100 for (; p < pend && *p != NULL; p++)
1101 {
1102 arelent *q = *p;
1103
1104 if (q->sym_ptr_ptr != NULL
1105 && *q->sym_ptr_ptr != NULL
1106 && strcmp (bfd_asymbol_name (*q->sym_ptr_ptr), info->symbol) == 0)
1107 {
1108 /* We found a reloc for the symbol we are looking for. */
1109 einfo ("%C: %s\n", abfd, sec, q->address, info->warning);
1110 info->found = true;
1111 break;
1112 }
1113 }
1114
1115 free (relpp);
1116}
1117
b9395be3 1118/* This is called when an undefined symbol is found. */
2fa0b342 1119
b9395be3
ILT
1120/*ARGSUSED*/
1121static boolean
1122undefined_symbol (info, name, abfd, section, address)
1123 struct bfd_link_info *info;
1124 const char *name;
1125 bfd *abfd;
1126 asection *section;
1127 bfd_vma address;
1128{
1129 static char *error_name;
1130 static unsigned int error_count;
29f33467 1131
b9395be3 1132#define MAX_ERRORS_IN_A_ROW 5
8a045e50 1133
809ee7e0
ILT
1134 if (config.warn_once)
1135 {
1136 static struct bfd_hash_table *hash;
1137
1138 /* Only warn once about a particular undefined symbol. */
1139
1140 if (hash == NULL)
1141 {
1142 hash = ((struct bfd_hash_table *)
1143 xmalloc (sizeof (struct bfd_hash_table)));
1144 if (! bfd_hash_table_init (hash, bfd_hash_newfunc))
8bc8f4bc 1145 einfo (_("%F%P: bfd_hash_table_init failed: %E\n"));
809ee7e0
ILT
1146 }
1147
1148 if (bfd_hash_lookup (hash, name, false, false) != NULL)
1149 return true;
1150
1151 if (bfd_hash_lookup (hash, name, true, true) == NULL)
8bc8f4bc 1152 einfo (_("%F%P: bfd_hash_lookup failed: %E\n"));
809ee7e0
ILT
1153 }
1154
b9395be3
ILT
1155 /* We never print more than a reasonable number of errors in a row
1156 for a single symbol. */
1157 if (error_name != (char *) NULL
1158 && strcmp (name, error_name) == 0)
1159 ++error_count;
1160 else
e47bfa63 1161 {
b9395be3
ILT
1162 error_count = 0;
1163 if (error_name != (char *) NULL)
1164 free (error_name);
1165 error_name = buystring (name);
1166 }
2fa0b342 1167
23244cd6
ILT
1168 if (section != NULL)
1169 {
1170 if (error_count < MAX_ERRORS_IN_A_ROW)
8bc8f4bc 1171 einfo (_("%X%C: undefined reference to `%T'\n"),
23244cd6
ILT
1172 abfd, section, address, name);
1173 else if (error_count == MAX_ERRORS_IN_A_ROW)
8bc8f4bc 1174 einfo (_("%D: more undefined references to `%T' follow\n"),
23244cd6
ILT
1175 abfd, section, address, name);
1176 }
1177 else
1178 {
1179 if (error_count < MAX_ERRORS_IN_A_ROW)
8bc8f4bc 1180 einfo (_("%X%B: undefined reference to `%T'\n"),
23244cd6
ILT
1181 abfd, name);
1182 else if (error_count == MAX_ERRORS_IN_A_ROW)
8bc8f4bc 1183 einfo (_("%B: more undefined references to `%T' follow\n"),
23244cd6
ILT
1184 abfd, name);
1185 }
2fa0b342 1186
b9395be3 1187 return true;
2fa0b342
DHW
1188}
1189
b9395be3 1190/* This is called when a reloc overflows. */
2fa0b342 1191
b9395be3 1192/*ARGSUSED*/
9f629407 1193static boolean
5dad4c97 1194reloc_overflow (info, name, reloc_name, addend, abfd, section, address)
b9395be3 1195 struct bfd_link_info *info;
5dad4c97
ILT
1196 const char *name;
1197 const char *reloc_name;
1198 bfd_vma addend;
b9395be3
ILT
1199 bfd *abfd;
1200 asection *section;
1201 bfd_vma address;
2fa0b342 1202{
2a9fa50c 1203 if (abfd == (bfd *) NULL)
8bc8f4bc 1204 einfo (_("%P%X: generated"));
2a9fa50c
ILT
1205 else
1206 einfo ("%X%C:", abfd, section, address);
8bc8f4bc 1207 einfo (_(" relocation truncated to fit: %s %T"), reloc_name, name);
5dad4c97
ILT
1208 if (addend != 0)
1209 einfo ("+%v", addend);
1210 einfo ("\n");
b9395be3
ILT
1211 return true;
1212}
2fa0b342 1213
b9395be3 1214/* This is called when a dangerous relocation is made. */
3e4c643d 1215
b9395be3
ILT
1216/*ARGSUSED*/
1217static boolean
1218reloc_dangerous (info, message, abfd, section, address)
1219 struct bfd_link_info *info;
1220 const char *message;
1221 bfd *abfd;
1222 asection *section;
1223 bfd_vma address;
1224{
2a9fa50c 1225 if (abfd == (bfd *) NULL)
8bc8f4bc 1226 einfo (_("%P%X: generated"));
2a9fa50c
ILT
1227 else
1228 einfo ("%X%C:", abfd, section, address);
8bc8f4bc 1229 einfo (_("dangerous relocation: %s\n"), message);
b9395be3
ILT
1230 return true;
1231}
973e421e 1232
b9395be3
ILT
1233/* This is called when a reloc is being generated attached to a symbol
1234 that is not being output. */
2fa0b342 1235
b9395be3
ILT
1236/*ARGSUSED*/
1237static boolean
1238unattached_reloc (info, name, abfd, section, address)
1239 struct bfd_link_info *info;
1240 const char *name;
1241 bfd *abfd;
1242 asection *section;
1243 bfd_vma address;
1244{
2a9fa50c 1245 if (abfd == (bfd *) NULL)
8bc8f4bc 1246 einfo (_("%P%X: generated"));
2a9fa50c
ILT
1247 else
1248 einfo ("%X%C:", abfd, section, address);
8bc8f4bc 1249 einfo (_(" reloc refers to symbol `%T' which is not being output\n"), name);
b9395be3 1250 return true;
2fa0b342 1251}
8a045e50 1252
cd09553a
ILT
1253/* This is called if link_info.notice_all is set, or when a symbol in
1254 link_info.notice_hash is found. Symbols are put in notice_hash
1255 using the -y option. */
b9395be3 1256
b9395be3 1257static boolean
cd09553a 1258notice (info, name, abfd, section, value)
b9395be3
ILT
1259 struct bfd_link_info *info;
1260 const char *name;
1261 bfd *abfd;
1262 asection *section;
1263 bfd_vma value;
8a045e50 1264{
cd09553a
ILT
1265 if (! info->notice_all
1266 || (info->notice_hash != NULL
1267 && bfd_hash_lookup (info->notice_hash, name, false, false) != NULL))
8bc8f4bc
TT
1268 {
1269 if (bfd_is_und_section (section))
1270 einfo ("%B: reference to %s\n", abfd, name);
1271 else
1272 einfo ("%B: definition of %s\n", abfd, name);
1273 }
cd09553a 1274
582dd77f 1275 if (command_line.cref || nocrossref_list != NULL)
cd09553a
ILT
1276 add_cref (name, abfd, section, value);
1277
b9395be3 1278 return true;
8a045e50 1279}
This page took 0.505943 seconds and 4 git commands to generate.