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