1 /* script-c.h -- C interface for linker scripts in gold. */
3 /* Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor <iant@google.com>.
6 This file is part of gold.
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.
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.
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. */
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. */
26 #ifndef GOLD_SCRIPT_C_H
27 #define GOLD_SCRIPT_C_H
33 /* A string value for the bison parser. */
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
51 typedef gold::Expression* Expression_ptr;
53 typedef void* Expression_ptr;
56 /* The bison parser definitions. */
60 /* The bison parser function. */
63 yyparse(void* closure);
65 /* Called by the bison parser skeleton to return the next token. */
68 yylex(YYSTYPE*, void* closure);
70 /* Called by the bison parser skeleton to report an error. */
73 yyerror(void* closure, const char*);
75 /* Called by the bison parser to add a file to the link. */
78 script_add_file(void* closure, const char*, size_t);
80 /* Called by the bison parser to start and stop a group. */
83 script_start_group(void* closure);
85 script_end_group(void* closure);
87 /* Called by the bison parser to start and end an AS_NEEDED list. */
90 script_start_as_needed(void* closure);
92 script_end_as_needed(void* closure);
94 /* Called by the bison parser to set the entry symbol. */
97 script_set_entry(void* closure, const char*, size_t);
99 /* Called by the bison parser to parse an OPTION. */
102 script_parse_option(void* closure, const char*, size_t);
104 /* Called by the bison parser to push the lexer into expression
108 script_push_lex_into_expression_mode(void* closure);
110 /* Called by the bison parser to pop the lexer mode. */
113 script_pop_lex_mode(void* closure);
115 /* Called by the bison parser to set a symbol to a value. PROVIDE is
116 non-zero if the symbol should be provided--only defined if there is
117 an undefined reference. HIDDEN is non-zero if the symbol should be
121 script_set_symbol(void* closure, const char*, size_t, Expression_ptr,
122 int provide, int hidden);
124 /* Called by the bison parser for expressions. */
126 extern Expression_ptr
127 script_exp_unary_minus(Expression_ptr);
128 extern Expression_ptr
129 script_exp_unary_logical_not(Expression_ptr);
130 extern Expression_ptr
131 script_exp_unary_bitwise_not(Expression_ptr);
132 extern Expression_ptr
133 script_exp_binary_mult(Expression_ptr, Expression_ptr);
134 extern Expression_ptr
135 script_exp_binary_div(Expression_ptr, Expression_ptr);
136 extern Expression_ptr
137 script_exp_binary_mod(Expression_ptr, Expression_ptr);
138 extern Expression_ptr
139 script_exp_binary_add(Expression_ptr, Expression_ptr);
140 extern Expression_ptr
141 script_exp_binary_sub(Expression_ptr, Expression_ptr);
142 extern Expression_ptr
143 script_exp_binary_lshift(Expression_ptr, Expression_ptr);
144 extern Expression_ptr
145 script_exp_binary_rshift(Expression_ptr, Expression_ptr);
146 extern Expression_ptr
147 script_exp_binary_eq(Expression_ptr, Expression_ptr);
148 extern Expression_ptr
149 script_exp_binary_ne(Expression_ptr, Expression_ptr);
150 extern Expression_ptr
151 script_exp_binary_le(Expression_ptr, Expression_ptr);
152 extern Expression_ptr
153 script_exp_binary_ge(Expression_ptr, Expression_ptr);
154 extern Expression_ptr
155 script_exp_binary_lt(Expression_ptr, Expression_ptr);
156 extern Expression_ptr
157 script_exp_binary_gt(Expression_ptr, Expression_ptr);
158 extern Expression_ptr
159 script_exp_binary_bitwise_and(Expression_ptr, Expression_ptr);
160 extern Expression_ptr
161 script_exp_binary_bitwise_xor(Expression_ptr, Expression_ptr);
162 extern Expression_ptr
163 script_exp_binary_bitwise_or(Expression_ptr, Expression_ptr);
164 extern Expression_ptr
165 script_exp_binary_logical_and(Expression_ptr, Expression_ptr);
166 extern Expression_ptr
167 script_exp_binary_logical_or(Expression_ptr, Expression_ptr);
168 extern Expression_ptr
169 script_exp_trinary_cond(Expression_ptr, Expression_ptr, Expression_ptr);
170 extern Expression_ptr
171 script_exp_integer(uint64_t);
172 extern Expression_ptr
173 script_exp_string(const char*, size_t);
174 extern Expression_ptr
175 script_exp_function_max(Expression_ptr, Expression_ptr);
176 extern Expression_ptr
177 script_exp_function_min(Expression_ptr, Expression_ptr);
178 extern Expression_ptr
179 script_exp_function_defined(const char*, size_t);
180 extern Expression_ptr
181 script_exp_function_sizeof_headers();
182 extern Expression_ptr
183 script_exp_function_alignof(const char*, size_t);
184 extern Expression_ptr
185 script_exp_function_sizeof(const char*, size_t);
186 extern Expression_ptr
187 script_exp_function_addr(const char*, size_t);
188 extern Expression_ptr
189 script_exp_function_loadaddr(const char*, size_t);
190 extern Expression_ptr
191 script_exp_function_origin(const char*, size_t);
192 extern Expression_ptr
193 script_exp_function_length(const char*, size_t);
194 extern Expression_ptr
195 script_exp_function_constant(const char*, size_t);
196 extern Expression_ptr
197 script_exp_function_absolute(Expression_ptr);
198 extern Expression_ptr
199 script_exp_function_align(Expression_ptr, Expression_ptr);
200 extern Expression_ptr
201 script_exp_function_data_segment_align(Expression_ptr, Expression_ptr);
202 extern Expression_ptr
203 script_exp_function_data_segment_relro_end(Expression_ptr, Expression_ptr);
204 extern Expression_ptr
205 script_exp_function_data_segment_end(Expression_ptr);
206 extern Expression_ptr
207 script_exp_function_segment_start(const char*, size_t, Expression_ptr);
208 extern Expression_ptr
209 script_exp_function_assert(Expression_ptr, const char*, size_t);
215 #endif /* !defined(GOLD_SCRIPT_C_H) */