summaryrefslogtreecommitdiffstats
path: root/gold/script-c.h
blob: da8b558c298a75f0218f1952ca4a619ddf198115 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/* script-c.h -- C interface for linker scripts in gold.  */

/* Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
   Written by Ian Lance Taylor <iant@google.com>.

   This file is part of gold.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
   MA 02110-1301, USA.  */

/* This file exists so that both the bison parser and script.cc can
   include it, so that they can communicate back and forth.  */

#ifndef GOLD_SCRIPT_C_H
#define GOLD_SCRIPT_C_H

#ifdef __cplusplus
extern "C" {
#endif

/* A string value for the bison parser.  */

struct Parser_string
{
  const char* value;
  size_t length;
};

/* The expression functions deal with pointers to Expression objects.
   Since the bison parser generates C code, this is a hack to keep the
   C++ code type safe.  This hacks assumes that all pointers look
   alike.  */

#ifdef __cplusplus
namespace gold
{
class Expression;
}
typedef gold::Expression* Expression_ptr;
#else
typedef void* Expression_ptr;
#endif

/* The bison parser definitions.  */

#include "yyscript.h"

/* The bison parser function.  */

extern int
yyparse(void* closure);

/* Called by the bison parser skeleton to return the next token.  */

extern int
yylex(YYSTYPE*, void* closure);

/* Called by the bison parser skeleton to report an error.  */

extern void
yyerror(void* closure, const char*);

/* Called by the bison parser to add a file to the link.  */

extern void
script_add_file(void* closure, const char*, size_t);

/* Called by the bison parser to start and stop a group.  */

extern void
script_start_group(void* closure);
extern void
script_end_group(void* closure);

/* Called by the bison parser to start and end an AS_NEEDED list.  */

extern void
script_start_as_needed(void* closure);
extern void
script_end_as_needed(void* closure);

/* Called by the bison parser to set the entry symbol.  */

extern void
script_set_entry(void* closure, const char*, size_t);

/* Called by the bison parser to parse an OPTION.  */

extern void
script_parse_option(void* closure, const char*, size_t);

/* Called by the bison parser to push the lexer into expression
   mode.  */

extern void
script_push_lex_into_expression_mode(void* closure);

/* Called by the bison parser to push the lexer into version
   mode.  */

extern void
script_push_lex_into_version_mode(void* closure);

/* Called by the bison parser to pop the lexer mode.  */

extern void
script_pop_lex_mode(void* closure);

/* Called by the bison parser to set a symbol to a value.  PROVIDE is
   non-zero if the symbol should be provided--only defined if there is
   an undefined reference.  HIDDEN is non-zero if the symbol should be
   hidden.  */

extern void
script_set_symbol(void* closure, const char*, size_t, Expression_ptr,
		  int provide, int hidden);

/* Called by the bison parser for expressions.  */

extern Expression_ptr
script_exp_unary_minus(Expression_ptr);
extern Expression_ptr
script_exp_unary_logical_not(Expression_ptr);
extern Expression_ptr
script_exp_unary_bitwise_not(Expression_ptr);
extern Expression_ptr
script_exp_binary_mult(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_div(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_mod(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_add(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_sub(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_lshift(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_rshift(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_eq(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_ne(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_le(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_ge(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_lt(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_gt(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_bitwise_and(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_bitwise_xor(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_bitwise_or(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_logical_and(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_logical_or(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_trinary_cond(Expression_ptr, Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_integer(uint64_t);
extern Expression_ptr
script_exp_string(const char*, size_t);
extern Expression_ptr
script_exp_function_max(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_function_min(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_function_defined(const char*, size_t);
extern Expression_ptr
script_exp_function_sizeof_headers();
extern Expression_ptr
script_exp_function_alignof(const char*, size_t);
extern Expression_ptr
script_exp_function_sizeof(const char*, size_t);
extern Expression_ptr
script_exp_function_addr(const char*, size_t);
extern Expression_ptr
script_exp_function_loadaddr(const char*, size_t);
extern Expression_ptr
script_exp_function_origin(const char*, size_t);
extern Expression_ptr
script_exp_function_length(const char*, size_t);
extern Expression_ptr
script_exp_function_constant(const char*, size_t);
extern Expression_ptr
script_exp_function_absolute(Expression_ptr);
extern Expression_ptr
script_exp_function_align(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_function_data_segment_align(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_function_data_segment_relro_end(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_function_data_segment_end(Expression_ptr);
extern Expression_ptr
script_exp_function_segment_start(const char*, size_t, Expression_ptr);
extern Expression_ptr
script_exp_function_assert(Expression_ptr, const char*, size_t);

struct Version_dependency_list;
struct Version_expression_list;
struct Version_tree;

extern void
script_register_vers_node(void* closure,
			  const char* tag,
			  int taglen,
			  struct Version_tree *,
			  struct Version_dependency_list *);

extern struct Version_dependency_list *
script_add_vers_depend(void* closure,
		       struct Version_dependency_list *existing_dependencies,
		       const char *depend_to_add, int deplen);

extern struct Version_expression_list *
script_new_vers_pattern(void* closure,
			struct Version_expression_list *,
			const char *, int, int);

extern struct Version_expression_list *
script_merge_expressions(struct Version_expression_list *a,
                         struct Version_expression_list *b);

extern struct Version_tree *
script_new_vers_node(void* closure,
		     struct Version_expression_list *global,
		     struct Version_expression_list *local);

extern void
version_script_push_lang(void* closure, const char* lang, int langlen);

extern void
version_script_pop_lang(void* closure);

#ifdef __cplusplus
}
#endif

#endif /* !defined(GOLD_SCRIPT_C_H) */
OpenPOWER on IntegriCloud