xref: /dflybsd-src/contrib/binutils-2.27/gold/dwp.h (revision e656dc90e3d65d744d534af2f5ea88cf8101ebcf)
1*a9fa9459Szrj // dwp.h -- general definitions for dwp.
2*a9fa9459Szrj 
3*a9fa9459Szrj // Copyright (C) 2012-2016 Free Software Foundation, Inc.
4*a9fa9459Szrj // Written by Cary Coutant <ccoutant@google.com>.
5*a9fa9459Szrj 
6*a9fa9459Szrj // This file is part of dwp, the DWARF packaging utility.
7*a9fa9459Szrj 
8*a9fa9459Szrj // This program is free software; you can redistribute it and/or modify
9*a9fa9459Szrj // it under the terms of the GNU General Public License as published by
10*a9fa9459Szrj // the Free Software Foundation; either version 3 of the License, or
11*a9fa9459Szrj // (at your option) any later version.
12*a9fa9459Szrj 
13*a9fa9459Szrj // This program is distributed in the hope that it will be useful,
14*a9fa9459Szrj // but WITHOUT ANY WARRANTY; without even the implied warranty of
15*a9fa9459Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*a9fa9459Szrj // GNU General Public License for more details.
17*a9fa9459Szrj 
18*a9fa9459Szrj // You should have received a copy of the GNU General Public License
19*a9fa9459Szrj // along with this program; if not, write to the Free Software
20*a9fa9459Szrj // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21*a9fa9459Szrj // MA 02110-1301, USA.
22*a9fa9459Szrj 
23*a9fa9459Szrj #ifndef DWP_DWP_H
24*a9fa9459Szrj #define DWP_DWP_H 1
25*a9fa9459Szrj 
26*a9fa9459Szrj #include "config.h"
27*a9fa9459Szrj #include "ansidecl.h"
28*a9fa9459Szrj 
29*a9fa9459Szrj #include <cstddef>
30*a9fa9459Szrj #include <cstdlib>
31*a9fa9459Szrj #include <cstring>
32*a9fa9459Szrj #include <stdint.h>
33*a9fa9459Szrj #include <sys/types.h>
34*a9fa9459Szrj 
35*a9fa9459Szrj #include "system.h"
36*a9fa9459Szrj 
37*a9fa9459Szrj namespace gold
38*a9fa9459Szrj {
39*a9fa9459Szrj 
40*a9fa9459Szrj extern const char* program_name;
41*a9fa9459Szrj 
42*a9fa9459Szrj class General_options;
43*a9fa9459Szrj class Command_line;
44*a9fa9459Szrj class Dirsearch;
45*a9fa9459Szrj class Input_objects;
46*a9fa9459Szrj class Mapfile;
47*a9fa9459Szrj class Symbol;
48*a9fa9459Szrj class Symbol_table;
49*a9fa9459Szrj class Layout;
50*a9fa9459Szrj class Task;
51*a9fa9459Szrj class Workqueue;
52*a9fa9459Szrj class Output_file;
53*a9fa9459Szrj template<int size, bool big_endian>
54*a9fa9459Szrj struct Relocate_info;
55*a9fa9459Szrj 
56*a9fa9459Szrj // The size of a section if we are going to look at the contents.
57*a9fa9459Szrj typedef size_t section_size_type;
58*a9fa9459Szrj 
59*a9fa9459Szrj // An offset within a section when we are looking at the contents.
60*a9fa9459Szrj typedef ptrdiff_t section_offset_type;
61*a9fa9459Szrj 
62*a9fa9459Szrj inline bool
is_prefix_of(const char * prefix,const char * str)63*a9fa9459Szrj is_prefix_of(const char* prefix, const char* str)
64*a9fa9459Szrj {
65*a9fa9459Szrj   return strncmp(prefix, str, strlen(prefix)) == 0;
66*a9fa9459Szrj }
67*a9fa9459Szrj 
68*a9fa9459Szrj // Exit status codes.
69*a9fa9459Szrj 
70*a9fa9459Szrj enum Exit_status
71*a9fa9459Szrj {
72*a9fa9459Szrj   GOLD_OK = EXIT_SUCCESS,
73*a9fa9459Szrj   GOLD_ERR = EXIT_FAILURE,
74*a9fa9459Szrj   GOLD_FALLBACK = EXIT_FAILURE + 1
75*a9fa9459Szrj };
76*a9fa9459Szrj 
77*a9fa9459Szrj // This function is called to exit the program.  Status is true to
78*a9fa9459Szrj // exit success (0) and false to exit failure (1).
79*a9fa9459Szrj extern void
80*a9fa9459Szrj gold_exit(Exit_status status) ATTRIBUTE_NORETURN;
81*a9fa9459Szrj 
82*a9fa9459Szrj // This function is called to emit an error message and then
83*a9fa9459Szrj // immediately exit with failure.
84*a9fa9459Szrj extern void
85*a9fa9459Szrj gold_fatal(const char* format, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1;
86*a9fa9459Szrj 
87*a9fa9459Szrj // This function is called to issue a warning.
88*a9fa9459Szrj extern void
89*a9fa9459Szrj gold_warning(const char* msg, ...) ATTRIBUTE_PRINTF_1;
90*a9fa9459Szrj 
91*a9fa9459Szrj // This function is called to print an informational message.
92*a9fa9459Szrj extern void
93*a9fa9459Szrj gold_info(const char* msg, ...) ATTRIBUTE_PRINTF_1;
94*a9fa9459Szrj 
95*a9fa9459Szrj #define gold_unreachable() \
96*a9fa9459Szrj   (gold::do_gold_unreachable(__FILE__, __LINE__, \
97*a9fa9459Szrj 			     static_cast<const char*>(__FUNCTION__)))
98*a9fa9459Szrj 
99*a9fa9459Szrj extern void do_gold_unreachable(const char*, int, const char*)
100*a9fa9459Szrj   ATTRIBUTE_NORETURN;
101*a9fa9459Szrj 
102*a9fa9459Szrj // Assertion check.
103*a9fa9459Szrj 
104*a9fa9459Szrj #define gold_assert(expr) ((void)(!(expr) ? gold_unreachable(), 0 : 0))
105*a9fa9459Szrj 
106*a9fa9459Szrj // Convert numeric types without unnoticed loss of precision.
107*a9fa9459Szrj template<typename To, typename From>
108*a9fa9459Szrj inline To
convert_types(const From from)109*a9fa9459Szrj convert_types(const From from)
110*a9fa9459Szrj {
111*a9fa9459Szrj   To to = from;
112*a9fa9459Szrj   gold_assert(static_cast<From>(to) == from);
113*a9fa9459Szrj   return to;
114*a9fa9459Szrj }
115*a9fa9459Szrj 
116*a9fa9459Szrj // A common case of convert_types<>: convert to section_size_type.
117*a9fa9459Szrj template<typename From>
118*a9fa9459Szrj inline section_size_type
convert_to_section_size_type(const From from)119*a9fa9459Szrj convert_to_section_size_type(const From from)
120*a9fa9459Szrj { return convert_types<section_size_type, From>(from); }
121*a9fa9459Szrj 
122*a9fa9459Szrj }; // End namespace gold.
123*a9fa9459Szrj 
124*a9fa9459Szrj #endif // !defined(DWP_DWP_H)
125