* options.h (class General_options): Add -Bsymbolic-functions.
[deliverable/binutils-gdb.git] / gold / errors.h
CommitLineData
75f2446e
ILT
1// errors.h -- handle errors for gold -*- C++ -*-
2
ebdbb458 3// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
75f2446e
ILT
4// Written by Ian Lance Taylor <iant@google.com>.
5
6// This file is part of gold.
7
8// This program is free software; you can redistribute it and/or modify
9// it under the terms of the GNU General Public License as published by
10// the Free Software Foundation; either version 3 of the License, or
11// (at your option) any later version.
12
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21// MA 02110-1301, USA.
22
23#ifndef GOLD_ERRORS_H
24#define GOLD_ERRORS_H
25
26#include <cstdarg>
27
28#include "gold-threads.h"
29
30namespace gold
31{
32
33class Symbol;
34template<int size, bool big_endian>
35struct Relocate_info;
36
37// This class handles errors for gold. There is a single instance
38// which is used by all threads. If and when we make the gold code
39// more amenable to being used in a library, we will make this an
40// abstract interface class, and expect the caller to provide their
41// own instantiation.
42
43class Errors
44{
45 public:
46 Errors(const char* program_name);
47
48 // Report a fatal error. After printing the error, this must exit.
49 void
50 fatal(const char* format, va_list) ATTRIBUTE_NORETURN;
51
52 // Report an error and continue.
53 void
54 error(const char* format, va_list);
55
56 // Report a warning and continue.
57 void
58 warning(const char* format, va_list);
c5818ff1
CC
59
60 // Print an informational message and continue.
61 void
62 info(const char* format, va_list);
75f2446e
ILT
63
64 // Report an error at a reloc location.
65 template<int size, bool big_endian>
66 void
67 error_at_location(const Relocate_info<size, big_endian>* relinfo,
68 size_t relnum, off_t reloffset,
69 const char* format, va_list);
70
71 // Report a warning at a reloc location.
72 template<int size, bool big_endian>
73 void
74 warning_at_location(const Relocate_info<size, big_endian>* relinfo,
75 size_t relnum, off_t reloffset,
76 const char* format, va_list);
77
78 // Issue an undefined symbol error. SYM is the undefined symbol.
79 // RELINFO is the general relocation info. RELNUM is the number of
80 // the reloc, and RELOFFSET is the reloc's offset.
81 template<int size, bool big_endian>
82 void
83 undefined_symbol(const Symbol* sym,
84 const Relocate_info<size, big_endian>* relinfo,
85 size_t relnum, off_t reloffset);
86
c7912668
ILT
87 // Report a debugging message.
88 void
89 debug(const char* format, ...) ATTRIBUTE_PRINTF_2;
90
75f2446e
ILT
91 // Return the number of errors.
92 int
93 error_count() const
94 { return this->error_count_; }
95
96 private:
97 Errors(const Errors&);
98 Errors& operator=(const Errors&);
99
c7912668
ILT
100 // Initialize the lock. We don't do this in the constructor because
101 // lock initialization wants to know whether we are using threads or
2dd3e587
ILT
102 // not. This returns true if the lock is now initialized.
103 bool
c7912668
ILT
104 initialize_lock();
105
2dd3e587
ILT
106 // Increment a counter, holding the lock.
107 void
108 increment_counter(int*);
109
75f2446e
ILT
110 // The number of times we report an undefined symbol.
111 static const int max_undefined_error_report = 5;
112
113 // The name of the program.
114 const char* program_name_;
115 // This class can be accessed from multiple threads. This lock is
116 // used to control access to the data structures.
c7912668 117 Lock* lock_;
75f2446e
ILT
118 // Numbers of errors reported.
119 int error_count_;
120 // Number of warnings reported.
121 int warning_count_;
122 // A map counting the numbers of times we have seen an undefined
123 // symbol.
124 Unordered_map<const Symbol*, int> undefined_symbols_;
125};
126
127} // End namespace gold.
128
129#endif // !defined(GOLD_ERRORS_H)
This page took 0.05274 seconds and 4 git commands to generate.