Add __ImageBase symbol to pe.em and pep.em.
[binutils.git] / gold / errors.h
blob545c463bad31568fe1df813b62c9cbf4da1995be
1 // errors.h -- handle errors for gold -*- C++ -*-
3 // Copyright 2006, 2007 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
6 // This file is part of gold.
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.
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.
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.
23 #ifndef GOLD_ERRORS_H
24 #define GOLD_ERRORS_H
26 #include <cstdarg>
28 #include "gold-threads.h"
30 namespace gold
33 class Symbol;
34 template<int size, bool big_endian>
35 struct Relocate_info;
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.
43 class Errors
45 public:
46 Errors(const char* program_name);
48 // Report a fatal error. After printing the error, this must exit.
49 void
50 fatal(const char* format, va_list) ATTRIBUTE_NORETURN;
52 // Report an error and continue.
53 void
54 error(const char* format, va_list);
56 // Report a warning and continue.
57 void
58 warning(const char* format, va_list);
60 // Report an error at a reloc location.
61 template<int size, bool big_endian>
62 void
63 error_at_location(const Relocate_info<size, big_endian>* relinfo,
64 size_t relnum, off_t reloffset,
65 const char* format, va_list);
67 // Report a warning at a reloc location.
68 template<int size, bool big_endian>
69 void
70 warning_at_location(const Relocate_info<size, big_endian>* relinfo,
71 size_t relnum, off_t reloffset,
72 const char* format, va_list);
74 // Issue an undefined symbol error. SYM is the undefined symbol.
75 // RELINFO is the general relocation info. RELNUM is the number of
76 // the reloc, and RELOFFSET is the reloc's offset.
77 template<int size, bool big_endian>
78 void
79 undefined_symbol(const Symbol* sym,
80 const Relocate_info<size, big_endian>* relinfo,
81 size_t relnum, off_t reloffset);
83 // Return the number of errors.
84 int
85 error_count() const
86 { return this->error_count_; }
88 private:
89 Errors(const Errors&);
90 Errors& operator=(const Errors&);
92 // The number of times we report an undefined symbol.
93 static const int max_undefined_error_report = 5;
95 // The name of the program.
96 const char* program_name_;
97 // This class can be accessed from multiple threads. This lock is
98 // used to control access to the data structures.
99 Lock lock_;
100 // Numbers of errors reported.
101 int error_count_;
102 // Number of warnings reported.
103 int warning_count_;
104 // A map counting the numbers of times we have seen an undefined
105 // symbol.
106 Unordered_map<const Symbol*, int> undefined_symbols_;
109 } // End namespace gold.
111 #endif // !defined(GOLD_ERRORS_H)