Commit | Line | Data |
---|---|---|
c611e285 | 1 | /* A YACC grammer to parse a superset of the AT&T linker scripting languaue. |
4a6afc88 | 2 | Copyright (C) 1991, 1993 Free Software Foundation, Inc. |
c611e285 | 3 | Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com). |
2fa0b342 | 4 | |
c611e285 | 5 | This file is part of GNU ld. |
2fa0b342 | 6 | |
c611e285 SC |
7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
2fa0b342 | 11 | |
c611e285 SC |
12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
2fa0b342 | 16 | |
c611e285 SC |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
20 | ||
21 | %{ | |
22 | /* | |
2e2bf962 | 23 | |
c611e285 | 24 | */ |
2fa0b342 | 25 | |
f177a611 | 26 | #define DONTDECLARE_MALLOC |
2fa0b342 | 27 | |
2fa0b342 | 28 | #include "bfd.h" |
f177a611 | 29 | #include "sysdep.h" |
4a6afc88 | 30 | #include "bfdlink.h" |
2fa0b342 DHW |
31 | #include "ld.h" |
32 | #include "ldexp.h" | |
7cb9aa50 | 33 | #include "ldver.h" |
2fa0b342 | 34 | #include "ldlang.h" |
f177a611 | 35 | #include "ldemul.h" |
2fa0b342 DHW |
36 | #include "ldfile.h" |
37 | #include "ldmisc.h" | |
fcf276c4 | 38 | #include "ldmain.h" |
3d2b83ea | 39 | #include "mri.h" |
6232b6c4 | 40 | #include "ldlex.h" |
f177a611 | 41 | |
2fa0b342 DHW |
42 | #define YYDEBUG 1 |
43 | ||
dadd414a | 44 | static int typebits; |
2fa0b342 | 45 | |
2fa0b342 DHW |
46 | lang_memory_region_type *region; |
47 | ||
48 | ||
2fa0b342 DHW |
49 | char *current_file; |
50 | boolean ldgram_want_filename = true; | |
51 | boolean had_script = false; | |
52 | boolean force_make_executable = false; | |
1d45ccb3 | 53 | |
1418c83b | 54 | boolean ldgram_in_script = false; |
1d45ccb3 | 55 | boolean ldgram_had_equals = false; |
2fa0b342 DHW |
56 | |
57 | ||
3d2b83ea SC |
58 | #define ERROR_NAME_MAX 20 |
59 | static char *error_names[ERROR_NAME_MAX]; | |
60 | static int error_index; | |
61 | #define PUSH_ERROR(x) if (error_index < ERROR_NAME_MAX) error_names[error_index] = x; error_index++; | |
62 | #define POP_ERROR() error_index--; | |
2fa0b342 DHW |
63 | %} |
64 | %union { | |
65 | bfd_vma integer; | |
2fa0b342 DHW |
66 | char *name; |
67 | int token; | |
68 | union etree_union *etree; | |
2fa0b342 DHW |
69 | } |
70 | ||
9fce28ed | 71 | %type <etree> exp opt_exp_with_type mustbe_exp opt_at |
dadd414a | 72 | %type <integer> fill_opt |
2fa0b342 | 73 | %type <name> memspec_opt |
6812f0e8 | 74 | %token <integer> INT |
2fa0b342 DHW |
75 | %token <name> NAME |
76 | %type <integer> length | |
77 | ||
a37cc0c0 | 78 | %right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ |
2fa0b342 DHW |
79 | %right <token> '?' ':' |
80 | %left <token> OROR | |
81 | %left <token> ANDAND | |
82 | %left <token> '|' | |
83 | %left <token> '^' | |
84 | %left <token> '&' | |
85 | %left <token> EQ NE | |
86 | %left <token> '<' '>' LE GE | |
87 | %left <token> LSHIFT RSHIFT | |
6812f0e8 | 88 | |
2fa0b342 DHW |
89 | %left <token> '+' '-' |
90 | %left <token> '*' '/' '%' | |
6812f0e8 | 91 | |
2fa0b342 | 92 | %right UNARY |
2e38b71d | 93 | %token END |
2fa0b342 | 94 | %left <token> '(' |
c477527c | 95 | %token <token> ALIGN_K BLOCK QUAD LONG SHORT BYTE |
d4e5e3c3 | 96 | %token SECTIONS |
2fa0b342 | 97 | %token '{' '}' |
6812f0e8 SC |
98 | %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH |
99 | %token SIZEOF_HEADERS | |
dadd414a | 100 | %token INCLUDE |
d4e5e3c3 | 101 | %token MEMORY DEFSYMEND |
f177a611 | 102 | %token NOLOAD DSECT COPY INFO OVERLAY |
d4e5e3c3 DM |
103 | %token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY |
104 | %token <integer> SIZEOF NEXT ADDR | |
105 | %token STARTUP HLL SYSLIB FLOAT NOFLOAT | |
106 | %token ORIGIN FILL | |
107 | %token LENGTH CREATE_OBJECT_SYMBOLS INPUT OUTPUT CONSTRUCTORS | |
108 | %token ALIGNMOD AT | |
6812f0e8 | 109 | %type <token> assign_op |
2fa0b342 | 110 | %type <name> filename |
e14a43bf | 111 | %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD |
4a6afc88 | 112 | %token FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL |
d4e5e3c3 | 113 | %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM |
3d2b83ea | 114 | |
2fa0b342 DHW |
115 | %% |
116 | ||
d4e5e3c3 DM |
117 | file: |
118 | INPUT_SCRIPT script_file | |
119 | | INPUT_MRI_SCRIPT mri_script_file | |
120 | | INPUT_DEFSYM defsym_expr | |
2fa0b342 DHW |
121 | ; |
122 | ||
2fa0b342 | 123 | |
d4e5e3c3 | 124 | filename: NAME; |
2fa0b342 | 125 | |
e14a43bf | 126 | |
d4e5e3c3 DM |
127 | defsym_expr: |
128 | { ldlex_defsym(); } | |
129 | NAME '=' exp | |
8ddef552 | 130 | { |
d4e5e3c3 DM |
131 | ldlex_popstate(); |
132 | lang_add_assignment(exp_assop($3,$2,$4)); | |
8ddef552 | 133 | } |
2fa0b342 | 134 | |
3d2b83ea SC |
135 | /* SYNTAX WITHIN AN MRI SCRIPT FILE */ |
136 | mri_script_file: | |
137 | { ldlex_mri_script(); | |
138 | PUSH_ERROR("MRI style script"); | |
139 | } | |
140 | mri_script_lines | |
141 | { ldlex_popstate(); | |
142 | POP_ERROR(); | |
143 | } | |
144 | ; | |
2fa0b342 | 145 | |
3d2b83ea | 146 | mri_script_lines: |
2e38b71d SC |
147 | mri_script_lines mri_script_command NEWLINE |
148 | | | |
3d2b83ea | 149 | ; |
2fa0b342 | 150 | |
2e38b71d | 151 | mri_script_command: |
3d2b83ea SC |
152 | CHIP exp |
153 | | CHIP exp ',' exp | |
154 | | NAME { | |
2e38b71d | 155 | einfo("%P%F: unrecognised keyword in MRI style script '%s'\n",$1); |
3d2b83ea SC |
156 | } |
157 | | LIST { | |
158 | write_map = true; | |
159 | config.map_filename = "-"; | |
160 | } | |
2e38b71d SC |
161 | | ORDER ordernamelist |
162 | | ENDWORD | |
e14a43bf SC |
163 | | PUBLIC NAME '=' exp |
164 | { mri_public($2, $4); } | |
165 | | PUBLIC NAME ',' exp | |
166 | { mri_public($2, $4); } | |
167 | | PUBLIC NAME exp | |
168 | { mri_public($2, $3); } | |
2e38b71d SC |
169 | | FORMAT NAME |
170 | { mri_format($2); } | |
171 | | SECT NAME ',' exp | |
3d2b83ea SC |
172 | { mri_output_section($2, $4);} |
173 | | SECT NAME exp | |
174 | { mri_output_section($2, $3);} | |
175 | | SECT NAME '=' exp | |
176 | { mri_output_section($2, $4);} | |
dadd414a SC |
177 | | ALIGN_K NAME '=' exp |
178 | { mri_align($2,$4); } | |
179 | | ALIGNMOD NAME '=' exp | |
180 | { mri_alignmod($2,$4); } | |
3d2b83ea SC |
181 | | ABSOLUTE mri_abs_name_list |
182 | | LOAD mri_load_name_list | |
2e38b71d SC |
183 | | NAMEWORD NAME |
184 | { mri_name($2); } | |
e14a43bf SC |
185 | | ALIAS NAME ',' NAME |
186 | { mri_alias($2,$4,0);} | |
187 | | ALIAS NAME ',' INT | |
4a6afc88 | 188 | { mri_alias($2,0,(int) $4);} |
e14a43bf SC |
189 | | BASE exp |
190 | { mri_base($2); } | |
dadd414a | 191 | | TRUNCATE INT |
4a6afc88 | 192 | { mri_truncate((unsigned int) $2); } |
2e38b71d SC |
193 | | |
194 | ; | |
195 | ||
196 | ordernamelist: | |
197 | ordernamelist ',' NAME { mri_order($3); } | |
198 | | ordernamelist NAME { mri_order($2); } | |
199 | | | |
3d2b83ea | 200 | ; |
2fa0b342 | 201 | |
3d2b83ea SC |
202 | mri_load_name_list: |
203 | NAME | |
204 | { mri_load($1); } | |
205 | | mri_load_name_list ',' NAME { mri_load($3); } | |
206 | ; | |
1418c83b | 207 | |
3d2b83ea SC |
208 | mri_abs_name_list: |
209 | NAME | |
210 | { mri_only_load($1); } | |
211 | | mri_abs_name_list ',' NAME | |
212 | { mri_only_load($3); } | |
213 | ; | |
1418c83b | 214 | |
3d2b83ea | 215 | script_file: |
9d1fe8a4 SC |
216 | { |
217 | ldlex_both(); | |
218 | } | |
3d2b83ea | 219 | ifile_list |
9d1fe8a4 SC |
220 | { |
221 | ldlex_popstate(); | |
222 | } | |
1418c83b SC |
223 | ; |
224 | ||
225 | ||
226 | ifile_list: | |
3d2b83ea | 227 | ifile_list ifile_p1 |
13a0e8d7 | 228 | | |
2fa0b342 DHW |
229 | ; |
230 | ||
231 | ||
232 | ||
233 | ifile_p1: | |
234 | memory | |
235 | | sections | |
236 | | startup | |
237 | | high_level_library | |
238 | | low_level_library | |
239 | | floating_point_support | |
ac004870 | 240 | | statement_anywhere |
9d1fe8a4 | 241 | | ';' |
2fa0b342 DHW |
242 | | TARGET_K '(' NAME ')' |
243 | { lang_add_target($3); } | |
244 | | SEARCH_DIR '(' filename ')' | |
245 | { ldfile_add_library_path($3); } | |
246 | | OUTPUT '(' filename ')' | |
f651733a ILT |
247 | { lang_add_output($3, 1); } |
248 | | OUTPUT_FORMAT '(' NAME ')' | |
de87cdb4 | 249 | { lang_add_output_format($3, 1); } |
f651733a | 250 | | OUTPUT_ARCH '(' NAME ')' |
a37cc0c0 | 251 | { ldfile_set_output_arch($3); } |
13a0e8d7 SC |
252 | | FORCE_COMMON_ALLOCATION |
253 | { command_line.force_common_definition = true ; } | |
2fa0b342 DHW |
254 | | INPUT '(' input_list ')' |
255 | | MAP '(' filename ')' | |
256 | { lang_add_map($3); } | |
dadd414a SC |
257 | | INCLUDE filename |
258 | { ldfile_open_command_file($2); } ifile_list END | |
2fa0b342 DHW |
259 | ; |
260 | ||
261 | input_list: | |
262 | NAME | |
f651733a | 263 | { lang_add_input_file($1,lang_input_file_is_search_file_enum, |
2fa0b342 DHW |
264 | (char *)NULL); } |
265 | | input_list ',' NAME | |
f651733a | 266 | { lang_add_input_file($3,lang_input_file_is_search_file_enum, |
2fa0b342 | 267 | (char *)NULL); } |
3d2b83ea | 268 | | input_list NAME |
f651733a | 269 | { lang_add_input_file($2,lang_input_file_is_search_file_enum, |
2fa0b342 DHW |
270 | (char *)NULL); } |
271 | ; | |
272 | ||
273 | sections: | |
3d2b83ea | 274 | SECTIONS '{' sec_or_group_p1 '}' |
2fa0b342 DHW |
275 | ; |
276 | ||
277 | sec_or_group_p1: | |
278 | sec_or_group_p1 section | |
279 | | sec_or_group_p1 statement_anywhere | |
280 | | | |
281 | ; | |
282 | ||
283 | statement_anywhere: | |
284 | ENTRY '(' NAME ')' | |
285 | { lang_add_entry($3); } | |
286 | | assignment end | |
287 | ; | |
288 | ||
1418c83b SC |
289 | file_NAME_list: |
290 | NAME | |
291 | { lang_add_wild($1, current_file); } | |
3d2b83ea | 292 | | file_NAME_list opt_comma NAME |
1418c83b SC |
293 | { lang_add_wild($3, current_file); } |
294 | ; | |
295 | ||
296 | input_section_spec: | |
297 | NAME | |
298 | { | |
299 | lang_add_wild((char *)NULL, $1); | |
300 | } | |
3d2b83ea | 301 | | '[' |
1418c83b SC |
302 | { |
303 | current_file = (char *)NULL; | |
304 | } | |
3d2b83ea SC |
305 | file_NAME_list |
306 | ']' | |
1418c83b SC |
307 | | NAME |
308 | { | |
3d2b83ea SC |
309 | current_file =$1; |
310 | } | |
1418c83b | 311 | '(' file_NAME_list ')' |
3d2b83ea SC |
312 | | '*' |
313 | { | |
1418c83b | 314 | current_file = (char *)NULL; |
3d2b83ea | 315 | } |
1418c83b SC |
316 | '(' file_NAME_list ')' |
317 | ; | |
318 | ||
2fa0b342 | 319 | statement: |
9fce28ed SC |
320 | assignment end |
321 | | CREATE_OBJECT_SYMBOLS | |
13a0e8d7 | 322 | { |
9fce28ed SC |
323 | lang_add_attribute(lang_object_symbols_statement_enum); |
324 | } | |
325 | | ';' | |
326 | | CONSTRUCTORS | |
f177a611 | 327 | { |
3d2b83ea | 328 | |
9fce28ed SC |
329 | lang_add_attribute(lang_constructors_statement_enum); |
330 | } | |
331 | | input_section_spec | |
332 | | length '(' exp ')' | |
2fa0b342 | 333 | { |
4a6afc88 | 334 | lang_add_data((int) $1,$3); |
2fa0b342 DHW |
335 | } |
336 | ||
9fce28ed | 337 | | FILL '(' exp ')' |
2fa0b342 DHW |
338 | { |
339 | lang_add_fill | |
9fce28ed | 340 | (exp_get_value_int($3, |
2fa0b342 DHW |
341 | 0, |
342 | "fill value", | |
9fce28ed | 343 | lang_first_phase_enum)); |
2fa0b342 | 344 | } |
2fa0b342 DHW |
345 | ; |
346 | ||
9fce28ed SC |
347 | statement_list: |
348 | statement_list statement | |
349 | | statement | |
350 | ; | |
351 | ||
8ddef552 DM |
352 | statement_list_opt: |
353 | /* empty */ | |
354 | | statement_list | |
355 | ; | |
356 | ||
2fa0b342 | 357 | length: |
c477527c ILT |
358 | QUAD |
359 | { $$ = $1; } | |
360 | | LONG | |
2fa0b342 | 361 | { $$ = $1; } |
3d2b83ea | 362 | | SHORT |
2fa0b342 | 363 | { $$ = $1; } |
3d2b83ea | 364 | | BYTE |
2fa0b342 DHW |
365 | { $$ = $1; } |
366 | ; | |
367 | ||
368 | fill_opt: | |
9d1fe8a4 | 369 | '=' mustbe_exp |
2fa0b342 DHW |
370 | { |
371 | $$ = exp_get_value_int($2, | |
372 | 0, | |
373 | "fill value", | |
3d2b83ea | 374 | lang_first_phase_enum); |
2fa0b342 | 375 | } |
3d2b83ea | 376 | | { $$ = 0; } |
2fa0b342 DHW |
377 | ; |
378 | ||
379 | ||
380 | ||
381 | assign_op: | |
382 | PLUSEQ | |
383 | { $$ = '+'; } | |
3d2b83ea | 384 | | MINUSEQ |
2fa0b342 DHW |
385 | { $$ = '-'; } |
386 | | MULTEQ | |
387 | { $$ = '*'; } | |
388 | | DIVEQ | |
389 | { $$ = '/'; } | |
390 | | LSHIFTEQ | |
391 | { $$ = LSHIFT; } | |
392 | | RSHIFTEQ | |
393 | { $$ = RSHIFT; } | |
394 | | ANDEQ | |
395 | { $$ = '&'; } | |
396 | | OREQ | |
397 | { $$ = '|'; } | |
398 | ||
399 | ; | |
400 | ||
9d1fe8a4 | 401 | end: ';' | ',' |
2fa0b342 DHW |
402 | ; |
403 | ||
2fa0b342 DHW |
404 | |
405 | assignment: | |
3d2b83ea | 406 | NAME '=' mustbe_exp |
2fa0b342 DHW |
407 | { |
408 | lang_add_assignment(exp_assop($2,$1,$3)); | |
409 | } | |
3d2b83ea | 410 | | NAME assign_op mustbe_exp |
2fa0b342 | 411 | { |
3d2b83ea SC |
412 | |
413 | lang_add_assignment(exp_assop('=',$1,exp_binop($2,exp_nameop(NAME,$1),$3))); | |
2fa0b342 DHW |
414 | } |
415 | ||
416 | ; | |
417 | ||
418 | ||
419 | opt_comma: | |
420 | ',' | ; | |
421 | ||
422 | ||
423 | memory: | |
3d2b83ea | 424 | MEMORY '{' memory_spec memory_spec_list '}' |
2fa0b342 DHW |
425 | ; |
426 | ||
427 | memory_spec_list: | |
3d2b83ea | 428 | memory_spec_list memory_spec |
2fa0b342 DHW |
429 | | memory_spec_list ',' memory_spec |
430 | | | |
431 | ; | |
432 | ||
433 | ||
3d2b83ea | 434 | memory_spec: NAME |
2fa0b342 | 435 | { region = lang_memory_region_lookup($1); } |
3d2b83ea | 436 | attributes_opt ':' |
9d1fe8a4 | 437 | origin_spec opt_comma length_spec |
2fa0b342 | 438 | |
3d2b83ea | 439 | ; origin_spec: |
9d1fe8a4 | 440 | ORIGIN '=' mustbe_exp |
2fa0b342 DHW |
441 | { region->current = |
442 | region->origin = | |
3d2b83ea SC |
443 | exp_get_vma($3, 0L,"origin", lang_first_phase_enum); |
444 | } | |
445 | ; length_spec: | |
446 | LENGTH '=' mustbe_exp | |
447 | { region->length = exp_get_vma($3, | |
2fa0b342 DHW |
448 | ~((bfd_vma)0), |
449 | "length", | |
450 | lang_first_phase_enum); | |
451 | } | |
452 | ||
453 | ||
454 | attributes_opt: | |
455 | '(' NAME ')' | |
456 | { | |
457 | lang_set_flags(®ion->flags, $2); | |
458 | } | |
459 | | | |
460 | ||
461 | ; | |
462 | ||
463 | startup: | |
464 | STARTUP '(' filename ')' | |
465 | { lang_startup($3); } | |
466 | ; | |
467 | ||
468 | high_level_library: | |
3d2b83ea SC |
469 | HLL '(' high_level_library_NAME_list ')' |
470 | | HLL '(' ')' | |
2fa0b342 DHW |
471 | { ldemul_hll((char *)NULL); } |
472 | ; | |
473 | ||
474 | high_level_library_NAME_list: | |
3d2b83ea | 475 | high_level_library_NAME_list opt_comma filename |
2fa0b342 DHW |
476 | { ldemul_hll($3); } |
477 | | filename | |
478 | { ldemul_hll($1); } | |
479 | ||
480 | ; | |
481 | ||
482 | low_level_library: | |
483 | SYSLIB '(' low_level_library_NAME_list ')' | |
3d2b83ea | 484 | ; low_level_library_NAME_list: |
2fa0b342 | 485 | low_level_library_NAME_list opt_comma filename |
3d2b83ea | 486 | { ldemul_syslib($3); } |
2fa0b342 DHW |
487 | | |
488 | ; | |
489 | ||
490 | floating_point_support: | |
491 | FLOAT | |
492 | { lang_float(true); } | |
493 | | NOFLOAT | |
3d2b83ea | 494 | { lang_float(false); } |
2fa0b342 DHW |
495 | ; |
496 | ||
497 | ||
3d2b83ea | 498 | mustbe_exp: { ldlex_expression(); } |
9d1fe8a4 SC |
499 | exp |
500 | { ldlex_popstate(); $$=$2;} | |
501 | ; | |
2fa0b342 DHW |
502 | |
503 | exp : | |
3d2b83ea | 504 | '-' exp %prec UNARY |
2fa0b342 | 505 | { $$ = exp_unop('-', $2); } |
9d1fe8a4 | 506 | | '(' exp ')' |
2fa0b342 DHW |
507 | { $$ = $2; } |
508 | | NEXT '(' exp ')' %prec UNARY | |
4a6afc88 | 509 | { $$ = exp_unop((int) $1,$3); } |
3d2b83ea | 510 | | '!' exp %prec UNARY |
2fa0b342 | 511 | { $$ = exp_unop('!', $2); } |
3d2b83ea | 512 | | '+' exp %prec UNARY |
2fa0b342 | 513 | { $$ = $2; } |
3d2b83ea | 514 | | '~' exp %prec UNARY |
2fa0b342 DHW |
515 | { $$ = exp_unop('~', $2);} |
516 | ||
517 | | exp '*' exp | |
518 | { $$ = exp_binop('*', $1, $3); } | |
519 | | exp '/' exp | |
520 | { $$ = exp_binop('/', $1, $3); } | |
521 | | exp '%' exp | |
522 | { $$ = exp_binop('%', $1, $3); } | |
523 | | exp '+' exp | |
524 | { $$ = exp_binop('+', $1, $3); } | |
525 | | exp '-' exp | |
3d2b83ea | 526 | { $$ = exp_binop('-' , $1, $3); } |
2fa0b342 DHW |
527 | | exp LSHIFT exp |
528 | { $$ = exp_binop(LSHIFT , $1, $3); } | |
529 | | exp RSHIFT exp | |
530 | { $$ = exp_binop(RSHIFT , $1, $3); } | |
531 | | exp EQ exp | |
532 | { $$ = exp_binop(EQ , $1, $3); } | |
533 | | exp NE exp | |
534 | { $$ = exp_binop(NE , $1, $3); } | |
535 | | exp LE exp | |
536 | { $$ = exp_binop(LE , $1, $3); } | |
3d2b83ea | 537 | | exp GE exp |
2fa0b342 DHW |
538 | { $$ = exp_binop(GE , $1, $3); } |
539 | | exp '<' exp | |
540 | { $$ = exp_binop('<' , $1, $3); } | |
541 | | exp '>' exp | |
542 | { $$ = exp_binop('>' , $1, $3); } | |
543 | | exp '&' exp | |
544 | { $$ = exp_binop('&' , $1, $3); } | |
545 | | exp '^' exp | |
546 | { $$ = exp_binop('^' , $1, $3); } | |
547 | | exp '|' exp | |
548 | { $$ = exp_binop('|' , $1, $3); } | |
549 | | exp '?' exp ':' exp | |
550 | { $$ = exp_trinop('?' , $1, $3, $5); } | |
551 | | exp ANDAND exp | |
552 | { $$ = exp_binop(ANDAND , $1, $3); } | |
553 | | exp OROR exp | |
554 | { $$ = exp_binop(OROR , $1, $3); } | |
555 | | DEFINED '(' NAME ')' | |
556 | { $$ = exp_nameop(DEFINED, $3); } | |
557 | | INT | |
558 | { $$ = exp_intop($1); } | |
3d2b83ea | 559 | | SIZEOF_HEADERS |
65c552e3 | 560 | { $$ = exp_nameop(SIZEOF_HEADERS,0); } |
2fa0b342 | 561 | |
3d2b83ea | 562 | | SIZEOF '(' NAME ')' |
f177a611 | 563 | { $$ = exp_nameop(SIZEOF,$3); } |
2fa0b342 | 564 | | ADDR '(' NAME ')' |
f177a611 | 565 | { $$ = exp_nameop(ADDR,$3); } |
ae475b39 SC |
566 | | ABSOLUTE '(' exp ')' |
567 | { $$ = exp_unop(ABSOLUTE, $3); } | |
2fa0b342 | 568 | | ALIGN_K '(' exp ')' |
f177a611 | 569 | { $$ = exp_unop(ALIGN_K,$3); } |
2fa0b342 DHW |
570 | | NAME |
571 | { $$ = exp_nameop(NAME,$1); } | |
572 | ; | |
573 | ||
574 | ||
9fce28ed SC |
575 | opt_at: |
576 | AT '(' exp ')' { $$ = $3; } | |
577 | | { $$ = 0; } | |
578 | ; | |
2fa0b342 | 579 | |
3d2b83ea | 580 | section: NAME { ldlex_expression(); } |
9fce28ed SC |
581 | opt_exp_with_type |
582 | opt_at { ldlex_popstate(); } | |
dadd414a | 583 | '{' |
9fce28ed SC |
584 | { |
585 | lang_enter_output_section_statement($1,$3,typebits,0,0,0,$4); | |
586 | } | |
8ddef552 | 587 | statement_list_opt |
27baca71 | 588 | '}' {ldlex_expression();} memspec_opt fill_opt |
2fa0b342 | 589 | { |
e14a43bf | 590 | ldlex_popstate(); |
27baca71 | 591 | lang_leave_output_section_statement($12, $11); |
2fa0b342 | 592 | } |
e14a43bf | 593 | opt_comma |
2fa0b342 DHW |
594 | |
595 | ; | |
596 | ||
dadd414a SC |
597 | type: |
598 | NOLOAD { typebits = SEC_NEVER_LOAD; } | |
599 | | DSECT { typebits = 0; } | |
600 | | COPY { typebits = 0; } | |
601 | | INFO { typebits = 0; } | |
602 | | OVERLAY { typebits = 0; } | |
603 | | { typebits = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; } | |
f177a611 JG |
604 | ; |
605 | ||
6812f0e8 | 606 | |
dadd414a | 607 | opt_exp_with_type: |
9fce28ed SC |
608 | exp ':' { $$ = $1; typebits =0;} |
609 | | exp '(' type ')' ':' { $$ = $1; } | |
610 | | ':' { $$= (etree_type *)NULL; typebits = 0; } | |
611 | | '(' type ')' ':' { $$= (etree_type *)NULL; } | |
2fa0b342 DHW |
612 | ; |
613 | ||
2fa0b342 | 614 | memspec_opt: |
9d1fe8a4 | 615 | '>' NAME |
2fa0b342 DHW |
616 | { $$ = $2; } |
617 | | { $$ = "*default*"; } | |
618 | ; | |
3d2b83ea SC |
619 | %% |
620 | void | |
621 | yyerror(arg) | |
c477527c | 622 | const char *arg; |
3d2b83ea | 623 | { |
c477527c ILT |
624 | if (error_index > 0 && error_index < ERROR_NAME_MAX) |
625 | einfo("%P%F: %S %s in %s\n", arg, error_names[error_index-1]); | |
3d2b83ea | 626 | else |
c477527c | 627 | einfo("%P%F: %S %s\n", arg); |
3d2b83ea | 628 | } |