* corefile.c (generic_search): Delete disabled code.
[deliverable/binutils-gdb.git] / gold / gold.h
CommitLineData
bae7f79e
ILT
1// gold.h -- general definitions for gold -*- C++ -*-
2
ebdbb458 3// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
6cb15b7f
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
bae7f79e 23#ifndef GOLD_GOLD_H
6724bacc 24#define GOLD_GOLD_H
bae7f79e
ILT
25
26#include "config.h"
27#include "ansidecl.h"
28
cbb93e63
ILT
29#include <cstddef>
30#include <sys/types.h>
31
801647d1
ILT
32#ifndef ENABLE_NLS
33 // The Solaris version of locale.h always includes libintl.h. If we
34 // have been configured with --disable-nls then ENABLE_NLS will not
35 // be defined and the dummy definitions of bindtextdomain (et al)
36 // below will conflict with the defintions in libintl.h. So we
37 // define these values to prevent the bogus inclusion of libintl.h.
38# define _LIBINTL_H
39# define _LIBGETTEXT_H
40#endif
41
42// Always include <clocale> first to avoid conflicts with the macros
43// used when ENABLE_NLS is not defined.
44#include <clocale>
45
bae7f79e
ILT
46#ifdef ENABLE_NLS
47# include <libintl.h>
48# define _(String) gettext (String)
49# ifdef gettext_noop
50# define N_(String) gettext_noop (String)
51# else
52# define N_(String) (String)
53# endif
54#else
55# define gettext(Msgid) (Msgid)
56# define dgettext(Domainname, Msgid) (Msgid)
57# define dcgettext(Domainname, Msgid, Category) (Msgid)
58# define textdomain(Domainname) while (0) /* nothing */
59# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */
60# define _(String) (String)
61# define N_(String) (String)
62#endif
63
54dc6425
ILT
64// Figure out how to get a hash set and a hash map.
65
d288e464 66#if defined(HAVE_TR1_UNORDERED_SET) && defined(HAVE_TR1_UNORDERED_MAP)
bae7f79e
ILT
67
68#include <tr1/unordered_set>
69#include <tr1/unordered_map>
70
71// We need a template typedef here.
72
73#define Unordered_set std::tr1::unordered_set
74#define Unordered_map std::tr1::unordered_map
75
d288e464 76#elif defined(HAVE_EXT_HASH_MAP) && defined(HAVE_EXT_HASH_SET)
54dc6425
ILT
77
78#include <ext/hash_map>
79#include <ext/hash_set>
274e99f9 80#include <string>
54dc6425
ILT
81
82#define Unordered_set __gnu_cxx::hash_set
83#define Unordered_map __gnu_cxx::hash_map
84
274e99f9
ILT
85namespace __gnu_cxx
86{
87
88template<>
89struct hash<std::string>
90{
91 size_t
92 operator()(std::string s) const
93 { return __stl_hash_string(s.c_str()); }
94};
95
96template<typename T>
97struct hash<T*>
98{
99 size_t
100 operator()(T* p) const
101 { return reinterpret_cast<size_t>(p); }
102};
103
104}
105
54dc6425
ILT
106#else
107
108// The fallback is to just use set and map.
109
110#include <set>
111#include <map>
112
113#define Unordered_set std::set
114#define Unordered_map std::map
115
116#endif
117
82dcae9d
ILT
118#ifndef HAVE_PREAD
119extern "C" ssize_t pread(int, void*, size_t, off_t);
120#endif
121
5482377d
ILT
122namespace gold
123{
5482377d 124
8383303e 125// General declarations.
bae7f79e 126
61ba1cf9 127class General_options;
5a6f7e2d 128class Command_line;
92e059d8
ILT
129class Input_argument_list;
130class Dirsearch;
61ba1cf9 131class Input_objects;
7d9e3d98 132class Mapfile;
75f2446e 133class Symbol;
61ba1cf9
ILT
134class Symbol_table;
135class Layout;
17a1d0a9 136class Task;
61ba1cf9
ILT
137class Workqueue;
138class Output_file;
75f2446e
ILT
139template<int size, bool big_endian>
140struct Relocate_info;
61ba1cf9 141
8383303e
ILT
142// Some basic types. For these we use lower case initial letters.
143
144// For an offset in an input or output file, use off_t. Note that
145// this will often be a 64-bit type even for a 32-bit build.
146
147// The size of a section if we are going to look at the contents.
148typedef size_t section_size_type;
149
150// An offset within a section when we are looking at the contents.
151typedef ptrdiff_t section_offset_type;
152
bae7f79e
ILT
153// The name of the program as used in error messages.
154extern const char* program_name;
155
156// This function is called to exit the program. Status is true to
157// exit success (0) and false to exit failure (1).
158extern void
159gold_exit(bool status) ATTRIBUTE_NORETURN;
160
75f2446e
ILT
161// This function is called to emit an error message and then
162// immediately exit with failure.
163extern void
164gold_fatal(const char* format, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1;
165
166// This function is called to issue an error. This will cause gold to
167// eventually exit with failure.
168extern void
169gold_error(const char* msg, ...) ATTRIBUTE_PRINTF_1;
170
171// This function is called to issue a warning.
172extern void
173gold_warning(const char* msg, ...) ATTRIBUTE_PRINTF_1;
174
c5818ff1
CC
175// This function is called to print an informational message.
176extern void
177gold_info(const char* msg, ...) ATTRIBUTE_PRINTF_1;
178
04bf7072
ILT
179// Work around a bug in gcc 4.3.0. http://gcc.gnu.org/PR35546 . This
180// can probably be removed after the bug has been fixed for a while.
181#ifdef HAVE_TEMPLATE_ATTRIBUTES
182#define TEMPLATE_ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF_4
183#else
184#define TEMPLATE_ATTRIBUTE_PRINTF_4
185#endif
186
75f2446e
ILT
187// This function is called to issue an error at the location of a
188// reloc.
189template<int size, bool big_endian>
190extern void
191gold_error_at_location(const Relocate_info<size, big_endian>*,
192 size_t, off_t, const char* format, ...)
04bf7072 193 TEMPLATE_ATTRIBUTE_PRINTF_4;
75f2446e
ILT
194
195// This function is called to issue a warning at the location of a
196// reloc.
197template<int size, bool big_endian>
198extern void
199gold_warning_at_location(const Relocate_info<size, big_endian>*,
200 size_t, off_t, const char* format, ...)
04bf7072 201 TEMPLATE_ATTRIBUTE_PRINTF_4;
75f2446e
ILT
202
203// This function is called to report an undefined symbol.
204template<int size, bool big_endian>
bae7f79e 205extern void
75f2446e
ILT
206gold_undefined_symbol(const Symbol*,
207 const Relocate_info<size, big_endian>*,
208 size_t, off_t);
bae7f79e
ILT
209
210// This is function is called in some cases if we run out of memory.
211extern void
212gold_nomem() ATTRIBUTE_NORETURN;
213
a3ad94ed
ILT
214// This macro and function are used in cases which can not arise if
215// the code is written correctly.
216
217#define gold_unreachable() \
218 (gold::do_gold_unreachable(__FILE__, __LINE__, __FUNCTION__))
219
220extern void do_gold_unreachable(const char*, int, const char*)
221 ATTRIBUTE_NORETURN;
222
223// Assertion check.
224
225#define gold_assert(expr) ((void)(!(expr) ? gold_unreachable(), 0 : 0))
bae7f79e 226
8486ee48
ILT
227// Print version information.
228extern void
229print_version(bool print_short);
230
4f211c8b
ILT
231// Get the version string.
232extern const char*
233get_version_string();
234
8383303e
ILT
235// Convert numeric types without unnoticed loss of precision.
236template<typename To, typename From>
237inline To
238convert_types(const From from)
239{
240 To to = from;
9bb53bf8 241 gold_assert(static_cast<From>(to) == from);
8383303e
ILT
242 return to;
243}
244
245// A common case of convert_types<>: convert to section_size_type.
246template<typename From>
247inline section_size_type
248convert_to_section_size_type(const From from)
249{ return convert_types<section_size_type, From>(from); }
250
92e059d8
ILT
251// Queue up the first set of tasks.
252extern void
253queue_initial_tasks(const General_options&,
17a1d0a9 254 Dirsearch&,
5a6f7e2d 255 const Command_line&,
92e059d8
ILT
256 Workqueue*,
257 Input_objects*,
258 Symbol_table*,
7d9e3d98
ILT
259 Layout*,
260 Mapfile*);
92e059d8
ILT
261
262// Queue up the middle set of tasks.
263extern void
264queue_middle_tasks(const General_options&,
17a1d0a9 265 const Task*,
92e059d8
ILT
266 const Input_objects*,
267 Symbol_table*,
268 Layout*,
7d9e3d98
ILT
269 Workqueue*,
270 Mapfile*);
92e059d8
ILT
271
272// Queue up the final set of tasks.
61ba1cf9
ILT
273extern void
274queue_final_tasks(const General_options&,
275 const Input_objects*,
276 const Symbol_table*,
27bc2bce 277 Layout*,
61ba1cf9
ILT
278 Workqueue*,
279 Output_file* of);
280
bae7f79e
ILT
281} // End namespace gold.
282
283#endif // !defined(GOLD_GOLD_H)
This page took 0.113982 seconds and 4 git commands to generate.