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