Commit | Line | Data |
---|---|---|
fcf276c4 ILT |
1 | /* Copyright (C) 1991, 1993 Free Software Foundation, Inc. |
2 | Written by Steve Chamberlain steve@cygnus.com | |
3 | ||
4 | This file is part of GLD, the Gnu Linker. | |
5 | ||
6 | GLD is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GLD is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GLD; see the file COPYING. If not, write to | |
18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | ||
20 | #include <bfd.h> | |
cbbdbb9f SC |
21 | #include "sysdep.h" |
22 | #include "../bfd/seclet.h" | |
23 | #include "ld.h" | |
9aa97a39 | 24 | #include "ldmisc.h" |
9f629407 | 25 | #include "lderror.h" |
cbbdbb9f SC |
26 | |
27 | #define MAX_ERRORS_IN_A_ROW 5 | |
28 | ||
cbbdbb9f SC |
29 | extern bfd_error_vector_type bfd_error_vector; |
30 | ||
9f629407 ILT |
31 | static void ld_undefined_symbol PARAMS ((const arelent *, |
32 | const bfd_seclet_type *)); | |
33 | static void ld_reloc_truncated PARAMS ((const arelent *, | |
34 | bfd_seclet_type *)); | |
35 | ||
cbbdbb9f SC |
36 | /* BFD has failed to link something, give a better error message */ |
37 | ||
38 | static void | |
8ddef552 DM |
39 | ld_undefined_symbol (relent, seclet) |
40 | CONST arelent *relent; | |
41 | CONST bfd_seclet_type *seclet; | |
cbbdbb9f SC |
42 | { |
43 | asymbol *s = *(relent->sym_ptr_ptr); | |
44 | static asymbol *error_symbol; | |
45 | static unsigned int error_count; | |
46 | if (seclet != (bfd_seclet_type *)NULL) | |
47 | { | |
48 | ||
49 | asection *section = seclet->u.indirect.section; | |
50 | bfd *abfd = section->owner; | |
51 | ||
52 | ||
53 | /* We remember the symbol, and never print more than | |
54 | a reasonable number of them in a row */ | |
55 | if (s == error_symbol) { | |
56 | error_count++; | |
57 | } | |
58 | else { | |
59 | error_count = 0; | |
60 | error_symbol = s; | |
61 | } | |
62 | if (error_count < MAX_ERRORS_IN_A_ROW) { | |
ca3c5c63 | 63 | einfo("%X%C: undefined reference to `%T'\n", |
cbbdbb9f SC |
64 | abfd,section, seclet->u.indirect.symbols, |
65 | relent->address, s); | |
66 | config.make_executable = false; | |
67 | ||
68 | } | |
69 | else if (error_count == MAX_ERRORS_IN_A_ROW) { | |
70 | einfo("%C: more undefined references to `%T' follow\n", | |
71 | abfd, section, | |
72 | seclet->u.indirect.symbols, | |
73 | relent->address, s); | |
74 | } | |
75 | else { | |
76 | /* Don't print any more */ | |
77 | } | |
78 | } | |
79 | else | |
80 | { | |
ca3c5c63 | 81 | einfo("%Xundefined reference to %s\n", (*(relent->sym_ptr_ptr))->name); |
cbbdbb9f SC |
82 | } |
83 | } | |
9f629407 | 84 | |
cbbdbb9f | 85 | static void |
8ddef552 DM |
86 | ld_reloc_truncated (relent, seclet) |
87 | CONST arelent *relent; | |
88 | bfd_seclet_type *seclet; | |
cbbdbb9f | 89 | { |
cbbdbb9f SC |
90 | asection *section = seclet->u.indirect.section; |
91 | bfd *abfd = section->owner; | |
92 | ||
93 | einfo("%X%C: relocation truncated to fit %R\n", | |
94 | abfd, section, seclet->u.indirect.symbols, relent->address, relent); | |
cbbdbb9f | 95 | } |
cbbdbb9f SC |
96 | |
97 | void | |
8ddef552 | 98 | init_bfd_error_vector () |
cbbdbb9f | 99 | { |
9aa97a39 SC |
100 | bfd_error_vector.undefined_symbol = ld_undefined_symbol; |
101 | bfd_error_vector.reloc_value_truncated = ld_reloc_truncated; | |
cbbdbb9f | 102 | } |