* ldmain.c (lprefix): Change default from a char to a string
[deliverable/binutils-gdb.git] / ld / lderror.c
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>
21 #include "sysdep.h"
22 #include "../bfd/seclet.h"
23 #include "ld.h"
24 #include "ldmisc.h"
25 #include "lderror.h"
26
27 #define MAX_ERRORS_IN_A_ROW 5
28
29 extern bfd_error_vector_type bfd_error_vector;
30
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
36 /* BFD has failed to link something, give a better error message */
37
38 static void
39 ld_undefined_symbol (relent, seclet)
40 CONST arelent *relent;
41 CONST bfd_seclet_type *seclet;
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) {
63 einfo("%X%C: undefined reference to `%T'\n",
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 {
81 einfo("%Xundefined reference to %s\n", (*(relent->sym_ptr_ptr))->name);
82 }
83 }
84
85 static void
86 ld_reloc_truncated (relent, seclet)
87 CONST arelent *relent;
88 bfd_seclet_type *seclet;
89 {
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);
95 }
96
97 void
98 init_bfd_error_vector ()
99 {
100 bfd_error_vector.undefined_symbol = ld_undefined_symbol;
101 bfd_error_vector.reloc_value_truncated = ld_reloc_truncated;
102 }
This page took 0.041571 seconds and 4 git commands to generate.