1 /* yyscript.y -- linker script grammar for gold. */
3 /* Copyright 2006, 2007, 2008 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
146 %token LENGTH
/* LENGTH, l, len */
148 %token LOCAL
/* local */
151 %token MAX_K
/* MAX */
153 %token MIN_K
/* MIN */
160 %token ORIGIN
/* ORIGIN, o, org */
167 %token PROVIDE_HIDDEN
174 %token SIZEOF_HEADERS
/* SIZEOF_HEADERS, sizeof_headers */
175 %token SORT_BY_ALIGNMENT
182 %token TARGET_K
/* TARGET */
184 %token VERSIONK
/* VERSION */
186 /* Keywords, part 2. These are keywords that are unique to gold,
187 and not present in the old GNU linker. As before, unless the
188 comments say otherwise, the keyword is recognized as the token
189 name in upper case. */
193 /* Special tokens used to tell the grammar what type of tokens we are
194 parsing. The token stream always begins with one of these tokens.
195 We do this because version scripts can appear embedded within
196 linker scripts, and because --defsym uses the expression
198 %token PARSING_LINKER_SCRIPT
199 %token PARSING_VERSION_SCRIPT
200 %token PARSING_DEFSYM
201 %token PARSING_DYNAMIC_LIST
203 /* Non-terminal types, where needed. */
205 %type
<expr
> parse_exp exp
206 %type
<expr
> opt_at opt_align opt_subalign opt_fill
207 %type
<output_section_header
> section_header opt_address_and_section_type
208 %type
<section_type
> section_type
209 %type
<output_section_trailer
> section_trailer
210 %type
<constraint
> opt_constraint
211 %type
<string_list
> opt_phdr
212 %type
<integer
> data_length
213 %type
<input_section_spec
> input_section_no_keep
214 %type
<wildcard_sections
> wildcard_sections
215 %type
<wildcard_section
> wildcard_file wildcard_section
216 %type
<string_list
> exclude_names
217 %type
<string> wildcard_name
218 %type
<integer
> phdr_type
219 %type
<phdr_info
> phdr_info
220 %type
<versyms
> vers_defns
221 %type
<versnode
> vers_tag
222 %type
<deplist
> verdep
223 %type
<string> string
227 /* Read the special token to see what to read next. */
229 PARSING_LINKER_SCRIPT linker_script
230 | PARSING_VERSION_SCRIPT version_script
231 | PARSING_DEFSYM defsym_expr
232 | PARSING_DYNAMIC_LIST dynamic_list_expr
235 /* A file contains a list of commands. */
237 linker_script file_cmd
241 /* A command which may appear at top level of a linker script. */
243 EXTERN
'(' extern_name_list
')'
244 | FORCE_COMMON_ALLOCATION
245 { script_set_common_allocation
(closure
, 1); }
247 { script_start_group
(closure
); }
249 { script_end_group
(closure
); }
250 | INHIBIT_COMMON_ALLOCATION
251 { script_set_common_allocation
(closure
, 0); }
252 | INPUT
'(' input_list
')'
253 | OPTION
'(' string ')'
254 { script_parse_option
(closure
, $3.value
, $3.length
); }
255 | OUTPUT_FORMAT
'(' string ')'
257 if
(!script_check_output_format
(closure
, $3.value
, $3.length
,
261 | OUTPUT_FORMAT
'(' string ',' string ',' string ')'
263 if
(!script_check_output_format
(closure
, $3.value
, $3.length
,
265 $7.value
, $7.length
))
268 | PHDRS
'{' phdrs_defs
'}'
269 | SEARCH_DIR
'(' string ')'
270 { script_add_search_dir
(closure
, $3.value
, $3.length
); }
272 { script_start_sections
(closure
); }
274 { script_finish_sections
(closure
); }
275 | TARGET_K
'(' string ')'
276 { script_set_target
(closure
, $3.value
, $3.length
); }
278 { script_push_lex_into_version_mode
(closure
); }
280 { script_pop_lex_mode
(closure
); }
281 | file_or_sections_cmd
286 /* Top level commands which we ignore. The GNU linker uses these to
287 select the output format, but we don't offer a choice. Ignoring
288 these is more-or-less OK since most scripts simply explicitly
289 choose the default. */
291 OUTPUT_ARCH
'(' string ')'
294 /* A list of external undefined symbols. We put the lexer into
295 expression mode so that commas separate names; this is what the GNU
299 { script_push_lex_into_expression_mode
(closure
); }
300 extern_name_list_body
301 { script_pop_lex_mode
(closure
); }
304 extern_name_list_body:
306 { script_add_extern
(closure
, $1.value
, $1.length
); }
307 | extern_name_list_body
string
308 { script_add_extern
(closure
, $2.value
, $2.length
); }
309 | extern_name_list_body
',' string
310 { script_add_extern
(closure
, $3.value
, $3.length
); }
313 /* A list of input file names. */
316 | input_list opt_comma input_list_element
319 /* An input file name. */
322 { script_add_file
(closure
, $1.value
, $1.length
); }
324 { script_start_as_needed
(closure
); }
326 { script_end_as_needed
(closure
); }
329 /* Commands in a SECTIONS block. */
331 sections_block section_block_cmd
335 /* A command which may appear within a SECTIONS block. */
338 |
string section_header
339 { script_start_output_section
(closure
, $1.value
, $1.length
, &$2); }
340 '{' section_cmds
'}' section_trailer
341 { script_finish_output_section
(closure
, &$7); }
344 /* The header of an output section in a SECTIONS block--everything
347 { script_push_lex_into_expression_mode
(closure
); }
348 opt_address_and_section_type opt_at opt_align opt_subalign
349 { script_pop_lex_mode
(closure
); }
352 $$.address
= $2.address
;
353 $$.section_type
= $2.section_type
;
354 $$.load_address
= $3;
361 /* The optional address followed by the optional section type. This
362 is a separate nonterminal to avoid a shift/reduce conflict on
363 '(' in section_header. */
365 opt_address_and_section_type:
369 $$.section_type
= SCRIPT_SECTION_TYPE_NONE
;
374 $$.section_type
= SCRIPT_SECTION_TYPE_NONE
;
379 $$.section_type
= SCRIPT_SECTION_TYPE_NONE
;
384 $$.section_type
= SCRIPT_SECTION_TYPE_NONE
;
386 |
'(' section_type
')' ':'
389 $$.section_type
= $2;
391 | exp
'(' section_type
')' ':'
394 $$.section_type
= $3;
398 /* We only support NOLOAD. */
401 { $$
= SCRIPT_SECTION_TYPE_NOLOAD
; }
404 yyerror(closure
, "DSECT section type is unsupported");
405 $$
= SCRIPT_SECTION_TYPE_DSECT
;
409 yyerror(closure
, "COPY section type is unsupported");
410 $$
= SCRIPT_SECTION_TYPE_COPY
;
414 yyerror(closure
, "INFO section type is unsupported");
415 $$
= SCRIPT_SECTION_TYPE_INFO
;
419 yyerror(closure
, "OVERLAY section type is unsupported");
420 $$
= SCRIPT_SECTION_TYPE_OVERLAY
;
424 /* The address at which an output section should be loaded. */
432 /* The alignment of an output section. */
436 | ALIGN_K
'(' exp
')'
440 /* The input section alignment within an output section. */
444 | SUBALIGN
'(' exp
')'
448 /* A section constraint. */
451 { $$
= CONSTRAINT_NONE
; }
453 { $$
= CONSTRAINT_ONLY_IF_RO
; }
455 { $$
= CONSTRAINT_ONLY_IF_RW
; }
457 { $$
= CONSTRAINT_SPECIAL
; }
460 /* The trailer of an output section in a SECTIONS block. */
462 opt_memspec opt_at_memspec opt_phdr opt_fill opt_comma
469 /* A memory specification for an output section. */
472 { yyerror(closure
, "memory regions are not supported"); }
476 /* A memory specification for where to load an output section. */
479 { yyerror(closure
, "memory regions are not supported"); }
483 /* The program segment an output section should go into. */
486 { $$
= script_string_list_push_back
($1, $3.value
, $3.length
); }
491 /* The value to use to fill an output section. FIXME: This does not
492 handle a string of arbitrary length. */
500 /* Commands which may appear within the description of an output
501 section in a SECTIONS block. */
504 | section_cmds section_cmd
507 /* A command which may appear within the description of an output
508 section in a SECTIONS block. */
512 | data_length
'(' parse_exp
')'
513 { script_add_data
(closure
, $1, $3); }
514 | ASSERT_K
'(' parse_exp
',' string ')'
515 { script_add_assertion
(closure
, $3, $5.value
, $5.length
); }
516 | FILL
'(' parse_exp
')'
517 { script_add_fill
(closure
, $3); }
520 /* The GNU linker uses CONSTRUCTORS for the a.out object
521 file format. It does nothing when using ELF. Since
522 some ELF linker scripts use it although it does
523 nothing, we accept it and ignore it. */
525 | SORT_BY_NAME
'(' CONSTRUCTORS
')'
529 /* The length of data which may appear within the description of an
530 output section in a SECTIONS block. */
544 /* An input section specification. This may appear within the
545 description of an output section in a SECTIONS block. */
547 input_section_no_keep
548 { script_add_input_section
(closure
, &$1, 0); }
549 | KEEP
'(' input_section_no_keep
')'
550 { script_add_input_section
(closure
, &$3, 1); }
553 /* An input section specification within a KEEP clause. */
554 input_section_no_keep:
558 $$.file.sort
= SORT_WILDCARD_NONE
;
559 $$.input_sections.sections
= NULL
;
560 $$.input_sections.exclude
= NULL
;
562 | wildcard_file
'(' wildcard_sections
')'
565 $$.input_sections
= $3;
569 /* A wildcard file specification. */
574 $$.sort
= SORT_WILDCARD_NONE
;
576 | SORT_BY_NAME
'(' wildcard_name
')'
579 $$.sort
= SORT_WILDCARD_BY_NAME
;
583 /* A list of wild card section specifications. */
585 wildcard_sections opt_comma wildcard_section
587 $$.sections
= script_string_sort_list_add
($1.sections
, &$3);
588 $$.exclude
= $1.exclude
;
592 $$.sections
= script_new_string_sort_list
(&$1);
595 | wildcard_sections opt_comma EXCLUDE_FILE
'(' exclude_names
')'
597 $$.sections
= $1.sections
;
598 $$.exclude
= script_string_list_append
($1.exclude
, $5);
600 | EXCLUDE_FILE
'(' exclude_names
')'
607 /* A single wild card specification. */
612 $$.sort
= SORT_WILDCARD_NONE
;
614 | SORT_BY_NAME
'(' wildcard_section
')'
619 case SORT_WILDCARD_NONE
:
620 $$.sort
= SORT_WILDCARD_BY_NAME
;
622 case SORT_WILDCARD_BY_NAME
:
623 case SORT_WILDCARD_BY_NAME_BY_ALIGNMENT
:
625 case SORT_WILDCARD_BY_ALIGNMENT
:
626 case SORT_WILDCARD_BY_ALIGNMENT_BY_NAME
:
627 $$.sort
= SORT_WILDCARD_BY_NAME_BY_ALIGNMENT
;
633 | SORT_BY_ALIGNMENT
'(' wildcard_section
')'
638 case SORT_WILDCARD_NONE
:
639 $$.sort
= SORT_WILDCARD_BY_ALIGNMENT
;
641 case SORT_WILDCARD_BY_ALIGNMENT
:
642 case SORT_WILDCARD_BY_ALIGNMENT_BY_NAME
:
644 case SORT_WILDCARD_BY_NAME
:
645 case SORT_WILDCARD_BY_NAME_BY_ALIGNMENT
:
646 $$.sort
= SORT_WILDCARD_BY_ALIGNMENT_BY_NAME
;
654 /* A list of file names to exclude. */
656 exclude_names opt_comma wildcard_name
657 { $$
= script_string_list_push_back
($1, $3.value
, $3.length
); }
659 { $$
= script_new_string_list
($1.value
, $1.length
); }
662 /* A single wildcard name. We recognize '*' and '?' specially since
663 they are expression tokens. */
679 /* A command which may appear at the top level of a linker script, or
680 within a SECTIONS block. */
681 file_or_sections_cmd:
683 { script_set_entry
(closure
, $3.value
, $3.length
); }
685 | ASSERT_K
'(' parse_exp
',' string ')'
686 { script_add_assertion
(closure
, $3, $5.value
, $5.length
); }
689 /* A list of program header definitions. */
695 /* A program header definition. */
697 string phdr_type phdr_info
';'
698 { script_add_phdr
(closure
, $1.value
, $1.length
, $2, &$3); }
701 /* A program header type. The GNU linker accepts a general expression
702 here, but that would be a pain because we would have to dig into
703 the expression structure. It's unlikely that anybody uses anything
704 other than a string or a number here, so that is all we expect. */
707 { $$
= script_phdr_string_to_type
(closure
, $1.value
, $1.length
); }
712 /* Additional information for a program header. */
715 { memset
(&$$
, 0, sizeof
(struct Phdr_info
)); }
719 if
($1.length
== 7 && strncmp
($1.value
, "FILEHDR", 7) == 0)
720 $$.includes_filehdr
= 1;
722 yyerror(closure
, "PHDRS syntax error");
727 $$.includes_phdrs
= 1;
729 |
string '(' INTEGER
')' phdr_info
732 if
($1.length
== 5 && strncmp
($1.value
, "FLAGS", 5) == 0)
734 $$.is_flags_valid
= 1;
738 yyerror(closure
, "PHDRS syntax error");
740 | AT
'(' parse_exp
')' phdr_info
743 $$.load_address
= $3;
747 /* Set a symbol to a value. */
750 { script_set_symbol
(closure
, $1.value
, $1.length
, $3, 0, 0); }
751 |
string PLUSEQ parse_exp
753 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
754 Expression_ptr e
= script_exp_binary_add
(s
, $3);
755 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
757 |
string MINUSEQ parse_exp
759 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
760 Expression_ptr e
= script_exp_binary_sub
(s
, $3);
761 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
763 |
string MULTEQ parse_exp
765 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
766 Expression_ptr e
= script_exp_binary_mult
(s
, $3);
767 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
769 |
string DIVEQ parse_exp
771 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
772 Expression_ptr e
= script_exp_binary_div
(s
, $3);
773 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
775 |
string LSHIFTEQ parse_exp
777 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
778 Expression_ptr e
= script_exp_binary_lshift
(s
, $3);
779 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
781 |
string RSHIFTEQ parse_exp
783 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
784 Expression_ptr e
= script_exp_binary_rshift
(s
, $3);
785 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
787 |
string ANDEQ parse_exp
789 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
790 Expression_ptr e
= script_exp_binary_bitwise_and
(s
, $3);
791 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
793 |
string OREQ parse_exp
795 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
796 Expression_ptr e
= script_exp_binary_bitwise_or
(s
, $3);
797 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
799 | PROVIDE
'(' string '=' parse_exp
')'
800 { script_set_symbol
(closure
, $3.value
, $3.length
, $5, 1, 0); }
801 | PROVIDE_HIDDEN
'(' string '=' parse_exp
')'
802 { script_set_symbol
(closure
, $3.value
, $3.length
, $5, 1, 1); }
805 /* Parse an expression, putting the lexer into the right mode. */
807 { script_push_lex_into_expression_mode
(closure
); }
810 script_pop_lex_mode
(closure
);
819 |
'-' exp %prec UNARY
820 { $$
= script_exp_unary_minus
($2); }
821 |
'!' exp %prec UNARY
822 { $$
= script_exp_unary_logical_not
($2); }
823 |
'~' exp %prec UNARY
824 { $$
= script_exp_unary_bitwise_not
($2); }
825 |
'+' exp %prec UNARY
828 { $$
= script_exp_binary_mult
($1, $3); }
830 { $$
= script_exp_binary_div
($1, $3); }
832 { $$
= script_exp_binary_mod
($1, $3); }
834 { $$
= script_exp_binary_add
($1, $3); }
836 { $$
= script_exp_binary_sub
($1, $3); }
838 { $$
= script_exp_binary_lshift
($1, $3); }
840 { $$
= script_exp_binary_rshift
($1, $3); }
842 { $$
= script_exp_binary_eq
($1, $3); }
844 { $$
= script_exp_binary_ne
($1, $3); }
846 { $$
= script_exp_binary_le
($1, $3); }
848 { $$
= script_exp_binary_ge
($1, $3); }
850 { $$
= script_exp_binary_lt
($1, $3); }
852 { $$
= script_exp_binary_gt
($1, $3); }
854 { $$
= script_exp_binary_bitwise_and
($1, $3); }
856 { $$
= script_exp_binary_bitwise_xor
($1, $3); }
858 { $$
= script_exp_binary_bitwise_or
($1, $3); }
860 { $$
= script_exp_binary_logical_and
($1, $3); }
862 { $$
= script_exp_binary_logical_or
($1, $3); }
863 | exp
'?' exp
':' exp
864 { $$
= script_exp_trinary_cond
($1, $3, $5); }
866 { $$
= script_exp_integer
($1); }
868 { $$
= script_exp_string
($1.value
, $1.length
); }
869 | MAX_K
'(' exp
',' exp
')'
870 { $$
= script_exp_function_max
($3, $5); }
871 | MIN_K
'(' exp
',' exp
')'
872 { $$
= script_exp_function_min
($3, $5); }
873 | DEFINED
'(' string ')'
874 { $$
= script_exp_function_defined
($3.value
, $3.length
); }
876 { $$
= script_exp_function_sizeof_headers
(); }
877 | ALIGNOF
'(' string ')'
878 { $$
= script_exp_function_alignof
($3.value
, $3.length
); }
879 | SIZEOF
'(' string ')'
880 { $$
= script_exp_function_sizeof
($3.value
, $3.length
); }
881 | ADDR
'(' string ')'
882 { $$
= script_exp_function_addr
($3.value
, $3.length
); }
883 | LOADADDR
'(' string ')'
884 { $$
= script_exp_function_loadaddr
($3.value
, $3.length
); }
885 | ORIGIN
'(' string ')'
886 { $$
= script_exp_function_origin
($3.value
, $3.length
); }
887 | LENGTH
'(' string ')'
888 { $$
= script_exp_function_length
($3.value
, $3.length
); }
889 | CONSTANT
'(' string ')'
890 { $$
= script_exp_function_constant
($3.value
, $3.length
); }
891 | ABSOLUTE
'(' exp
')'
892 { $$
= script_exp_function_absolute
($3); }
893 | ALIGN_K
'(' exp
')'
894 { $$
= script_exp_function_align
(script_exp_string
(".", 1), $3); }
895 | ALIGN_K
'(' exp
',' exp
')'
896 { $$
= script_exp_function_align
($3, $5); }
898 { $$
= script_exp_function_align
(script_exp_string
(".", 1), $3); }
899 | DATA_SEGMENT_ALIGN
'(' exp
',' exp
')'
901 script_data_segment_align
(closure
);
902 $$
= script_exp_function_data_segment_align
($3, $5);
904 | DATA_SEGMENT_RELRO_END
'(' exp
',' exp
')'
906 script_data_segment_relro_end
(closure
);
907 $$
= script_exp_function_data_segment_relro_end
($3, $5);
909 | DATA_SEGMENT_END
'(' exp
')'
910 { $$
= script_exp_function_data_segment_end
($3); }
911 | SEGMENT_START
'(' string ',' exp
')'
913 $$
= script_exp_function_segment_start
($3.value
, $3.length
, $5);
914 /* We need to take note of any SEGMENT_START expressions
915 because they change the behaviour of -Ttext, -Tdata and
917 script_saw_segment_start_expression
(closure
);
919 | ASSERT_K
'(' exp
',' string ')'
920 { $$
= script_exp_function_assert
($3, $5.value
, $5.length
); }
923 /* Handle the --defsym option. */
926 { script_set_symbol
(closure
, $1.value
, $1.length
, $3, 0, 0); }
929 /* Handle the --dynamic-list option. A dynamic list has the format
930 { sym1; sym2; extern "C++" { namespace::sym3 }; };
931 We store the symbol we see in the "local" list; that is where
932 Command_line::in_dynamic_list() will look to do its check.
933 TODO(csilvers): More than one of these brace-lists can appear, and
934 should just be merged and treated as a single list. */
935 dynamic_list_expr: dynamic_list_nodes
;
939 | dynamic_list_nodes dynamic_list_node
943 '{' vers_defns
';' '}' ';'
944 { script_new_vers_node
(closure
, NULL
, $2); }
947 /* A version script. */
954 | vers_nodes vers_node
960 script_register_vers_node
(closure
, NULL
, 0, $2, NULL
);
962 |
string '{' vers_tag
'}' ';'
964 script_register_vers_node
(closure
, $1.value
, $1.length
, $3,
967 |
string '{' vers_tag
'}' verdep
';'
969 script_register_vers_node
(closure
, $1.value
, $1.length
, $3, $5);
976 $$
= script_add_vers_depend
(closure
, NULL
, $1.value
, $1.length
);
980 $$
= script_add_vers_depend
(closure
, $1, $2.value
, $2.length
);
986 { $$
= script_new_vers_node
(closure
, NULL
, NULL
); }
988 { $$
= script_new_vers_node
(closure
, $1, NULL
); }
989 | GLOBAL
':' vers_defns
';'
990 { $$
= script_new_vers_node
(closure
, $3, NULL
); }
991 | LOCAL
':' vers_defns
';'
992 { $$
= script_new_vers_node
(closure
, NULL
, $3); }
993 | GLOBAL
':' vers_defns
';' LOCAL
':' vers_defns
';'
994 { $$
= script_new_vers_node
(closure
, $3, $7); }
997 /* Here is one of the rare places we care about the distinction
998 between STRING and QUOTED_STRING. For QUOTED_STRING, we do exact
999 matching on the pattern, so we pass in true for the exact_match
1000 parameter. For STRING, we do glob matching and pass in false. */
1004 $$
= script_new_vers_pattern
(closure
, NULL
, $1.value
,
1009 $$
= script_new_vers_pattern
(closure
, NULL
, $1.value
,
1012 | vers_defns
';' STRING
1014 $$
= script_new_vers_pattern
(closure
, $1, $3.value
,
1017 | vers_defns
';' QUOTED_STRING
1019 $$
= script_new_vers_pattern
(closure
, $1, $3.value
,
1022 |
/* Push string on the language stack. */
1024 { version_script_push_lang
(closure
, $2.value
, $2.length
); }
1025 vers_defns opt_semicolon
'}'
1028 version_script_pop_lang
(closure
);
1030 |
/* Push string on the language stack. This is more complicated
1031 than the other cases because we need to merge the linked-list
1032 state from the pre-EXTERN defns and the post-EXTERN defns. */
1033 vers_defns
';' EXTERN
string '{'
1034 { version_script_push_lang
(closure
, $4.value
, $4.length
); }
1035 vers_defns opt_semicolon
'}'
1037 $$
= script_merge_expressions
($1, $7);
1038 version_script_pop_lang
(closure
);
1040 | EXTERN
// "extern" as a symbol name
1042 $$
= script_new_vers_pattern
(closure
, NULL
, "extern",
1043 sizeof
("extern") - 1, 1);
1045 | vers_defns
';' EXTERN
1047 $$
= script_new_vers_pattern
(closure
, $1, "extern",
1048 sizeof
("extern") - 1, 1);
1052 /* A string can be either a STRING or a QUOTED_STRING. Almost all the
1053 time we don't care, and we use this rule. */
1061 /* Some statements require a terminator, which may be a semicolon or a
1068 /* An optional semicolon. */
1074 /* An optional comma. */