9 This is a YACC grammer intended to parse a superset of the AT&T
10 linker scripting languaue.
30 extern unsigned int lineno;
31 extern boolean trace_files;
32 extern boolean write_map;
36 strip_symbols_type strip_symbols=STRIP_NONE;
37 discard_locals_type discard_locals=DISCARD_NONE;
40 lang_memory_region_type *region;
43 lang_memory_region_type *lang_memory_region_lookup();
44 lang_output_section_statement_type *lang_output_section_statement_lookup();
48 void lang_add_data(int type, union etree_union *exp);
49 void lang_enter_output_section_statement(char *output_section_statement_name, etree_type *address_exp, bfd_vma block_value);
54 void lang_enter_output_section_statement();
58 extern args_type command_line;
60 boolean ldgram_want_filename = true;
61 boolean had_script = false;
62 boolean force_make_executable = false;
64 boolean ldgram_in_script = false;
65 boolean ldgram_had_equals = false;
77 union etree_union *etree;
79 struct lang_output_section_statement_struct *output_section_statement;
80 union lang_statement_union **statement_ptr;
91 %type <etree> exp opt_exp
92 %type <integer> fill_opt opt_block
93 %type <name> memspec_opt
96 %type <integer> length
98 %right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
99 %right <token> '?' ':'
106 %left <token> '<' '>' LE GE
107 %left <token> LSHIFT RSHIFT
109 %left <token> '+' '-'
110 %left <token> '*' '/' '%'
112 /*%token <token> '+' '-' '*' '/' '%'*/
115 %token <token> ALIGN_K BLOCK LONG SHORT BYTE
118 %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
119 %token SIZEOF_HEADERS
121 %token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY
122 %token OPTION_e OPTION_c OPTION_noinhibit_exec OPTION_s OPTION_S OPTION_sort_common
123 %token OPTION_format OPTION_F OPTION_u
124 %token <integer> SIZEOF NEXT ADDR
125 %token OPTION_d OPTION_dc OPTION_dp OPTION_x OPTION_X OPTION_defsym
126 %token OPTION_v OPTION_M OPTION_t STARTUP HLL SYSLIB FLOAT NOFLOAT
127 %token OPTION_n OPTION_r OPTION_o OPTION_b OPTION_R
128 %token <name> OPTION_l OPTION_L OPTION_T OPTION_Aarch OPTION_Tfile OPTION_Texp
130 %token ORIGIN FILL OPTION_g
131 %token LENGTH CREATE_OBJECT_SYMBOLS INPUT OUTPUT
132 %type <token> assign_op
134 %type <name> filename
137 ld_config_type config;
144 file: command_line { lang_final(); };
151 command_line command_line_option
157 { ldgram_in_script = true; }
159 { ldgram_in_script = false; }
173 config.magic_demand_paged = false;
174 config.make_executable = false;
177 strip_symbols = STRIP_ALL;
180 strip_symbols = STRIP_DEBUGGER;
183 ldlang_add_undef($2);
187 config.relocateable_output = true;
188 config.build_constructors = false;
189 config.magic_demand_paged = false;
192 config.relocateable_output = true;
193 config.build_constructors = true;
194 config.magic_demand_paged = false;
201 { lang_add_entry($2);
204 discard_locals = DISCARD_L;
207 discard_locals = DISCARD_ALL;
210 | OPTION_noinhibit_exec
212 force_make_executable = true;
214 | OPTION_sort_common {
215 config.sort_common = true;
218 command_line.force_common_definition = true;
222 command_line.force_common_definition = true;
230 command_line.force_common_definition = true;
242 lang_section_start($1,exp_intop($3));
256 ldfile_add_library_path($1);
263 { lang_add_input_file($1,lang_input_file_is_file_enum,
265 | OPTION_c filename script_file
266 { ldfile_open_command_file($2); }
268 { ldfile_open_command_file($1); } script_file
271 { ldfile_open_command_file($2); } script_file
275 lang_add_input_file($1,
276 lang_input_file_is_l_enum,
281 lang_add_input_file($2,
282 lang_input_file_is_symbols_only_enum,
291 lang_add_assignment(exp_assop($4,$3,$5));
294 { info("%P%F Unrecognised option -%s\n", $2); }
306 { ldgram_in_script = true; }
308 { ldgram_in_script = false; }
326 | floating_point_support
328 | TARGET_K '(' NAME ')'
329 { lang_add_target($3); }
330 | SEARCH_DIR '(' filename ')'
331 { ldfile_add_library_path($3); }
332 | OUTPUT '(' filename ')'
333 { lang_add_output($3); }
334 | OUTPUT_FORMAT '(' NAME ')'
335 { lang_add_output_format($3); }
336 | OUTPUT_ARCH '(' NAME ')'
337 { ldfile_set_output_arch($3); }
338 | FORCE_COMMON_ALLOCATION
339 { command_line.force_common_definition = true ; }
340 | INPUT '(' input_list ')'
341 | MAP '(' filename ')'
342 { lang_add_map($3); }
347 { lang_add_input_file($1,lang_input_file_is_file_enum,
349 | input_list ',' NAME
350 { lang_add_input_file($3,lang_input_file_is_file_enum,
353 { lang_add_input_file($2, lang_input_file_is_file_enum,
358 SECTIONS '{'sec_or_group_p1 '}'
362 sec_or_group_p1 section
363 | sec_or_group_p1 statement_anywhere
369 { lang_add_entry($3); }
375 { lang_add_wild($1, current_file); }
376 | file_NAME_list opt_comma NAME
377 { lang_add_wild($3, current_file); }
383 lang_add_wild((char *)NULL, $1);
387 current_file = (char *)NULL;
395 '(' file_NAME_list ')'
398 current_file = (char *)NULL;
400 '(' file_NAME_list ')'
404 statement assignment end
405 | statement CREATE_OBJECT_SYMBOLS
407 lang_add_attribute(lang_object_symbols_statement_enum); }
409 | statement input_section_spec
410 | statement length '(' exp ')'
412 lang_add_data($2,$4);
415 | statement FILL '(' exp ')'
418 (exp_get_value_int($4,
421 lang_first_phase_enum));
438 $$ = exp_get_value_int($2,
441 lang_first_phase_enum);
475 lang_add_assignment(exp_assop($2,$1,$3));
479 lang_add_assignment(exp_assop('=',$1,exp_binop($2,exp_nameop(NAME,$1),$3)));
490 MEMORY '{' memory_spec memory_spec_list '}'
494 memory_spec_list memory_spec
495 | memory_spec_list ',' memory_spec
502 { region = lang_memory_region_lookup($1); }
503 attributes_opt ':' origin_spec opt_comma length_spec
514 exp_get_vma($3, 0L,"origin", lang_first_phase_enum); }
518 { region->length = exp_get_vma($3,
521 lang_first_phase_enum);
528 lang_set_flags(®ion->flags, $2);
535 STARTUP '(' filename ')'
536 { lang_startup($3); }
540 HLL '(' high_level_library_NAME_list ')'
542 { ldemul_hll((char *)NULL); }
545 high_level_library_NAME_list:
546 high_level_library_NAME_list opt_comma filename
554 SYSLIB '(' low_level_library_NAME_list ')'
556 low_level_library_NAME_list:
557 low_level_library_NAME_list opt_comma filename
558 { ldemul_syslib($3); }
562 floating_point_support:
564 { lang_float(true); }
566 { lang_float(false); }
574 { $$ = exp_unop('-', $2); }
577 | NEXT '(' exp ')' %prec UNARY
578 { $$ = exp_unop($1,$3); }
579 | '!' exp %prec UNARY
580 { $$ = exp_unop('!', $2); }
581 | '+' exp %prec UNARY
583 | '~' exp %prec UNARY
584 { $$ = exp_unop('~', $2);}
587 { $$ = exp_binop('*', $1, $3); }
589 { $$ = exp_binop('/', $1, $3); }
591 { $$ = exp_binop('%', $1, $3); }
593 { $$ = exp_binop('+', $1, $3); }
595 { $$ = exp_binop('-' , $1, $3); }
597 { $$ = exp_binop(LSHIFT , $1, $3); }
599 { $$ = exp_binop(RSHIFT , $1, $3); }
601 { $$ = exp_binop(EQ , $1, $3); }
603 { $$ = exp_binop(NE , $1, $3); }
605 { $$ = exp_binop(LE , $1, $3); }
607 { $$ = exp_binop(GE , $1, $3); }
609 { $$ = exp_binop('<' , $1, $3); }
611 { $$ = exp_binop('>' , $1, $3); }
613 { $$ = exp_binop('&' , $1, $3); }
615 { $$ = exp_binop('^' , $1, $3); }
617 { $$ = exp_binop('|' , $1, $3); }
618 | exp '?' exp ':' exp
619 { $$ = exp_trinop('?' , $1, $3, $5); }
621 { $$ = exp_binop(ANDAND , $1, $3); }
623 { $$ = exp_binop(OROR , $1, $3); }
624 | DEFINED '(' NAME ')'
625 { $$ = exp_nameop(DEFINED, $3); }
627 { $$ = exp_intop($1); }
629 { $$ = exp_nameop(SIZEOF_HEADERS,0); }
631 | SIZEOF '(' NAME ')'
632 { $$ = exp_nameop($1,$3); }
634 { $$ = exp_nameop($1,$3); }
635 | ALIGN_K '(' exp ')'
636 { $$ = exp_unop($1,$3); }
638 { $$ = exp_nameop(NAME,$1); }
644 section: NAME opt_exp opt_block ':' opt_things'{'
646 lang_enter_output_section_statement($1,$2,$3);
648 statement '}' fill_opt memspec_opt
650 lang_leave_output_section_statement($10, $11);
668 | { $$= (etree_type *)NULL; }
673 { $$ = exp_get_value_int($3,
676 lang_first_phase_enum);
684 | { $$ = "*default*"; }