This is a test to see if the file is still locked.
[deliverable/binutils-gdb.git] / ld / ldgram.y
CommitLineData
c611e285
SC
1/* A YACC grammer to parse a superset of the AT&T linker scripting languaue.
2 Copyright (C) 1991 Free Software Foundation, Inc.
3 Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
2fa0b342 4
c611e285 5This file is part of GNU ld.
2fa0b342 6
c611e285
SC
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
2fa0b342 11
c611e285
SC
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
2fa0b342 16
c611e285
SC
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, 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"
2fa0b342
DHW
30#include "ld.h"
31#include "ldexp.h"
7cb9aa50 32#include "ldver.h"
2fa0b342 33#include "ldlang.h"
f177a611 34#include "ldemul.h"
2fa0b342
DHW
35#include "ldfile.h"
36#include "ldmisc.h"
3d2b83ea 37#include "mri.h"
f177a611 38
2fa0b342
DHW
39#define YYDEBUG 1
40
41boolean option_v;
2fa0b342
DHW
42extern unsigned int lineno;
43extern boolean trace_files;
44extern boolean write_map;
c611e285 45extern boolean option_longmap;
2fa0b342
DHW
46boolean hex_mode;
47
d646b568
SC
48strip_symbols_type strip_symbols=STRIP_NONE;
49discard_locals_type discard_locals=DISCARD_NONE;
2fa0b342
DHW
50
51
52lang_memory_region_type *region;
53
54
55lang_memory_region_type *lang_memory_region_lookup();
56lang_output_section_statement_type *lang_output_section_statement_lookup();
57
58#ifdef __STDC__
59
60void lang_add_data(int type, union etree_union *exp);
f177a611 61void lang_enter_output_section_statement(char *output_section_statement_name, etree_type *address_exp, int flags, bfd_vma block_value);
2fa0b342
DHW
62
63#else
64
65void lang_add_data();
66void lang_enter_output_section_statement();
67
68#endif /* __STDC__ */
69
70extern args_type command_line;
71char *current_file;
72boolean ldgram_want_filename = true;
73boolean had_script = false;
74boolean force_make_executable = false;
1d45ccb3 75
1418c83b 76boolean ldgram_in_script = false;
1d45ccb3 77boolean ldgram_had_equals = false;
2fa0b342
DHW
78/* LOCALS */
79
80
3d2b83ea
SC
81#define ERROR_NAME_MAX 20
82static char *error_names[ERROR_NAME_MAX];
83static int error_index;
84#define PUSH_ERROR(x) if (error_index < ERROR_NAME_MAX) error_names[error_index] = x; error_index++;
85#define POP_ERROR() error_index--;
2fa0b342
DHW
86%}
87%union {
88 bfd_vma integer;
89 int voidval;
90 char *name;
91 int token;
92 union etree_union *etree;
76971f0d 93struct sec *section;
2fa0b342
DHW
94 struct lang_output_section_statement_struct *output_section_statement;
95 union lang_statement_union **statement_ptr;
96 int lineno;
97 struct {
98 FILE *file;
99 char *name;
100 unsigned int lineno;
101 } state;
102
103
104}
105
9d1fe8a4 106%type <etree> exp opt_exp mustbe_exp
f177a611 107%type <integer> fill_opt opt_block opt_type
2fa0b342 108%type <name> memspec_opt
6812f0e8 109%token <integer> INT
2fa0b342
DHW
110%token <name> NAME
111%type <integer> length
112
a37cc0c0 113%right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
2fa0b342
DHW
114%right <token> '?' ':'
115%left <token> OROR
116%left <token> ANDAND
117%left <token> '|'
118%left <token> '^'
119%left <token> '&'
120%left <token> EQ NE
121%left <token> '<' '>' LE GE
122%left <token> LSHIFT RSHIFT
6812f0e8 123
2fa0b342
DHW
124%left <token> '+' '-'
125%left <token> '*' '/' '%'
6812f0e8
SC
126
127/*%token <token> '+' '-' '*' '/' '%'*/
2fa0b342 128%right UNARY
2e38b71d 129%token END
2fa0b342
DHW
130%left <token> '('
131%token <token> ALIGN_K BLOCK LONG SHORT BYTE
132%token SECTIONS
133%token '{' '}'
6812f0e8
SC
134%token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
135%token SIZEOF_HEADERS
e14a43bf 136%token MEMORY DEFSYMEND
f177a611 137%token NOLOAD DSECT COPY INFO OVERLAY
2fa0b342 138%token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY
b6316534 139%token OPTION_e OPTION_c OPTION_noinhibit_exec OPTION_s OPTION_S OPTION_sort_common
f177a611 140%token OPTION_format OPTION_F OPTION_u OPTION_Bstatic OPTION_N
6812f0e8 141%token <integer> SIZEOF NEXT ADDR
a37cc0c0 142%token OPTION_d OPTION_dc OPTION_dp OPTION_x OPTION_X OPTION_defsym
2e2bf962
SC
143%token OPTION_v OPTION_V OPTION_M OPTION_t STARTUP HLL SYSLIB FLOAT NOFLOAT
144%token OPTION_Map
c611e285 145%token OPTION_n OPTION_r OPTION_o OPTION_b OPTION_R OPTION_relax
2fa0b342
DHW
146%token <name> OPTION_l OPTION_L OPTION_T OPTION_Aarch OPTION_Tfile OPTION_Texp
147%token OPTION_Ur
148%token ORIGIN FILL OPTION_g
76971f0d 149%token LENGTH CREATE_OBJECT_SYMBOLS INPUT OUTPUT CONSTRUCTORS
6812f0e8
SC
150%type <token> assign_op
151
2fa0b342
DHW
152%type <name> filename
153
3d2b83ea 154
e14a43bf
SC
155%token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD
156%token FORMAT PUBLIC DEFSYMEND BASE ALIAS
3d2b83ea 157
2fa0b342
DHW
158%{
159ld_config_type config;
160%}
161
162%%
163
2fa0b342
DHW
164file: command_line { lang_final(); };
165
9d1fe8a4
SC
166
167filename: NAME;
2fa0b342 168
76971f0d 169
2fa0b342
DHW
170command_line:
171 command_line command_line_option
172 |
173 ;
174
175command_line_option:
9d1fe8a4 176 OPTION_Bstatic { }
1418c83b 177 | OPTION_v
2fa0b342 178 {
76971f0d 179 ldversion(0);
2fa0b342
DHW
180 option_v = true;
181 }
c611e285
SC
182 | OPTION_V
183 {
76971f0d 184 ldversion(1);
c611e285
SC
185 option_v = true;
186 }
2fa0b342
DHW
187 | OPTION_t {
188 trace_files = true;
189 }
2e2bf962
SC
190 | OPTION_Map NAME
191 {
192 write_map = true;
193 config.map_filename = $2;
194 }
2fa0b342 195 | OPTION_M {
870f54b2 196 config.map_filename = "-";
3d2b83ea 197
2fa0b342
DHW
198 }
199 | OPTION_n {
200 config.magic_demand_paged = false;
2fa0b342 201 }
f177a611 202 | OPTION_N {
c611e285 203 config.text_read_only = false;
f177a611
JG
204 config.magic_demand_paged = false;
205 }
2fa0b342
DHW
206 | OPTION_s {
207 strip_symbols = STRIP_ALL;
208 }
209 | OPTION_S {
210 strip_symbols = STRIP_DEBUGGER;
211 }
1418c83b
SC
212 | OPTION_u NAME {
213 ldlang_add_undef($2);
214 }
215
2fa0b342
DHW
216 | OPTION_r {
217 config.relocateable_output = true;
218 config.build_constructors = false;
219 config.magic_demand_paged = false;
c611e285 220 config.text_read_only = false;
2fa0b342
DHW
221 }
222 | OPTION_Ur {
223 config.relocateable_output = true;
224 config.build_constructors = true;
225 config.magic_demand_paged = false;
c611e285 226 config.text_read_only = false;
2fa0b342
DHW
227 }
228 | OPTION_o filename
229 {
230 lang_add_output($2);
231 }
232 | OPTION_e NAME
233 { lang_add_entry($2);
234 }
235 | OPTION_X {
236 discard_locals = DISCARD_L;
237 }
238 | OPTION_x {
239 discard_locals = DISCARD_ALL;
240 }
241
242 | OPTION_noinhibit_exec
243 {
244 force_make_executable = true;
245 }
b6316534
SC
246 | OPTION_sort_common {
247 config.sort_common = true;
248 }
1418c83b 249 | OPTION_d {
2fa0b342
DHW
250 command_line.force_common_definition = true;
251 }
c611e285
SC
252
253 | OPTION_relax {
254 command_line.relax = true;
255 }
1418c83b 256 | OPTION_dc
2fa0b342
DHW
257 {
258 command_line.force_common_definition = true;
259 }
260 | OPTION_g
261 {
262 /* Ignored */
263 }
1418c83b 264 | OPTION_dp
2fa0b342
DHW
265 {
266 command_line.force_common_definition = true;
267 }
1418c83b 268 | OPTION_format NAME
7ca04d28
SC
269 {
270 lang_add_target($2);
271 }
de7c1ff6 272 | OPTION_Texp
e14a43bf 273 { ldlex_expression();
9d1fe8a4 274 hex_mode = 16;
1418c83b
SC
275 }
276 INT
e14a43bf 277 { ldlex_popstate();
1418c83b 278 lang_section_start($1,exp_intop($3));
9d1fe8a4 279 hex_mode = 0;
1418c83b 280 }
2fa0b342 281
7ca04d28 282 | OPTION_Aarch
1418c83b
SC
283 {
284 ldfile_add_arch($1);
285 }
7ca04d28 286 | OPTION_b NAME
2fa0b342
DHW
287 {
288 lang_add_target($2);
289 }
290 | OPTION_L
291 {
292 ldfile_add_library_path($1);
1418c83b 293 }
7ca04d28
SC
294 | OPTION_F
295 {
296 /* Ignore */
297 }
1418c83b
SC
298 | NAME
299 { lang_add_input_file($1,lang_input_file_is_file_enum,
300 (char *)NULL); }
f177a611 301 | OPTION_c filename
3d2b83ea 302 { ldfile_open_command_file($2); } mri_script_file END { ldlex_command()};
9d1fe8a4 303
1418c83b
SC
304 | OPTION_Tfile
305 { ldfile_open_command_file($1); } script_file
3d2b83ea 306 END { ldlex_command();}
2fa0b342 307
1418c83b
SC
308 | OPTION_T filename
309 { ldfile_open_command_file($2); } script_file
9d1fe8a4 310END { ldlex_command();}
2fa0b342
DHW
311
312 | OPTION_l
313 {
314 lang_add_input_file($1,
315 lang_input_file_is_l_enum,
316 (char *)NULL);
317 }
1418c83b 318 | OPTION_R filename
2fa0b342
DHW
319 {
320 lang_add_input_file($2,
321 lang_input_file_is_symbols_only_enum,
322 (char *)NULL);
323 }
e14a43bf
SC
324
325 | OPTION_defsym { ldlex_defsym(); }
326 NAME '=' exp DEFSYMEND { ldlex_popstate();
1d45ccb3 327 lang_add_assignment(exp_assop($4,$3,$5));
7ca04d28 328 }
1418c83b
SC
329 | '-' NAME
330 { info("%P%F Unrecognised option -%s\n", $2); }
7ca04d28 331
9d1fe8a4 332 | '{' script_file '}'
2fa0b342
DHW
333 ;
334
335
3d2b83ea
SC
336/* SYNTAX WITHIN AN MRI SCRIPT FILE */
337mri_script_file:
338 { ldlex_mri_script();
339 PUSH_ERROR("MRI style script");
340 }
341 mri_script_lines
342 { ldlex_popstate();
343 POP_ERROR();
344 }
345 ;
2fa0b342 346
3d2b83ea 347mri_script_lines:
2e38b71d
SC
348 mri_script_lines mri_script_command NEWLINE
349 |
3d2b83ea 350 ;
2fa0b342 351
2e38b71d 352mri_script_command:
3d2b83ea
SC
353 CHIP exp
354 | CHIP exp ',' exp
355 | NAME {
2e38b71d 356 einfo("%P%F: unrecognised keyword in MRI style script '%s'\n",$1);
3d2b83ea
SC
357 }
358 | LIST {
359 write_map = true;
360 config.map_filename = "-";
361 }
2e38b71d
SC
362 | ORDER ordernamelist
363 | ENDWORD
e14a43bf
SC
364 | PUBLIC NAME '=' exp
365 { mri_public($2, $4); }
366 | PUBLIC NAME ',' exp
367 { mri_public($2, $4); }
368 | PUBLIC NAME exp
369 { mri_public($2, $3); }
2e38b71d
SC
370 | FORMAT NAME
371 { mri_format($2); }
372 | SECT NAME ',' exp
3d2b83ea
SC
373 { mri_output_section($2, $4);}
374 | SECT NAME exp
375 { mri_output_section($2, $3);}
376 | SECT NAME '=' exp
377 { mri_output_section($2, $4);}
378 | ABSOLUTE mri_abs_name_list
379 | LOAD mri_load_name_list
2e38b71d
SC
380 | NAMEWORD NAME
381 { mri_name($2); }
e14a43bf
SC
382 | ALIAS NAME ',' NAME
383 { mri_alias($2,$4,0);}
384 | ALIAS NAME ',' INT
385 { mri_alias($2,0,$4);}
386 | BASE exp
387 { mri_base($2); }
2e38b71d
SC
388 |
389 ;
390
391ordernamelist:
392 ordernamelist ',' NAME { mri_order($3); }
393 | ordernamelist NAME { mri_order($2); }
394 |
3d2b83ea 395 ;
2fa0b342 396
3d2b83ea
SC
397mri_load_name_list:
398 NAME
399 { mri_load($1); }
400 | mri_load_name_list ',' NAME { mri_load($3); }
401 ;
1418c83b 402
3d2b83ea
SC
403mri_abs_name_list:
404 NAME
405 { mri_only_load($1); }
406 | mri_abs_name_list ',' NAME
407 { mri_only_load($3); }
408 ;
1418c83b 409
3d2b83ea 410script_file:
9d1fe8a4
SC
411 {
412 ldlex_both();
413 }
3d2b83ea 414 ifile_list
9d1fe8a4
SC
415 {
416 ldlex_popstate();
417 }
1418c83b
SC
418 ;
419
420
421ifile_list:
3d2b83ea 422 ifile_list ifile_p1
13a0e8d7 423 |
2fa0b342
DHW
424 ;
425
426
427
428ifile_p1:
429 memory
430 | sections
431 | startup
432 | high_level_library
433 | low_level_library
434 | floating_point_support
ac004870 435 | statement_anywhere
9d1fe8a4 436 | ';'
2fa0b342
DHW
437 | TARGET_K '(' NAME ')'
438 { lang_add_target($3); }
439 | SEARCH_DIR '(' filename ')'
440 { ldfile_add_library_path($3); }
441 | OUTPUT '(' filename ')'
442 { lang_add_output($3); }
3d2b83ea 443 | OUTPUT_FORMAT '(' NAME ')'
13a0e8d7 444 { lang_add_output_format($3); }
3d2b83ea 445 | OUTPUT_ARCH '(' NAME ')'
a37cc0c0 446 { ldfile_set_output_arch($3); }
13a0e8d7
SC
447 | FORCE_COMMON_ALLOCATION
448 { command_line.force_common_definition = true ; }
2fa0b342
DHW
449 | INPUT '(' input_list ')'
450 | MAP '(' filename ')'
451 { lang_add_map($3); }
452 ;
453
454input_list:
455 NAME
456 { lang_add_input_file($1,lang_input_file_is_file_enum,
457 (char *)NULL); }
458 | input_list ',' NAME
459 { lang_add_input_file($3,lang_input_file_is_file_enum,
460 (char *)NULL); }
3d2b83ea
SC
461 | input_list NAME
462 { lang_add_input_file($2,
463lang_input_file_is_file_enum,
2fa0b342
DHW
464 (char *)NULL); }
465 ;
466
467sections:
3d2b83ea 468 SECTIONS '{' sec_or_group_p1 '}'
2fa0b342
DHW
469 ;
470
471sec_or_group_p1:
472 sec_or_group_p1 section
473 | sec_or_group_p1 statement_anywhere
474 |
475 ;
476
477statement_anywhere:
478 ENTRY '(' NAME ')'
479 { lang_add_entry($3); }
480 | assignment end
481 ;
482
1418c83b
SC
483file_NAME_list:
484 NAME
485 { lang_add_wild($1, current_file); }
3d2b83ea 486 | file_NAME_list opt_comma NAME
1418c83b
SC
487 { lang_add_wild($3, current_file); }
488 ;
489
490input_section_spec:
491 NAME
492 {
493 lang_add_wild((char *)NULL, $1);
494 }
3d2b83ea 495 | '['
1418c83b
SC
496 {
497 current_file = (char *)NULL;
498 }
3d2b83ea
SC
499 file_NAME_list
500 ']'
1418c83b
SC
501 | NAME
502 {
3d2b83ea
SC
503 current_file =$1;
504 }
1418c83b 505 '(' file_NAME_list ')'
3d2b83ea
SC
506 | '*'
507 {
1418c83b 508 current_file = (char *)NULL;
3d2b83ea 509 }
1418c83b
SC
510 '(' file_NAME_list ')'
511 ;
512
2fa0b342
DHW
513statement:
514 statement assignment end
515 | statement CREATE_OBJECT_SYMBOLS
13a0e8d7 516 {
3d2b83ea
SC
517
518lang_add_attribute(lang_object_symbols_statement_enum); }
9d1fe8a4 519 | statement ';'
f177a611
JG
520 | statement CONSTRUCTORS
521 {
3d2b83ea
SC
522
523lang_add_attribute(lang_constructors_statement_enum); }
13a0e8d7 524
2fa0b342 525 | statement input_section_spec
3d2b83ea 526 | statement length '(' exp ')'
2fa0b342
DHW
527 {
528 lang_add_data($2,$4);
529 }
530
6812f0e8 531 | statement FILL '(' exp ')'
2fa0b342
DHW
532 {
533 lang_add_fill
534 (exp_get_value_int($4,
535 0,
536 "fill value",
3d2b83ea
SC
537
538lang_first_phase_enum));
2fa0b342
DHW
539 }
540 |
541 ;
542
543length:
3d2b83ea 544 LONG
2fa0b342 545 { $$ = $1; }
3d2b83ea 546 | SHORT
2fa0b342 547 { $$ = $1; }
3d2b83ea 548 | BYTE
2fa0b342
DHW
549 { $$ = $1; }
550 ;
551
552fill_opt:
9d1fe8a4 553 '=' mustbe_exp
2fa0b342
DHW
554 {
555 $$ = exp_get_value_int($2,
556 0,
557 "fill value",
3d2b83ea 558 lang_first_phase_enum);
2fa0b342 559 }
3d2b83ea 560 | { $$ = 0; }
2fa0b342
DHW
561 ;
562
563
564
565assign_op:
566 PLUSEQ
567 { $$ = '+'; }
3d2b83ea 568 | MINUSEQ
2fa0b342
DHW
569 { $$ = '-'; }
570 | MULTEQ
571 { $$ = '*'; }
572 | DIVEQ
573 { $$ = '/'; }
574 | LSHIFTEQ
575 { $$ = LSHIFT; }
576 | RSHIFTEQ
577 { $$ = RSHIFT; }
578 | ANDEQ
579 { $$ = '&'; }
580 | OREQ
581 { $$ = '|'; }
582
583 ;
584
9d1fe8a4 585end: ';' | ','
2fa0b342
DHW
586 ;
587
2fa0b342
DHW
588
589assignment:
3d2b83ea 590 NAME '=' mustbe_exp
2fa0b342
DHW
591 {
592 lang_add_assignment(exp_assop($2,$1,$3));
593 }
3d2b83ea 594 | NAME assign_op mustbe_exp
2fa0b342 595 {
3d2b83ea
SC
596
597lang_add_assignment(exp_assop('=',$1,exp_binop($2,exp_nameop(NAME,$1),$3)));
2fa0b342
DHW
598 }
599
600 ;
601
602
603opt_comma:
604 ',' | ;
605
606
607memory:
3d2b83ea 608 MEMORY '{' memory_spec memory_spec_list '}'
2fa0b342
DHW
609 ;
610
611memory_spec_list:
3d2b83ea 612 memory_spec_list memory_spec
2fa0b342
DHW
613 | memory_spec_list ',' memory_spec
614 |
615 ;
616
617
3d2b83ea 618memory_spec: NAME
2fa0b342 619 { region = lang_memory_region_lookup($1); }
3d2b83ea 620 attributes_opt ':'
9d1fe8a4 621 origin_spec opt_comma length_spec
2fa0b342 622
3d2b83ea 623 ; origin_spec:
9d1fe8a4 624 ORIGIN '=' mustbe_exp
2fa0b342
DHW
625 { region->current =
626 region->origin =
3d2b83ea
SC
627 exp_get_vma($3, 0L,"origin", lang_first_phase_enum);
628}
629 ; length_spec:
630 LENGTH '=' mustbe_exp
631 { region->length = exp_get_vma($3,
2fa0b342
DHW
632 ~((bfd_vma)0),
633 "length",
634 lang_first_phase_enum);
635 }
636
637
638attributes_opt:
639 '(' NAME ')'
640 {
641 lang_set_flags(&region->flags, $2);
642 }
643 |
644
645 ;
646
647startup:
648 STARTUP '(' filename ')'
649 { lang_startup($3); }
650 ;
651
652high_level_library:
3d2b83ea
SC
653 HLL '(' high_level_library_NAME_list ')'
654 | HLL '(' ')'
2fa0b342
DHW
655 { ldemul_hll((char *)NULL); }
656 ;
657
658high_level_library_NAME_list:
3d2b83ea 659 high_level_library_NAME_list opt_comma filename
2fa0b342
DHW
660 { ldemul_hll($3); }
661 | filename
662 { ldemul_hll($1); }
663
664 ;
665
666low_level_library:
667 SYSLIB '(' low_level_library_NAME_list ')'
3d2b83ea 668 ; low_level_library_NAME_list:
2fa0b342 669 low_level_library_NAME_list opt_comma filename
3d2b83ea 670 { ldemul_syslib($3); }
2fa0b342
DHW
671 |
672 ;
673
674floating_point_support:
675 FLOAT
676 { lang_float(true); }
677 | NOFLOAT
3d2b83ea 678 { lang_float(false); }
2fa0b342
DHW
679 ;
680
681
3d2b83ea 682mustbe_exp: { ldlex_expression(); }
9d1fe8a4
SC
683 exp
684 { ldlex_popstate(); $$=$2;}
685 ;
2fa0b342
DHW
686
687exp :
3d2b83ea 688 '-' exp %prec UNARY
2fa0b342 689 { $$ = exp_unop('-', $2); }
9d1fe8a4 690 | '(' exp ')'
2fa0b342
DHW
691 { $$ = $2; }
692 | NEXT '(' exp ')' %prec UNARY
693 { $$ = exp_unop($1,$3); }
3d2b83ea 694 | '!' exp %prec UNARY
2fa0b342 695 { $$ = exp_unop('!', $2); }
3d2b83ea 696 | '+' exp %prec UNARY
2fa0b342 697 { $$ = $2; }
3d2b83ea 698 | '~' exp %prec UNARY
2fa0b342
DHW
699 { $$ = exp_unop('~', $2);}
700
701 | exp '*' exp
702 { $$ = exp_binop('*', $1, $3); }
703 | exp '/' exp
704 { $$ = exp_binop('/', $1, $3); }
705 | exp '%' exp
706 { $$ = exp_binop('%', $1, $3); }
707 | exp '+' exp
708 { $$ = exp_binop('+', $1, $3); }
709 | exp '-' exp
3d2b83ea 710 { $$ = exp_binop('-' , $1, $3); }
2fa0b342
DHW
711 | exp LSHIFT exp
712 { $$ = exp_binop(LSHIFT , $1, $3); }
713 | exp RSHIFT exp
714 { $$ = exp_binop(RSHIFT , $1, $3); }
715 | exp EQ exp
716 { $$ = exp_binop(EQ , $1, $3); }
717 | exp NE exp
718 { $$ = exp_binop(NE , $1, $3); }
719 | exp LE exp
720 { $$ = exp_binop(LE , $1, $3); }
3d2b83ea 721 | exp GE exp
2fa0b342
DHW
722 { $$ = exp_binop(GE , $1, $3); }
723 | exp '<' exp
724 { $$ = exp_binop('<' , $1, $3); }
725 | exp '>' exp
726 { $$ = exp_binop('>' , $1, $3); }
727 | exp '&' exp
728 { $$ = exp_binop('&' , $1, $3); }
729 | exp '^' exp
730 { $$ = exp_binop('^' , $1, $3); }
731 | exp '|' exp
732 { $$ = exp_binop('|' , $1, $3); }
733 | exp '?' exp ':' exp
734 { $$ = exp_trinop('?' , $1, $3, $5); }
735 | exp ANDAND exp
736 { $$ = exp_binop(ANDAND , $1, $3); }
737 | exp OROR exp
738 { $$ = exp_binop(OROR , $1, $3); }
739 | DEFINED '(' NAME ')'
740 { $$ = exp_nameop(DEFINED, $3); }
741 | INT
742 { $$ = exp_intop($1); }
3d2b83ea 743 | SIZEOF_HEADERS
65c552e3 744 { $$ = exp_nameop(SIZEOF_HEADERS,0); }
2fa0b342 745
3d2b83ea 746 | SIZEOF '(' NAME ')'
f177a611 747 { $$ = exp_nameop(SIZEOF,$3); }
2fa0b342 748 | ADDR '(' NAME ')'
f177a611 749 { $$ = exp_nameop(ADDR,$3); }
2fa0b342 750 | ALIGN_K '(' exp ')'
f177a611 751 { $$ = exp_unop(ALIGN_K,$3); }
2fa0b342
DHW
752 | NAME
753 { $$ = exp_nameop(NAME,$1); }
754 ;
755
756
757
758
3d2b83ea 759section: NAME { ldlex_expression(); }
9d1fe8a4 760 opt_exp { ldlex_popstate(); }
3d2b83ea 761 opt_type opt_block ':' opt_things'{'
2fa0b342 762 {
9d1fe8a4 763 lang_enter_output_section_statement($1,$3,$5,$6);
2fa0b342 764 }
e14a43bf 765 statement '}' {ldlex_expression();} fill_opt memspec_opt
2fa0b342 766 {
e14a43bf
SC
767 ldlex_popstate();
768 lang_leave_output_section_statement($14, $15);
2fa0b342 769 }
e14a43bf 770opt_comma
2fa0b342
DHW
771
772 ;
773
3d2b83ea 774opt_type:
f177a611
JG
775 '(' NOLOAD ')' { $$ = SEC_NO_FLAGS; }
776 | '(' DSECT ')' { $$ = 0; }
777 | '(' COPY ')' { $$ = 0; }
778 | '(' INFO ')' { $$ = 0; }
779 | '(' OVERLAY ')' { $$ = 0; }
3d2b83ea 780 | { $$ = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; }
f177a611
JG
781 ;
782
3d2b83ea 783opt_things:
9d1fe8a4
SC
784 {
785 };
6812f0e8 786
2fa0b342
DHW
787
788opt_exp:
6812f0e8 789 exp
2fa0b342
DHW
790 { $$ = $1; }
791 | { $$= (etree_type *)NULL; }
792 ;
793
794opt_block:
9d1fe8a4 795 BLOCK '(' exp ')'
2fa0b342
DHW
796 { $$ = exp_get_value_int($3,
797 1L,
798 "block",
799 lang_first_phase_enum);
800 }
801 | { $$ = 1; }
802 ;
803
804memspec_opt:
9d1fe8a4 805 '>' NAME
2fa0b342
DHW
806 { $$ = $2; }
807 | { $$ = "*default*"; }
808 ;
3d2b83ea
SC
809%%
810void
811yyerror(arg)
812char *arg;
813{
814 if (error_index> 0 && error_index < ERROR_NAME_MAX)
815 einfo("%P%F: %S syntax error in %s\n",error_names[error_index-1]);
816 else
817 einfo("%P%F: %S syntax error\n");
818}
This page took 0.127299 seconds and 4 git commands to generate.