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