]>
Commit | Line | Data |
---|---|---|
dbe717ef ILT |
1 | /* script-c.h -- C interface for linker scripts in gold. */ |
2 | ||
e5756efb | 3 | /* Copyright 2006, 2007, 2008 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 | ||
dbe717ef ILT |
23 | /* This file exists so that both the bison parser and script.cc can |
24 | include it, so that they can communicate back and forth. */ | |
25 | ||
26 | #ifndef GOLD_SCRIPT_C_H | |
27 | #define GOLD_SCRIPT_C_H | |
28 | ||
29 | #ifdef __cplusplus | |
30 | extern "C" { | |
31 | #endif | |
32 | ||
e5756efb ILT |
33 | /* A string value for the bison parser. */ |
34 | ||
35 | struct Parser_string | |
36 | { | |
37 | const char* value; | |
38 | size_t length; | |
39 | }; | |
40 | ||
41 | /* The expression functions deal with pointers to Expression objects. | |
42 | Since the bison parser generates C code, this is a hack to keep the | |
43 | C++ code type safe. This hacks assumes that all pointers look | |
44 | alike. */ | |
45 | ||
46 | #ifdef __cplusplus | |
47 | namespace gold | |
48 | { | |
49 | class Expression; | |
50 | } | |
51 | typedef gold::Expression* Expression_ptr; | |
52 | #else | |
53 | typedef void* Expression_ptr; | |
54 | #endif | |
55 | ||
56 | /* The bison parser definitions. */ | |
57 | ||
dbe717ef ILT |
58 | #include "yyscript.h" |
59 | ||
60 | /* The bison parser function. */ | |
61 | ||
62 | extern int | |
63 | yyparse(void* closure); | |
64 | ||
65 | /* Called by the bison parser skeleton to return the next token. */ | |
66 | ||
67 | extern int | |
68 | yylex(YYSTYPE*, void* closure); | |
69 | ||
70 | /* Called by the bison parser skeleton to report an error. */ | |
71 | ||
72 | extern void | |
73 | yyerror(void* closure, const char*); | |
74 | ||
75 | /* Called by the bison parser to add a file to the link. */ | |
76 | ||
77 | extern void | |
e5756efb | 78 | script_add_file(void* closure, const char*, size_t); |
dbe717ef ILT |
79 | |
80 | /* Called by the bison parser to start and stop a group. */ | |
81 | ||
82 | extern void | |
83 | script_start_group(void* closure); | |
84 | extern void | |
85 | script_end_group(void* closure); | |
86 | ||
87 | /* Called by the bison parser to start and end an AS_NEEDED list. */ | |
88 | ||
89 | extern void | |
90 | script_start_as_needed(void* closure); | |
91 | extern void | |
92 | script_end_as_needed(void* closure); | |
93 | ||
d391083d ILT |
94 | /* Called by the bison parser to set the entry symbol. */ |
95 | ||
96 | extern void | |
e5756efb | 97 | script_set_entry(void* closure, const char*, size_t); |
d391083d | 98 | |
195e7dc6 | 99 | /* Called by the bison parser to parse an OPTION. */ |
e5756efb ILT |
100 | |
101 | extern void | |
102 | script_parse_option(void* closure, const char*, size_t); | |
103 | ||
104 | /* Called by the bison parser to push the lexer into expression | |
105 | mode. */ | |
106 | ||
107 | extern void | |
108 | script_push_lex_into_expression_mode(void* closure); | |
109 | ||
09124467 ILT |
110 | /* Called by the bison parser to push the lexer into version |
111 | mode. */ | |
112 | ||
113 | extern void | |
114 | script_push_lex_into_version_mode(void* closure); | |
115 | ||
e5756efb ILT |
116 | /* Called by the bison parser to pop the lexer mode. */ |
117 | ||
118 | extern void | |
119 | script_pop_lex_mode(void* closure); | |
120 | ||
121 | /* Called by the bison parser to set a symbol to a value. PROVIDE is | |
122 | non-zero if the symbol should be provided--only defined if there is | |
123 | an undefined reference. HIDDEN is non-zero if the symbol should be | |
124 | hidden. */ | |
125 | ||
195e7dc6 | 126 | extern void |
e5756efb ILT |
127 | script_set_symbol(void* closure, const char*, size_t, Expression_ptr, |
128 | int provide, int hidden); | |
129 | ||
130 | /* Called by the bison parser for expressions. */ | |
131 | ||
132 | extern Expression_ptr | |
133 | script_exp_unary_minus(Expression_ptr); | |
134 | extern Expression_ptr | |
135 | script_exp_unary_logical_not(Expression_ptr); | |
136 | extern Expression_ptr | |
137 | script_exp_unary_bitwise_not(Expression_ptr); | |
138 | extern Expression_ptr | |
139 | script_exp_binary_mult(Expression_ptr, Expression_ptr); | |
140 | extern Expression_ptr | |
141 | script_exp_binary_div(Expression_ptr, Expression_ptr); | |
142 | extern Expression_ptr | |
143 | script_exp_binary_mod(Expression_ptr, Expression_ptr); | |
144 | extern Expression_ptr | |
145 | script_exp_binary_add(Expression_ptr, Expression_ptr); | |
146 | extern Expression_ptr | |
147 | script_exp_binary_sub(Expression_ptr, Expression_ptr); | |
148 | extern Expression_ptr | |
149 | script_exp_binary_lshift(Expression_ptr, Expression_ptr); | |
150 | extern Expression_ptr | |
151 | script_exp_binary_rshift(Expression_ptr, Expression_ptr); | |
152 | extern Expression_ptr | |
153 | script_exp_binary_eq(Expression_ptr, Expression_ptr); | |
154 | extern Expression_ptr | |
155 | script_exp_binary_ne(Expression_ptr, Expression_ptr); | |
156 | extern Expression_ptr | |
157 | script_exp_binary_le(Expression_ptr, Expression_ptr); | |
158 | extern Expression_ptr | |
159 | script_exp_binary_ge(Expression_ptr, Expression_ptr); | |
160 | extern Expression_ptr | |
161 | script_exp_binary_lt(Expression_ptr, Expression_ptr); | |
162 | extern Expression_ptr | |
163 | script_exp_binary_gt(Expression_ptr, Expression_ptr); | |
164 | extern Expression_ptr | |
165 | script_exp_binary_bitwise_and(Expression_ptr, Expression_ptr); | |
166 | extern Expression_ptr | |
167 | script_exp_binary_bitwise_xor(Expression_ptr, Expression_ptr); | |
168 | extern Expression_ptr | |
169 | script_exp_binary_bitwise_or(Expression_ptr, Expression_ptr); | |
170 | extern Expression_ptr | |
171 | script_exp_binary_logical_and(Expression_ptr, Expression_ptr); | |
172 | extern Expression_ptr | |
173 | script_exp_binary_logical_or(Expression_ptr, Expression_ptr); | |
174 | extern Expression_ptr | |
175 | script_exp_trinary_cond(Expression_ptr, Expression_ptr, Expression_ptr); | |
176 | extern Expression_ptr | |
177 | script_exp_integer(uint64_t); | |
178 | extern Expression_ptr | |
179 | script_exp_string(const char*, size_t); | |
180 | extern Expression_ptr | |
181 | script_exp_function_max(Expression_ptr, Expression_ptr); | |
182 | extern Expression_ptr | |
183 | script_exp_function_min(Expression_ptr, Expression_ptr); | |
184 | extern Expression_ptr | |
185 | script_exp_function_defined(const char*, size_t); | |
186 | extern Expression_ptr | |
187 | script_exp_function_sizeof_headers(); | |
188 | extern Expression_ptr | |
189 | script_exp_function_alignof(const char*, size_t); | |
190 | extern Expression_ptr | |
191 | script_exp_function_sizeof(const char*, size_t); | |
192 | extern Expression_ptr | |
193 | script_exp_function_addr(const char*, size_t); | |
194 | extern Expression_ptr | |
195 | script_exp_function_loadaddr(const char*, size_t); | |
196 | extern Expression_ptr | |
197 | script_exp_function_origin(const char*, size_t); | |
198 | extern Expression_ptr | |
199 | script_exp_function_length(const char*, size_t); | |
200 | extern Expression_ptr | |
201 | script_exp_function_constant(const char*, size_t); | |
202 | extern Expression_ptr | |
203 | script_exp_function_absolute(Expression_ptr); | |
204 | extern Expression_ptr | |
205 | script_exp_function_align(Expression_ptr, Expression_ptr); | |
206 | extern Expression_ptr | |
207 | script_exp_function_data_segment_align(Expression_ptr, Expression_ptr); | |
208 | extern Expression_ptr | |
209 | script_exp_function_data_segment_relro_end(Expression_ptr, Expression_ptr); | |
210 | extern Expression_ptr | |
211 | script_exp_function_data_segment_end(Expression_ptr); | |
212 | extern Expression_ptr | |
213 | script_exp_function_segment_start(const char*, size_t, Expression_ptr); | |
214 | extern Expression_ptr | |
215 | script_exp_function_assert(Expression_ptr, const char*, size_t); | |
195e7dc6 | 216 | |
09124467 ILT |
217 | struct Version_dependency_list; |
218 | struct Version_expression_list; | |
219 | struct Version_tree; | |
220 | ||
221 | extern void | |
222 | script_register_vers_node(void* closure, | |
223 | const char* tag, | |
224 | int taglen, | |
225 | struct Version_tree *, | |
226 | struct Version_dependency_list *); | |
227 | ||
228 | extern struct Version_dependency_list * | |
229 | script_add_vers_depend(void* closure, | |
230 | struct Version_dependency_list *existing_dependencies, | |
231 | const char *depend_to_add, int deplen); | |
232 | ||
233 | extern struct Version_expression_list * | |
234 | script_new_vers_pattern(void* closure, | |
235 | struct Version_expression_list *, | |
236 | const char *, int); | |
237 | ||
238 | extern struct Version_tree * | |
239 | script_new_vers_node(void* closure, | |
240 | struct Version_expression_list *global, | |
241 | struct Version_expression_list *local); | |
242 | ||
243 | extern void | |
244 | version_script_push_lang(void* closure, const char* lang, int langlen); | |
245 | ||
246 | extern void | |
247 | version_script_pop_lang(void* closure); | |
248 | ||
dbe717ef ILT |
249 | #ifdef __cplusplus |
250 | } | |
251 | #endif | |
252 | ||
253 | #endif /* !defined(GOLD_SCRIPT_C_H) */ |