dc196aec37d188d331d0ce038a781f12c8243bab
[deliverable/binutils-gdb.git] / ld / ldgram.y
1 /* A YACC grammer to parse a superset of the AT&T linker scripting languaue.
2 Copyright (C) 1991, 1993 Free Software Foundation, Inc.
3 Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
4
5 This file is part of GNU ld.
6
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.
11
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.
16
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 /*
23
24 */
25
26 #define DONTDECLARE_MALLOC
27
28 #include "bfd.h"
29 #include "sysdep.h"
30 #include "bfdlink.h"
31 #include "ld.h"
32 #include "ldexp.h"
33 #include "ldver.h"
34 #include "ldlang.h"
35 #include "ldemul.h"
36 #include "ldfile.h"
37 #include "ldmisc.h"
38 #include "ldmain.h"
39 #include "mri.h"
40 #include "ldlex.h"
41
42 #define YYDEBUG 1
43
44 static int typebits;
45
46 static char *dirlist_ptr;
47
48 lang_memory_region_type *region;
49
50
51 char *current_file;
52 boolean ldgram_want_filename = true;
53 boolean had_script = false;
54 boolean force_make_executable = false;
55
56 boolean ldgram_in_script = false;
57 boolean ldgram_had_equals = false;
58
59
60 #define ERROR_NAME_MAX 20
61 static char *error_names[ERROR_NAME_MAX];
62 static int error_index;
63 #define PUSH_ERROR(x) if (error_index < ERROR_NAME_MAX) error_names[error_index] = x; error_index++;
64 #define POP_ERROR() error_index--;
65 %}
66 %union {
67 bfd_vma integer;
68 int voidval;
69 char *name;
70 int token;
71 union etree_union *etree;
72 struct sec *section;
73 struct lang_output_section_statement_struct *output_section_statement;
74 union lang_statement_union **statement_ptr;
75 int lineno;
76 struct {
77 FILE *file;
78 char *name;
79 unsigned int lineno;
80 } state;
81
82
83 }
84
85 %type <etree> exp opt_exp_with_type mustbe_exp opt_at
86 %type <integer> fill_opt
87 %type <name> memspec_opt
88 %token <integer> INT
89 %token <name> NAME
90 %type <integer> length
91
92 %right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
93 %right <token> '?' ':'
94 %left <token> OROR
95 %left <token> ANDAND
96 %left <token> '|'
97 %left <token> '^'
98 %left <token> '&'
99 %left <token> EQ NE
100 %left <token> '<' '>' LE GE
101 %left <token> LSHIFT RSHIFT
102
103 %left <token> '+' '-'
104 %left <token> '*' '/' '%'
105
106 /*%token <token> '+' '-' '*' '/' '%'*/
107 %right UNARY
108 %token END
109 %left <token> '('
110 %token <token> ALIGN_K BLOCK QUAD LONG SHORT BYTE
111 %token SECTIONS
112 %token '{' '}'
113 %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
114 %token SIZEOF_HEADERS
115 %token INCLUDE
116 %token MEMORY DEFSYMEND
117 %token NOLOAD DSECT COPY INFO OVERLAY
118 %token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY
119 %token OPTION_e OPTION_c OPTION_noinhibit_exec OPTION_s OPTION_S OPTION_sort_common OPTION_warn_common
120 %token OPTION_EB OPTION_EL OPTION_G OPTION_Gval OPTION_help
121 %token OPTION_format OPTION_oformat OPTION_F OPTION_u OPTION_y OPTION_Bstatic OPTION_N
122 %token <integer> SIZEOF NEXT ADDR
123 %token OPTION_d OPTION_dc OPTION_dp OPTION_x OPTION_X OPTION_defsym
124 %token OPTION_v OPTION_V OPTION_m OPTION_memul OPTION_M OPTION_t STARTUP HLL SYSLIB FLOAT NOFLOAT
125 %token OPTION_L OPTION_Map
126 %token OPTION_n OPTION_r OPTION_o OPTION_b OPTION_R OPTION_relax OPTION_version
127 %token <name> OPTION_l OPTION_Lfile OPTION_T OPTION_Aarch OPTION_Tfile
128 %token <name> OPTION_Texp OPTION_esymbol OPTION_usymbol OPTION_ysymbol
129 %token OPTION_Ur
130 %token ORIGIN FILL OPTION_g
131 %token LENGTH CREATE_OBJECT_SYMBOLS INPUT OUTPUT CONSTRUCTORS
132 %token OPTION_RETAIN_SYMBOLS_FILE ALIGNMOD AT
133 %token OPTION_Qy OPTION_Y OPTION_dn OPTION_call_shared OPTION_non_shared
134 %token OPTION_Oval OPTION_stats OPTION_no_keep_memory
135 %token <name> OPTION_YP
136
137 %type <token> assign_op
138
139 %type <name> filename
140
141
142 %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD
143 %token FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL
144
145 %%
146
147 file: command_line
148
149
150 filename: NAME;
151
152
153 command_line:
154 command_line command_line_option
155 |
156 ;
157
158 command_line_option:
159 OPTION_Bstatic { }
160 | OPTION_help
161 {
162 help ();
163 exit (0);
164 }
165 | OPTION_v
166 {
167 ldversion(0);
168 version_printed = true;
169 }
170 | OPTION_V
171 {
172 ldversion(1);
173 version_printed = true;
174 trace_file_tries = true;
175 }
176 | OPTION_version
177 {
178 ldversion(0);
179 version_printed = true;
180 }
181 | OPTION_t {
182 trace_files = true;
183 }
184 | OPTION_Map NAME
185 {
186 write_map = true;
187 config.map_filename = $2;
188 }
189 | OPTION_m NAME
190 {
191 /* Ignore. */
192 }
193 | OPTION_memul
194 {
195 /* Ignore. */
196 }
197 | OPTION_M
198 {
199 config.map_filename = "-";
200 }
201 | OPTION_n {
202 config.magic_demand_paged = false;
203 }
204 | OPTION_N {
205 config.text_read_only = false;
206 config.magic_demand_paged = false;
207 }
208 | OPTION_s {
209 link_info.strip = strip_all;
210 }
211 | OPTION_S {
212 link_info.strip = strip_debugger;
213 }
214 | OPTION_stats {
215 config.stats = true;
216 }
217 | OPTION_no_keep_memory {
218 link_info.keep_memory = false;
219 }
220 | OPTION_u NAME {
221 ldlang_add_undef($2);
222 }
223 | OPTION_usymbol {
224 ldlang_add_undef($1);
225 }
226 | OPTION_r {
227 link_info.relocateable = true;
228 config.build_constructors = false;
229 config.magic_demand_paged = false;
230 config.text_read_only = false;
231 }
232 | OPTION_Ur {
233 link_info.relocateable = true;
234 config.build_constructors = true;
235 config.magic_demand_paged = false;
236 config.text_read_only = false;
237 }
238 | OPTION_o filename
239 {
240 lang_add_output($2, 0);
241 }
242 | OPTION_e NAME
243 { lang_add_entry($2);
244 }
245 | OPTION_esymbol
246 { lang_add_entry($1);
247 }
248 | OPTION_X {
249 link_info.discard = discard_l;
250 }
251 | OPTION_x {
252 link_info.discard = discard_all;
253 }
254
255 | OPTION_noinhibit_exec
256 {
257 force_make_executable = true;
258 }
259 | OPTION_sort_common
260 {
261 config.sort_common = true;
262 }
263 | OPTION_warn_common
264 {
265 config.warn_common = true;
266 }
267 | OPTION_d {
268 command_line.force_common_definition = true;
269 }
270
271 | OPTION_relax {
272 command_line.relax = true;
273 }
274 | OPTION_dc
275 {
276 command_line.force_common_definition = true;
277 }
278 | OPTION_g
279 {
280 /* Ignored */
281 }
282 | OPTION_dp
283 {
284 command_line.force_common_definition = true;
285 }
286 | OPTION_format NAME
287 {
288 lang_add_target($2);
289 }
290 | OPTION_oformat NAME
291 {
292 lang_add_output_format($2, 0);
293 }
294 | OPTION_Texp
295 { ldlex_expression();
296 hex_mode = 16;
297 }
298 INT
299 { ldlex_popstate();
300 lang_section_start($1,exp_intop($3));
301 hex_mode = 0;
302 }
303 | OPTION_y NAME
304 {
305 add_ysym($2);
306 }
307 | OPTION_ysymbol
308 {
309 add_ysym($1);
310 }
311 | OPTION_Aarch
312 {
313 ldfile_add_arch($1);
314 }
315 | OPTION_b NAME
316 {
317 lang_add_target($2);
318 }
319 | OPTION_L NAME
320 {
321 ldfile_add_library_path($2);
322 }
323 | OPTION_Lfile
324 {
325 ldfile_add_library_path($1);
326 }
327 | OPTION_F
328 {
329 /* Ignore */
330 }
331 | OPTION_c filename
332 {ldfile_open_command_file($2); }
333 mri_script_file END { ldlex_command();}
334
335 | OPTION_Tfile
336 { ldfile_open_command_file($1); } script_file
337 END { ldlex_command();}
338
339 | OPTION_T filename
340 { ldfile_open_command_file($2); } script_file
341 END { ldlex_command();}
342
343 | OPTION_l
344 {
345 lang_add_input_file($1,
346 lang_input_file_is_l_enum,
347 (char *)NULL);
348 }
349 | OPTION_R filename
350 {
351 lang_add_input_file($2,
352 lang_input_file_is_symbols_only_enum,
353 (char *)NULL);
354 }
355
356 | OPTION_defsym { ldlex_defsym(); }
357 NAME '=' exp DEFSYMEND { ldlex_popstate();
358 lang_add_assignment(exp_assop($4,$3,$5));
359 }
360 | OPTION_RETAIN_SYMBOLS_FILE filename
361 { add_keepsyms_file ($2); }
362 | OPTION_EB
363 {
364 /* FIXME: This is currently ignored. It means
365 ``produce a big-endian object file''. It could
366 be used to select an output format. */
367 }
368 | OPTION_EL
369 {
370 /* FIXME: This is currently ignored. It means
371 ``produce a little-endian object file''. It could
372 be used to select an output format. */
373 }
374 | OPTION_G NAME
375 {
376 g_switch_value = atoi ($2);
377 }
378 | OPTION_Gval
379 {
380 g_switch_value = yylval.integer;
381 }
382 | OPTION_Qy
383 | OPTION_dn
384 | OPTION_non_shared
385 | OPTION_call_shared
386 | OPTION_Oval
387 | OPTION_YP
388 {
389 dirlist_ptr = $1;
390 goto set_default_dirlist;
391 }
392 | OPTION_Y NAME
393 {
394 if (strncmp ($2, "P,", 2))
395 einfo ("%P%F: unknown -Y option -- %s\n", $2);
396 else
397 {
398 char *p;
399 dirlist_ptr = $2;
400 set_default_dirlist:
401 while (1)
402 {
403 p = strchr (dirlist_ptr, ':');
404 if (p != NULL)
405 *p = 0;
406 if (*dirlist_ptr)
407 ldfile_add_library_path (dirlist_ptr);
408 if (p == NULL)
409 break;
410 *p = ':';
411 dirlist_ptr = p + 1;
412 }
413 }
414 }
415 | '{' script_file '}' { /* This parses compiled-in scripts. */ }
416 | NAME
417 {
418 if (*$1 == '-')
419 einfo("%P%F: illegal option -- %s\n", $1);
420 else
421 lang_add_input_file($1,lang_input_file_is_file_enum,
422 (char *)NULL);
423 }
424 ;
425
426
427 /* SYNTAX WITHIN AN MRI SCRIPT FILE */
428 mri_script_file:
429 { ldlex_mri_script();
430 PUSH_ERROR("MRI style script");
431 }
432 mri_script_lines
433 { ldlex_popstate();
434 POP_ERROR();
435 }
436 ;
437
438 mri_script_lines:
439 mri_script_lines mri_script_command NEWLINE
440 |
441 ;
442
443 mri_script_command:
444 CHIP exp
445 | CHIP exp ',' exp
446 | NAME {
447 einfo("%P%F: unrecognised keyword in MRI style script '%s'\n",$1);
448 }
449 | LIST {
450 write_map = true;
451 config.map_filename = "-";
452 }
453 | ORDER ordernamelist
454 | ENDWORD
455 | PUBLIC NAME '=' exp
456 { mri_public($2, $4); }
457 | PUBLIC NAME ',' exp
458 { mri_public($2, $4); }
459 | PUBLIC NAME exp
460 { mri_public($2, $3); }
461 | FORMAT NAME
462 { mri_format($2); }
463 | SECT NAME ',' exp
464 { mri_output_section($2, $4);}
465 | SECT NAME exp
466 { mri_output_section($2, $3);}
467 | SECT NAME '=' exp
468 { mri_output_section($2, $4);}
469 | ALIGN_K NAME '=' exp
470 { mri_align($2,$4); }
471 | ALIGNMOD NAME '=' exp
472 { mri_alignmod($2,$4); }
473 | ABSOLUTE mri_abs_name_list
474 | LOAD mri_load_name_list
475 | NAMEWORD NAME
476 { mri_name($2); }
477 | ALIAS NAME ',' NAME
478 { mri_alias($2,$4,0);}
479 | ALIAS NAME ',' INT
480 { mri_alias($2,0,(int) $4);}
481 | BASE exp
482 { mri_base($2); }
483 | TRUNCATE INT
484 { mri_truncate((unsigned int) $2); }
485 |
486 ;
487
488 ordernamelist:
489 ordernamelist ',' NAME { mri_order($3); }
490 | ordernamelist NAME { mri_order($2); }
491 |
492 ;
493
494 mri_load_name_list:
495 NAME
496 { mri_load($1); }
497 | mri_load_name_list ',' NAME { mri_load($3); }
498 ;
499
500 mri_abs_name_list:
501 NAME
502 { mri_only_load($1); }
503 | mri_abs_name_list ',' NAME
504 { mri_only_load($3); }
505 ;
506
507 script_file:
508 {
509 ldlex_both();
510 }
511 ifile_list
512 {
513 ldlex_popstate();
514 }
515 ;
516
517
518 ifile_list:
519 ifile_list ifile_p1
520 |
521 ;
522
523
524
525 ifile_p1:
526 memory
527 | sections
528 | startup
529 | high_level_library
530 | low_level_library
531 | floating_point_support
532 | statement_anywhere
533 | ';'
534 | TARGET_K '(' NAME ')'
535 { lang_add_target($3); }
536 | SEARCH_DIR '(' filename ')'
537 { ldfile_add_library_path($3); }
538 | OUTPUT '(' filename ')'
539 { lang_add_output($3, 1); }
540 | OUTPUT_FORMAT '(' NAME ')'
541 { lang_add_output_format($3, 1); }
542 | OUTPUT_ARCH '(' NAME ')'
543 { ldfile_set_output_arch($3); }
544 | FORCE_COMMON_ALLOCATION
545 { command_line.force_common_definition = true ; }
546 | INPUT '(' input_list ')'
547 | MAP '(' filename ')'
548 { lang_add_map($3); }
549 | INCLUDE filename
550 { ldfile_open_command_file($2); } ifile_list END
551 ;
552
553 input_list:
554 NAME
555 { lang_add_input_file($1,lang_input_file_is_search_file_enum,
556 (char *)NULL); }
557 | input_list ',' NAME
558 { lang_add_input_file($3,lang_input_file_is_search_file_enum,
559 (char *)NULL); }
560 | input_list NAME
561 { lang_add_input_file($2,lang_input_file_is_search_file_enum,
562 (char *)NULL); }
563 ;
564
565 sections:
566 SECTIONS '{' sec_or_group_p1 '}'
567 ;
568
569 sec_or_group_p1:
570 sec_or_group_p1 section
571 | sec_or_group_p1 statement_anywhere
572 |
573 ;
574
575 statement_anywhere:
576 ENTRY '(' NAME ')'
577 { lang_add_entry($3); }
578 | assignment end
579 ;
580
581 file_NAME_list:
582 NAME
583 { lang_add_wild($1, current_file); }
584 | file_NAME_list opt_comma NAME
585 { lang_add_wild($3, current_file); }
586 ;
587
588 input_section_spec:
589 NAME
590 {
591 lang_add_wild((char *)NULL, $1);
592 }
593 | '['
594 {
595 current_file = (char *)NULL;
596 }
597 file_NAME_list
598 ']'
599 | NAME
600 {
601 current_file =$1;
602 }
603 '(' file_NAME_list ')'
604 | '*'
605 {
606 current_file = (char *)NULL;
607 }
608 '(' file_NAME_list ')'
609 ;
610
611 statement:
612 assignment end
613 | CREATE_OBJECT_SYMBOLS
614 {
615 lang_add_attribute(lang_object_symbols_statement_enum);
616 }
617 | ';'
618 | CONSTRUCTORS
619 {
620
621 lang_add_attribute(lang_constructors_statement_enum);
622 }
623 | input_section_spec
624 | length '(' exp ')'
625 {
626 lang_add_data((int) $1,$3);
627 }
628
629 | FILL '(' exp ')'
630 {
631 lang_add_fill
632 (exp_get_value_int($3,
633 0,
634 "fill value",
635 lang_first_phase_enum));
636 }
637 ;
638
639 statement_list:
640 statement_list statement
641 | statement
642 ;
643
644 statement_list_opt:
645 /* empty */
646 | statement_list
647 ;
648
649 length:
650 QUAD
651 { $$ = $1; }
652 | LONG
653 { $$ = $1; }
654 | SHORT
655 { $$ = $1; }
656 | BYTE
657 { $$ = $1; }
658 ;
659
660 fill_opt:
661 '=' mustbe_exp
662 {
663 $$ = exp_get_value_int($2,
664 0,
665 "fill value",
666 lang_first_phase_enum);
667 }
668 | { $$ = 0; }
669 ;
670
671
672
673 assign_op:
674 PLUSEQ
675 { $$ = '+'; }
676 | MINUSEQ
677 { $$ = '-'; }
678 | MULTEQ
679 { $$ = '*'; }
680 | DIVEQ
681 { $$ = '/'; }
682 | LSHIFTEQ
683 { $$ = LSHIFT; }
684 | RSHIFTEQ
685 { $$ = RSHIFT; }
686 | ANDEQ
687 { $$ = '&'; }
688 | OREQ
689 { $$ = '|'; }
690
691 ;
692
693 end: ';' | ','
694 ;
695
696
697 assignment:
698 NAME '=' mustbe_exp
699 {
700 lang_add_assignment(exp_assop($2,$1,$3));
701 }
702 | NAME assign_op mustbe_exp
703 {
704
705 lang_add_assignment(exp_assop('=',$1,exp_binop($2,exp_nameop(NAME,$1),$3)));
706 }
707
708 ;
709
710
711 opt_comma:
712 ',' | ;
713
714
715 memory:
716 MEMORY '{' memory_spec memory_spec_list '}'
717 ;
718
719 memory_spec_list:
720 memory_spec_list memory_spec
721 | memory_spec_list ',' memory_spec
722 |
723 ;
724
725
726 memory_spec: NAME
727 { region = lang_memory_region_lookup($1); }
728 attributes_opt ':'
729 origin_spec opt_comma length_spec
730
731 ; origin_spec:
732 ORIGIN '=' mustbe_exp
733 { region->current =
734 region->origin =
735 exp_get_vma($3, 0L,"origin", lang_first_phase_enum);
736 }
737 ; length_spec:
738 LENGTH '=' mustbe_exp
739 { region->length = exp_get_vma($3,
740 ~((bfd_vma)0),
741 "length",
742 lang_first_phase_enum);
743 }
744
745
746 attributes_opt:
747 '(' NAME ')'
748 {
749 lang_set_flags(&region->flags, $2);
750 }
751 |
752
753 ;
754
755 startup:
756 STARTUP '(' filename ')'
757 { lang_startup($3); }
758 ;
759
760 high_level_library:
761 HLL '(' high_level_library_NAME_list ')'
762 | HLL '(' ')'
763 { ldemul_hll((char *)NULL); }
764 ;
765
766 high_level_library_NAME_list:
767 high_level_library_NAME_list opt_comma filename
768 { ldemul_hll($3); }
769 | filename
770 { ldemul_hll($1); }
771
772 ;
773
774 low_level_library:
775 SYSLIB '(' low_level_library_NAME_list ')'
776 ; low_level_library_NAME_list:
777 low_level_library_NAME_list opt_comma filename
778 { ldemul_syslib($3); }
779 |
780 ;
781
782 floating_point_support:
783 FLOAT
784 { lang_float(true); }
785 | NOFLOAT
786 { lang_float(false); }
787 ;
788
789
790 mustbe_exp: { ldlex_expression(); }
791 exp
792 { ldlex_popstate(); $$=$2;}
793 ;
794
795 exp :
796 '-' exp %prec UNARY
797 { $$ = exp_unop('-', $2); }
798 | '(' exp ')'
799 { $$ = $2; }
800 | NEXT '(' exp ')' %prec UNARY
801 { $$ = exp_unop((int) $1,$3); }
802 | '!' exp %prec UNARY
803 { $$ = exp_unop('!', $2); }
804 | '+' exp %prec UNARY
805 { $$ = $2; }
806 | '~' exp %prec UNARY
807 { $$ = exp_unop('~', $2);}
808
809 | exp '*' exp
810 { $$ = exp_binop('*', $1, $3); }
811 | exp '/' exp
812 { $$ = exp_binop('/', $1, $3); }
813 | exp '%' exp
814 { $$ = exp_binop('%', $1, $3); }
815 | exp '+' exp
816 { $$ = exp_binop('+', $1, $3); }
817 | exp '-' exp
818 { $$ = exp_binop('-' , $1, $3); }
819 | exp LSHIFT exp
820 { $$ = exp_binop(LSHIFT , $1, $3); }
821 | exp RSHIFT exp
822 { $$ = exp_binop(RSHIFT , $1, $3); }
823 | exp EQ exp
824 { $$ = exp_binop(EQ , $1, $3); }
825 | exp NE exp
826 { $$ = exp_binop(NE , $1, $3); }
827 | exp LE exp
828 { $$ = exp_binop(LE , $1, $3); }
829 | exp GE exp
830 { $$ = exp_binop(GE , $1, $3); }
831 | exp '<' exp
832 { $$ = exp_binop('<' , $1, $3); }
833 | exp '>' exp
834 { $$ = exp_binop('>' , $1, $3); }
835 | exp '&' exp
836 { $$ = exp_binop('&' , $1, $3); }
837 | exp '^' exp
838 { $$ = exp_binop('^' , $1, $3); }
839 | exp '|' exp
840 { $$ = exp_binop('|' , $1, $3); }
841 | exp '?' exp ':' exp
842 { $$ = exp_trinop('?' , $1, $3, $5); }
843 | exp ANDAND exp
844 { $$ = exp_binop(ANDAND , $1, $3); }
845 | exp OROR exp
846 { $$ = exp_binop(OROR , $1, $3); }
847 | DEFINED '(' NAME ')'
848 { $$ = exp_nameop(DEFINED, $3); }
849 | INT
850 { $$ = exp_intop($1); }
851 | SIZEOF_HEADERS
852 { $$ = exp_nameop(SIZEOF_HEADERS,0); }
853
854 | SIZEOF '(' NAME ')'
855 { $$ = exp_nameop(SIZEOF,$3); }
856 | ADDR '(' NAME ')'
857 { $$ = exp_nameop(ADDR,$3); }
858 | ABSOLUTE '(' exp ')'
859 { $$ = exp_unop(ABSOLUTE, $3); }
860 | ALIGN_K '(' exp ')'
861 { $$ = exp_unop(ALIGN_K,$3); }
862 | NAME
863 { $$ = exp_nameop(NAME,$1); }
864 ;
865
866
867 opt_at:
868 AT '(' exp ')' { $$ = $3; }
869 | { $$ = 0; }
870 ;
871
872 section: NAME { ldlex_expression(); }
873 opt_exp_with_type
874 opt_at { ldlex_popstate(); }
875 '{'
876 {
877 lang_enter_output_section_statement($1,$3,typebits,0,0,0,$4);
878 }
879 statement_list_opt
880 '}' {ldlex_expression();} fill_opt memspec_opt
881 {
882 ldlex_popstate();
883 lang_leave_output_section_statement($11, $12);
884 }
885 opt_comma
886
887 ;
888
889 type:
890 NOLOAD { typebits = SEC_NEVER_LOAD; }
891 | DSECT { typebits = 0; }
892 | COPY { typebits = 0; }
893 | INFO { typebits = 0; }
894 | OVERLAY { typebits = 0; }
895 | { typebits = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; }
896 ;
897
898
899 opt_exp_with_type:
900 exp ':' { $$ = $1; typebits =0;}
901 | exp '(' type ')' ':' { $$ = $1; }
902 | ':' { $$= (etree_type *)NULL; typebits = 0; }
903 | '(' type ')' ':' { $$= (etree_type *)NULL; }
904 ;
905
906 memspec_opt:
907 '>' NAME
908 { $$ = $2; }
909 | { $$ = "*default*"; }
910 ;
911 %%
912 void
913 yyerror(arg)
914 const char *arg;
915 {
916 if (error_index > 0 && error_index < ERROR_NAME_MAX)
917 einfo("%P%F: %S %s in %s\n", arg, error_names[error_index-1]);
918 else
919 einfo("%P%F: %S %s\n", arg);
920 }
This page took 0.047825 seconds and 4 git commands to generate.