1 /* yyscript.y -- linker script grammar for gold. */
3 /* Copyright (C) 2006-2016 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor <iant@google.com>.
6 This file is part of gold.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
23 /* This is a bison grammar to parse a subset of the original GNU ld
24 linker script language. */
39 /* We need to use a pure parser because we might be multi-threaded.
40 We pass some arguments through the parser to the lexer. */
44 %parse-param {void* closure}
45 %lex-param {void* closure}
47 /* Since we require bison anyhow, we take advantage of it. */
51 /* The values associated with tokens. */
55 struct Parser_string string;
60 /* An output section header. */
61 struct Parser_output_section_header output_section_header;
62 /* An output section trailer. */
63 struct Parser_output_section_trailer output_section_trailer;
64 /* A section constraint. */
65 enum Section_constraint constraint;
66 /* A complete input section specification. */
67 struct Input_section_spec input_section_spec;
68 /* A list of wildcard specifications, with exclusions. */
69 struct Wildcard_sections wildcard_sections;
70 /* A single wildcard specification. */
71 struct Wildcard_section wildcard_section;
72 /* A list of strings. */
73 String_list_ptr string_list;
74 /* Information for a program header. */
75 struct Phdr_info phdr_info;
76 /* Used for version scripts and within VERSION {}. */
77 struct Version_dependency_list* deplist;
78 struct Version_expression_list* versyms;
79 struct Version_tree* versnode;
80 enum Script_section_type section_type;
83 /* Operators, including a precedence table for expressions. */
85 %right PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
98 /* A fake operator used to indicate unary operator precedence. */
103 %token <string> STRING
104 %token <string> QUOTED_STRING
105 %token <integer> INTEGER
107 /* Keywords. This list is taken from ldgram.y and ldlex.l in the old
108 GNU linker, with the keywords which only appear in MRI mode
109 removed. Not all these keywords are actually used in this grammar.
110 In most cases the keyword is recognized as the token name in upper
111 case. The comments indicate where this is not the case. */
115 %token ALIGN_K /* ALIGN */
117 %token ASSERT_K /* ASSERT */
126 %token CREATE_OBJECT_SYMBOLS
127 %token DATA_SEGMENT_ALIGN
128 %token DATA_SEGMENT_END
129 %token DATA_SEGMENT_RELRO_END
137 %token FORCE_COMMON_ALLOCATION
138 %token GLOBAL /* global */
142 %token INHIBIT_COMMON_ALLOCATION
147 %token LENGTH /* LENGTH, l, len */
149 %token LOCAL /* local */
152 %token MAX_K /* MAX */
154 %token MIN_K /* MIN */
162 %token ORIGIN /* ORIGIN, o, org */
169 %token PROVIDE_HIDDEN
176 %token SIZEOF_HEADERS /* SIZEOF_HEADERS, sizeof_headers */
177 %token SORT_BY_ALIGNMENT
184 %token TARGET_K /* TARGET */
186 %token VERSIONK /* VERSION */
188 /* Keywords, part 2. These are keywords that are unique to gold,
189 and not present in the old GNU linker. As before, unless the
190 comments say otherwise, the keyword is recognized as the token
191 name in upper case. */
195 /* Special tokens used to tell the grammar what type of tokens we are
196 parsing. The token stream always begins with one of these tokens.
197 We do this because version scripts can appear embedded within
198 linker scripts, and because --defsym uses the expression
200 %token PARSING_LINKER_SCRIPT
201 %token PARSING_VERSION_SCRIPT
202 %token PARSING_DEFSYM
203 %token PARSING_DYNAMIC_LIST
204 %token PARSING_SECTIONS_BLOCK
205 %token PARSING_SECTION_COMMANDS
206 %token PARSING_MEMORY_DEF
208 /* Non-terminal types, where needed. */
210 %type <expr> parse_exp exp
211 %type <expr> opt_at opt_align opt_subalign opt_fill
212 %type <output_section_header> section_header opt_address_and_section_type
213 %type <section_type> section_type
214 %type <output_section_trailer> section_trailer
215 %type <constraint> opt_constraint
216 %type <string_list> opt_phdr
217 %type <integer> data_length
218 %type <input_section_spec> input_section_no_keep
219 %type <wildcard_sections> wildcard_sections
220 %type <wildcard_section> wildcard_file wildcard_section
221 %type <string_list> exclude_names
222 %type <string> wildcard_name
223 %type <integer> phdr_type memory_attr
224 %type <phdr_info> phdr_info
225 %type <versyms> vers_defns
226 %type <versnode> vers_tag
227 %type <deplist> verdep
228 %type <string> string
232 /* Read the special token to see what to read next. */
234 PARSING_LINKER_SCRIPT linker_script
235 | PARSING_VERSION_SCRIPT version_script
236 | PARSING_DEFSYM defsym_expr
237 | PARSING_DYNAMIC_LIST dynamic_list_expr
238 | PARSING_SECTIONS_BLOCK sections_block
239 | PARSING_SECTION_COMMANDS section_cmds
240 | PARSING_MEMORY_DEF memory_defs
243 /* A file contains a list of commands. */
245 linker_script file_cmd
249 /* A command which may appear at top level of a linker script. */
251 EXTERN '(' extern_name_list ')'
252 | FORCE_COMMON_ALLOCATION
253 { script_set_common_allocation(closure, 1); }
255 { script_start_group(closure); }
257 { script_end_group(closure); }
258 | INHIBIT_COMMON_ALLOCATION
259 { script_set_common_allocation(closure, 0); }
260 | INPUT '(' input_list ')'
261 | MEMORY '{' memory_defs '}'
262 | OPTION '(' string ')'
263 { script_parse_option(closure, $3.value, $3.length); }
264 | OUTPUT_FORMAT '(' string ')'
266 if (!script_check_output_format(closure, $3.value, $3.length,
270 | OUTPUT_FORMAT '(' string ',' string ',' string ')'
272 if (!script_check_output_format(closure, $3.value, $3.length,
274 $7.value, $7.length))
277 | PHDRS '{' phdrs_defs '}'
278 | SEARCH_DIR '(' string ')'
279 { script_add_search_dir(closure, $3.value, $3.length); }
281 { script_start_sections(closure); }
283 { script_finish_sections(closure); }
284 | TARGET_K '(' string ')'
285 { script_set_target(closure, $3.value, $3.length); }
287 { script_push_lex_into_version_mode(closure); }
289 { script_pop_lex_mode(closure); }
290 | ENTRY '(' string ')'
291 { script_set_entry(closure, $3.value, $3.length); }
293 | ASSERT_K '(' parse_exp ',' string ')'
294 { script_add_assertion(closure, $3, $5.value, $5.length); }
296 { script_include_directive(PARSING_LINKER_SCRIPT, closure,
297 $2.value, $2.length); }
302 /* Top level commands which we ignore. The GNU linker uses these to
303 select the output format, but we don't offer a choice. Ignoring
304 these is more-or-less OK since most scripts simply explicitly
305 choose the default. */
307 OUTPUT_ARCH '(' string ')'
310 /* A list of external undefined symbols. We put the lexer into
311 expression mode so that commas separate names; this is what the GNU
315 { script_push_lex_into_expression_mode(closure); }
316 extern_name_list_body
317 { script_pop_lex_mode(closure); }
320 extern_name_list_body:
322 { script_add_extern(closure, $1.value, $1.length); }
323 | extern_name_list_body string
324 { script_add_extern(closure, $2.value, $2.length); }
325 | extern_name_list_body ',' string
326 { script_add_extern(closure, $3.value, $3.length); }
329 /* A list of input file names. */
332 | input_list opt_comma input_list_element
335 /* An input file name. */
338 { script_add_file(closure, $1.value, $1.length); }
340 { script_add_library(closure, $2.value, $2.length); }
342 { script_start_as_needed(closure); }
344 { script_end_as_needed(closure); }
347 /* Commands in a SECTIONS block. */
349 sections_block section_block_cmd
353 /* A command which may appear within a SECTIONS block. */
356 { script_set_entry(closure, $3.value, $3.length); }
358 | ASSERT_K '(' parse_exp ',' string ')'
359 { script_add_assertion(closure, $3, $5.value, $5.length); }
361 { script_include_directive(PARSING_SECTIONS_BLOCK, closure,
362 $2.value, $2.length); }
363 | string section_header
364 { script_start_output_section(closure, $1.value, $1.length, &$2); }
365 '{' section_cmds '}' section_trailer
366 { script_finish_output_section(closure, &$7); }
369 /* The header of an output section in a SECTIONS block--everything
372 { script_push_lex_into_expression_mode(closure); }
373 opt_address_and_section_type opt_at opt_align opt_subalign
374 { script_pop_lex_mode(closure); }
377 $$.address = $2.address;
378 $$.section_type = $2.section_type;
379 $$.load_address = $3;
386 /* The optional address followed by the optional section type. This
387 is a separate nonterminal to avoid a shift/reduce conflict on
388 '(' in section_header. */
390 opt_address_and_section_type:
394 $$.section_type = SCRIPT_SECTION_TYPE_NONE;
399 $$.section_type = SCRIPT_SECTION_TYPE_NONE;
404 $$.section_type = SCRIPT_SECTION_TYPE_NONE;
409 $$.section_type = SCRIPT_SECTION_TYPE_NONE;
411 | '(' section_type ')' ':'
414 $$.section_type = $2;
416 | exp '(' section_type ')' ':'
419 $$.section_type = $3;
423 /* We only support NOLOAD. */
426 { $$ = SCRIPT_SECTION_TYPE_NOLOAD; }
429 yyerror(closure, "DSECT section type is unsupported");
430 $$ = SCRIPT_SECTION_TYPE_DSECT;
434 yyerror(closure, "COPY section type is unsupported");
435 $$ = SCRIPT_SECTION_TYPE_COPY;
439 yyerror(closure, "INFO section type is unsupported");
440 $$ = SCRIPT_SECTION_TYPE_INFO;
444 yyerror(closure, "OVERLAY section type is unsupported");
445 $$ = SCRIPT_SECTION_TYPE_OVERLAY;
449 /* The address at which an output section should be loaded. */
457 /* The alignment of an output section. */
461 | ALIGN_K '(' exp ')'
465 /* The input section alignment within an output section. */
469 | SUBALIGN '(' exp ')'
473 /* A section constraint. */
476 { $$ = CONSTRAINT_NONE; }
478 { $$ = CONSTRAINT_ONLY_IF_RO; }
480 { $$ = CONSTRAINT_ONLY_IF_RW; }
482 { $$ = CONSTRAINT_SPECIAL; }
485 /* The trailer of an output section in a SECTIONS block. */
487 opt_memspec opt_at_memspec opt_phdr opt_fill opt_comma
494 /* A memory specification for an output section. */
497 { script_set_section_region(closure, $2.value, $2.length, 1); }
501 /* A memory specification for where to load an output section. */
504 { script_set_section_region(closure, $3.value, $3.length, 0); }
508 /* The program segment an output section should go into. */
511 { $$ = script_string_list_push_back($1, $3.value, $3.length); }
516 /* The value to use to fill an output section. FIXME: This does not
517 handle a string of arbitrary length. */
525 /* Commands which may appear within the description of an output
526 section in a SECTIONS block. */
529 | section_cmds section_cmd
532 /* A command which may appear within the description of an output
533 section in a SECTIONS block. */
537 | data_length '(' parse_exp ')'
538 { script_add_data(closure, $1, $3); }
539 | ASSERT_K '(' parse_exp ',' string ')'
540 { script_add_assertion(closure, $3, $5.value, $5.length); }
541 | FILL '(' parse_exp ')'
542 { script_add_fill(closure, $3); }
545 /* The GNU linker uses CONSTRUCTORS for the a.out object
546 file format. It does nothing when using ELF. Since
547 some ELF linker scripts use it although it does
548 nothing, we accept it and ignore it. */
550 | SORT_BY_NAME '(' CONSTRUCTORS ')'
552 { script_include_directive(PARSING_SECTION_COMMANDS, closure,
553 $2.value, $2.length); }
557 /* The length of data which may appear within the description of an
558 output section in a SECTIONS block. */
572 /* An input section specification. This may appear within the
573 description of an output section in a SECTIONS block. */
575 input_section_no_keep
576 { script_add_input_section(closure, &$1, 0); }
577 | KEEP '(' input_section_no_keep ')'
578 { script_add_input_section(closure, &$3, 1); }
581 /* An input section specification within a KEEP clause. */
582 input_section_no_keep:
586 $$.file.sort = SORT_WILDCARD_NONE;
587 $$.input_sections.sections = NULL;
588 $$.input_sections.exclude = NULL;
590 | wildcard_file '(' wildcard_sections ')'
593 $$.input_sections = $3;
597 /* A wildcard file specification. */
602 $$.sort = SORT_WILDCARD_NONE;
604 | SORT_BY_NAME '(' wildcard_name ')'
607 $$.sort = SORT_WILDCARD_BY_NAME;
611 /* A list of wild card section specifications. */
613 wildcard_sections opt_comma wildcard_section
615 $$.sections = script_string_sort_list_add($1.sections, &$3);
616 $$.exclude = $1.exclude;
620 $$.sections = script_new_string_sort_list(&$1);
623 | wildcard_sections opt_comma EXCLUDE_FILE '(' exclude_names ')'
625 $$.sections = $1.sections;
626 $$.exclude = script_string_list_append($1.exclude, $5);
628 | EXCLUDE_FILE '(' exclude_names ')'
635 /* A single wild card specification. */
640 $$.sort = SORT_WILDCARD_NONE;
642 | SORT_BY_NAME '(' wildcard_section ')'
647 case SORT_WILDCARD_NONE:
648 $$.sort = SORT_WILDCARD_BY_NAME;
650 case SORT_WILDCARD_BY_NAME:
651 case SORT_WILDCARD_BY_NAME_BY_ALIGNMENT:
653 case SORT_WILDCARD_BY_ALIGNMENT:
654 case SORT_WILDCARD_BY_ALIGNMENT_BY_NAME:
655 $$.sort = SORT_WILDCARD_BY_NAME_BY_ALIGNMENT;
661 | SORT_BY_ALIGNMENT '(' wildcard_section ')'
666 case SORT_WILDCARD_NONE:
667 $$.sort = SORT_WILDCARD_BY_ALIGNMENT;
669 case SORT_WILDCARD_BY_ALIGNMENT:
670 case SORT_WILDCARD_BY_ALIGNMENT_BY_NAME:
672 case SORT_WILDCARD_BY_NAME:
673 case SORT_WILDCARD_BY_NAME_BY_ALIGNMENT:
674 $$.sort = SORT_WILDCARD_BY_ALIGNMENT_BY_NAME;
682 /* A list of file names to exclude. */
684 exclude_names opt_comma wildcard_name
685 { $$ = script_string_list_push_back($1, $3.value, $3.length); }
687 { $$ = script_new_string_list($1.value, $1.length); }
690 /* A single wildcard name. We recognize '*' and '?' specially since
691 they are expression tokens. */
707 /* A list of MEMORY definitions. */
709 memory_defs opt_comma memory_def
713 /* A single MEMORY definition. */
715 string memory_attr ':' memory_origin '=' parse_exp opt_comma memory_length '=' parse_exp
716 { script_add_memory(closure, $1.value, $1.length, $2, $6, $10); }
719 { script_include_directive(PARSING_MEMORY_DEF, closure,
720 $2.value, $2.length); }
724 /* The (optional) attributes of a MEMORY region. */
727 { $$ = script_parse_memory_attr(closure, $2.value, $2.length, 0); }
728 | /* Inverted attributes. */
730 { $$ = script_parse_memory_attr(closure, $3.value, $3.length, 1); }
751 /* A list of program header definitions. */
757 /* A program header definition. */
759 string phdr_type phdr_info ';'
760 { script_add_phdr(closure, $1.value, $1.length, $2, &$3); }
763 /* A program header type. The GNU linker accepts a general expression
764 here, but that would be a pain because we would have to dig into
765 the expression structure. It's unlikely that anybody uses anything
766 other than a string or a number here, so that is all we expect. */
769 { $$ = script_phdr_string_to_type(closure, $1.value, $1.length); }
774 /* Additional information for a program header. */
777 { memset(&$$, 0, sizeof(struct Phdr_info)); }
781 if ($1.length == 7 && strncmp($1.value, "FILEHDR", 7) == 0)
782 $$.includes_filehdr = 1;
784 yyerror(closure, "PHDRS syntax error");
789 $$.includes_phdrs = 1;
791 | string '(' INTEGER ')' phdr_info
794 if ($1.length == 5 && strncmp($1.value, "FLAGS", 5) == 0)
796 $$.is_flags_valid = 1;
800 yyerror(closure, "PHDRS syntax error");
802 | AT '(' parse_exp ')' phdr_info
805 $$.load_address = $3;
809 /* Set a symbol to a value. */
812 { script_set_symbol(closure, $1.value, $1.length, $3, 0, 0); }
813 | string PLUSEQ parse_exp
815 Expression_ptr s = script_exp_string($1.value, $1.length);
816 Expression_ptr e = script_exp_binary_add(s, $3);
817 script_set_symbol(closure, $1.value, $1.length, e, 0, 0);
819 | string MINUSEQ parse_exp
821 Expression_ptr s = script_exp_string($1.value, $1.length);
822 Expression_ptr e = script_exp_binary_sub(s, $3);
823 script_set_symbol(closure, $1.value, $1.length, e, 0, 0);
825 | string MULTEQ parse_exp
827 Expression_ptr s = script_exp_string($1.value, $1.length);
828 Expression_ptr e = script_exp_binary_mult(s, $3);
829 script_set_symbol(closure, $1.value, $1.length, e, 0, 0);
831 | string DIVEQ parse_exp
833 Expression_ptr s = script_exp_string($1.value, $1.length);
834 Expression_ptr e = script_exp_binary_div(s, $3);
835 script_set_symbol(closure, $1.value, $1.length, e, 0, 0);
837 | string LSHIFTEQ parse_exp
839 Expression_ptr s = script_exp_string($1.value, $1.length);
840 Expression_ptr e = script_exp_binary_lshift(s, $3);
841 script_set_symbol(closure, $1.value, $1.length, e, 0, 0);
843 | string RSHIFTEQ parse_exp
845 Expression_ptr s = script_exp_string($1.value, $1.length);
846 Expression_ptr e = script_exp_binary_rshift(s, $3);
847 script_set_symbol(closure, $1.value, $1.length, e, 0, 0);
849 | string ANDEQ parse_exp
851 Expression_ptr s = script_exp_string($1.value, $1.length);
852 Expression_ptr e = script_exp_binary_bitwise_and(s, $3);
853 script_set_symbol(closure, $1.value, $1.length, e, 0, 0);
855 | string OREQ parse_exp
857 Expression_ptr s = script_exp_string($1.value, $1.length);
858 Expression_ptr e = script_exp_binary_bitwise_or(s, $3);
859 script_set_symbol(closure, $1.value, $1.length, e, 0, 0);
861 | PROVIDE '(' string '=' parse_exp ')'
862 { script_set_symbol(closure, $3.value, $3.length, $5, 1, 0); }
863 | PROVIDE_HIDDEN '(' string '=' parse_exp ')'
864 { script_set_symbol(closure, $3.value, $3.length, $5, 1, 1); }
867 /* Parse an expression, putting the lexer into the right mode. */
869 { script_push_lex_into_expression_mode(closure); }
872 script_pop_lex_mode(closure);
881 | '-' exp %prec UNARY
882 { $$ = script_exp_unary_minus($2); }
883 | '!' exp %prec UNARY
884 { $$ = script_exp_unary_logical_not($2); }
885 | '~' exp %prec UNARY
886 { $$ = script_exp_unary_bitwise_not($2); }
887 | '+' exp %prec UNARY
890 { $$ = script_exp_binary_mult($1, $3); }
892 { $$ = script_exp_binary_div($1, $3); }
894 { $$ = script_exp_binary_mod($1, $3); }
896 { $$ = script_exp_binary_add($1, $3); }
898 { $$ = script_exp_binary_sub($1, $3); }
900 { $$ = script_exp_binary_lshift($1, $3); }
902 { $$ = script_exp_binary_rshift($1, $3); }
904 { $$ = script_exp_binary_eq($1, $3); }
906 { $$ = script_exp_binary_ne($1, $3); }
908 { $$ = script_exp_binary_le($1, $3); }
910 { $$ = script_exp_binary_ge($1, $3); }
912 { $$ = script_exp_binary_lt($1, $3); }
914 { $$ = script_exp_binary_gt($1, $3); }
916 { $$ = script_exp_binary_bitwise_and($1, $3); }
918 { $$ = script_exp_binary_bitwise_xor($1, $3); }
920 { $$ = script_exp_binary_bitwise_or($1, $3); }
922 { $$ = script_exp_binary_logical_and($1, $3); }
924 { $$ = script_exp_binary_logical_or($1, $3); }
925 | exp '?' exp ':' exp
926 { $$ = script_exp_trinary_cond($1, $3, $5); }
928 { $$ = script_exp_integer($1); }
930 { $$ = script_symbol(closure, $1.value, $1.length); }
931 | MAX_K '(' exp ',' exp ')'
932 { $$ = script_exp_function_max($3, $5); }
933 | MIN_K '(' exp ',' exp ')'
934 { $$ = script_exp_function_min($3, $5); }
935 | DEFINED '(' string ')'
936 { $$ = script_exp_function_defined($3.value, $3.length); }
938 { $$ = script_exp_function_sizeof_headers(); }
939 | ALIGNOF '(' string ')'
940 { $$ = script_exp_function_alignof($3.value, $3.length); }
941 | SIZEOF '(' string ')'
942 { $$ = script_exp_function_sizeof($3.value, $3.length); }
943 | ADDR '(' string ')'
944 { $$ = script_exp_function_addr($3.value, $3.length); }
945 | LOADADDR '(' string ')'
946 { $$ = script_exp_function_loadaddr($3.value, $3.length); }
947 | ORIGIN '(' string ')'
948 { $$ = script_exp_function_origin(closure, $3.value, $3.length); }
949 | LENGTH '(' string ')'
950 { $$ = script_exp_function_length(closure, $3.value, $3.length); }
951 | CONSTANT '(' string ')'
952 { $$ = script_exp_function_constant($3.value, $3.length); }
953 | ABSOLUTE '(' exp ')'
954 { $$ = script_exp_function_absolute($3); }
955 | ALIGN_K '(' exp ')'
956 { $$ = script_exp_function_align(script_exp_string(".", 1), $3); }
957 | ALIGN_K '(' exp ',' exp ')'
958 { $$ = script_exp_function_align($3, $5); }
960 { $$ = script_exp_function_align(script_exp_string(".", 1), $3); }
961 | DATA_SEGMENT_ALIGN '(' exp ',' exp ')'
963 script_data_segment_align(closure);
964 $$ = script_exp_function_data_segment_align($3, $5);
966 | DATA_SEGMENT_RELRO_END '(' exp ',' exp ')'
968 script_data_segment_relro_end(closure);
969 $$ = script_exp_function_data_segment_relro_end($3, $5);
971 | DATA_SEGMENT_END '(' exp ')'
972 { $$ = script_exp_function_data_segment_end($3); }
973 | SEGMENT_START '(' string ',' exp ')'
975 $$ = script_exp_function_segment_start($3.value, $3.length, $5);
976 /* We need to take note of any SEGMENT_START expressions
977 because they change the behaviour of -Ttext, -Tdata and
979 script_saw_segment_start_expression(closure);
981 | ASSERT_K '(' exp ',' string ')'
982 { $$ = script_exp_function_assert($3, $5.value, $5.length); }
985 /* Handle the --defsym option. */
988 { script_set_symbol(closure, $1.value, $1.length, $3, 0, 0); }
991 /* Handle the --dynamic-list option. A dynamic list has the format
992 { sym1; sym2; extern "C++" { namespace::sym3 }; };
993 We store the symbol we see in the "local" list; that is where
994 Command_line::in_dynamic_list() will look to do its check.
995 TODO(csilvers): More than one of these brace-lists can appear, and
996 should just be merged and treated as a single list. */
997 dynamic_list_expr: dynamic_list_nodes ;
1001 | dynamic_list_nodes dynamic_list_node
1005 '{' vers_defns ';' '}' ';'
1006 { script_new_vers_node (closure, NULL, $2); }
1009 /* A version script. */
1016 | vers_nodes vers_node
1020 '{' vers_tag '}' ';'
1022 script_register_vers_node (closure, NULL, 0, $2, NULL);
1024 | string '{' vers_tag '}' ';'
1026 script_register_vers_node (closure, $1.value, $1.length, $3,
1029 | string '{' vers_tag '}' verdep ';'
1031 script_register_vers_node (closure, $1.value, $1.length, $3, $5);
1038 $$ = script_add_vers_depend (closure, NULL, $1.value, $1.length);
1042 $$ = script_add_vers_depend (closure, $1, $2.value, $2.length);
1048 { $$ = script_new_vers_node (closure, NULL, NULL); }
1050 { $$ = script_new_vers_node (closure, $1, NULL); }
1051 | GLOBAL ':' vers_defns ';'
1052 { $$ = script_new_vers_node (closure, $3, NULL); }
1053 | LOCAL ':' vers_defns ';'
1054 { $$ = script_new_vers_node (closure, NULL, $3); }
1055 | GLOBAL ':' vers_defns ';' LOCAL ':' vers_defns ';'
1056 { $$ = script_new_vers_node (closure, $3, $7); }
1059 /* Here is one of the rare places we care about the distinction
1060 between STRING and QUOTED_STRING. For QUOTED_STRING, we do exact
1061 matching on the pattern, so we pass in true for the exact_match
1062 parameter. For STRING, we do glob matching and pass in false. */
1066 $$ = script_new_vers_pattern (closure, NULL, $1.value,
1071 $$ = script_new_vers_pattern (closure, NULL, $1.value,
1074 | vers_defns ';' STRING
1076 $$ = script_new_vers_pattern (closure, $1, $3.value,
1079 | vers_defns ';' QUOTED_STRING
1081 $$ = script_new_vers_pattern (closure, $1, $3.value,
1084 | /* Push string on the language stack. */
1086 { version_script_push_lang (closure, $2.value, $2.length); }
1087 vers_defns opt_semicolon '}'
1090 version_script_pop_lang(closure);
1092 | /* Push string on the language stack. This is more complicated
1093 than the other cases because we need to merge the linked-list
1094 state from the pre-EXTERN defns and the post-EXTERN defns. */
1095 vers_defns ';' EXTERN string '{'
1096 { version_script_push_lang (closure, $4.value, $4.length); }
1097 vers_defns opt_semicolon '}'
1099 $$ = script_merge_expressions ($1, $7);
1100 version_script_pop_lang(closure);
1102 | EXTERN // "extern" as a symbol name
1104 $$ = script_new_vers_pattern (closure, NULL, "extern",
1105 sizeof("extern") - 1, 1);
1107 | vers_defns ';' EXTERN
1109 $$ = script_new_vers_pattern (closure, $1, "extern",
1110 sizeof("extern") - 1, 1);
1114 /* A string can be either a STRING or a QUOTED_STRING. Almost all the
1115 time we don't care, and we use this rule. */
1123 /* Some statements require a terminator, which may be a semicolon or a
1130 /* An optional semicolon. */
1136 /* An optional comma. */