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