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
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
205 /* Non-terminal types, where needed. */
207 %type
<expr
> parse_exp exp
208 %type
<expr
> opt_at opt_align opt_subalign opt_fill
209 %type
<output_section_header
> section_header opt_address_and_section_type
210 %type
<section_type
> section_type
211 %type
<output_section_trailer
> section_trailer
212 %type
<constraint
> opt_constraint
213 %type
<string_list
> opt_phdr
214 %type
<integer
> data_length
215 %type
<input_section_spec
> input_section_no_keep
216 %type
<wildcard_sections
> wildcard_sections
217 %type
<wildcard_section
> wildcard_file wildcard_section
218 %type
<string_list
> exclude_names
219 %type
<string> wildcard_name
220 %type
<integer
> phdr_type memory_attr
221 %type
<phdr_info
> phdr_info
222 %type
<versyms
> vers_defns
223 %type
<versnode
> vers_tag
224 %type
<deplist
> verdep
225 %type
<string> string
229 /* Read the special token to see what to read next. */
231 PARSING_LINKER_SCRIPT linker_script
232 | PARSING_VERSION_SCRIPT version_script
233 | PARSING_DEFSYM defsym_expr
234 | PARSING_DYNAMIC_LIST dynamic_list_expr
237 /* A file contains a list of commands. */
239 linker_script file_cmd
243 /* A command which may appear at top level of a linker script. */
245 EXTERN
'(' extern_name_list
')'
246 | FORCE_COMMON_ALLOCATION
247 { script_set_common_allocation
(closure
, 1); }
249 { script_start_group
(closure
); }
251 { script_end_group
(closure
); }
252 | INHIBIT_COMMON_ALLOCATION
253 { script_set_common_allocation
(closure
, 0); }
254 | INPUT
'(' input_list
')'
255 | MEMORY
'{' memory_defs
'}'
256 | OPTION
'(' string ')'
257 { script_parse_option
(closure
, $3.value
, $3.length
); }
258 | OUTPUT_FORMAT
'(' string ')'
260 if
(!script_check_output_format
(closure
, $3.value
, $3.length
,
264 | OUTPUT_FORMAT
'(' string ',' string ',' string ')'
266 if
(!script_check_output_format
(closure
, $3.value
, $3.length
,
268 $7.value
, $7.length
))
271 | PHDRS
'{' phdrs_defs
'}'
272 | SEARCH_DIR
'(' string ')'
273 { script_add_search_dir
(closure
, $3.value
, $3.length
); }
275 { script_start_sections
(closure
); }
277 { script_finish_sections
(closure
); }
278 | TARGET_K
'(' string ')'
279 { script_set_target
(closure
, $3.value
, $3.length
); }
281 { script_push_lex_into_version_mode
(closure
); }
283 { script_pop_lex_mode
(closure
); }
284 | file_or_sections_cmd
289 /* Top level commands which we ignore. The GNU linker uses these to
290 select the output format, but we don't offer a choice. Ignoring
291 these is more-or-less OK since most scripts simply explicitly
292 choose the default. */
294 OUTPUT_ARCH
'(' string ')'
297 /* A list of external undefined symbols. We put the lexer into
298 expression mode so that commas separate names; this is what the GNU
302 { script_push_lex_into_expression_mode
(closure
); }
303 extern_name_list_body
304 { script_pop_lex_mode
(closure
); }
307 extern_name_list_body:
309 { script_add_extern
(closure
, $1.value
, $1.length
); }
310 | extern_name_list_body
string
311 { script_add_extern
(closure
, $2.value
, $2.length
); }
312 | extern_name_list_body
',' string
313 { script_add_extern
(closure
, $3.value
, $3.length
); }
316 /* A list of input file names. */
319 | input_list opt_comma input_list_element
322 /* An input file name. */
325 { script_add_file
(closure
, $1.value
, $1.length
); }
327 { script_add_library
(closure
, $2.value
, $2.length
); }
329 { script_start_as_needed
(closure
); }
331 { script_end_as_needed
(closure
); }
334 /* Commands in a SECTIONS block. */
336 sections_block section_block_cmd
340 /* A command which may appear within a SECTIONS block. */
343 |
string section_header
344 { script_start_output_section
(closure
, $1.value
, $1.length
, &$2); }
345 '{' section_cmds
'}' section_trailer
346 { script_finish_output_section
(closure
, &$7); }
349 /* The header of an output section in a SECTIONS block--everything
352 { script_push_lex_into_expression_mode
(closure
); }
353 opt_address_and_section_type opt_at opt_align opt_subalign
354 { script_pop_lex_mode
(closure
); }
357 $$.address
= $2.address
;
358 $$.section_type
= $2.section_type
;
359 $$.load_address
= $3;
366 /* The optional address followed by the optional section type. This
367 is a separate nonterminal to avoid a shift/reduce conflict on
368 '(' in section_header. */
370 opt_address_and_section_type:
374 $$.section_type
= SCRIPT_SECTION_TYPE_NONE
;
379 $$.section_type
= SCRIPT_SECTION_TYPE_NONE
;
384 $$.section_type
= SCRIPT_SECTION_TYPE_NONE
;
389 $$.section_type
= SCRIPT_SECTION_TYPE_NONE
;
391 |
'(' section_type
')' ':'
394 $$.section_type
= $2;
396 | exp
'(' section_type
')' ':'
399 $$.section_type
= $3;
403 /* We only support NOLOAD. */
406 { $$
= SCRIPT_SECTION_TYPE_NOLOAD
; }
409 yyerror(closure
, "DSECT section type is unsupported");
410 $$
= SCRIPT_SECTION_TYPE_DSECT
;
414 yyerror(closure
, "COPY section type is unsupported");
415 $$
= SCRIPT_SECTION_TYPE_COPY
;
419 yyerror(closure
, "INFO section type is unsupported");
420 $$
= SCRIPT_SECTION_TYPE_INFO
;
424 yyerror(closure
, "OVERLAY section type is unsupported");
425 $$
= SCRIPT_SECTION_TYPE_OVERLAY
;
429 /* The address at which an output section should be loaded. */
437 /* The alignment of an output section. */
441 | ALIGN_K
'(' exp
')'
445 /* The input section alignment within an output section. */
449 | SUBALIGN
'(' exp
')'
453 /* A section constraint. */
456 { $$
= CONSTRAINT_NONE
; }
458 { $$
= CONSTRAINT_ONLY_IF_RO
; }
460 { $$
= CONSTRAINT_ONLY_IF_RW
; }
462 { $$
= CONSTRAINT_SPECIAL
; }
465 /* The trailer of an output section in a SECTIONS block. */
467 opt_memspec opt_at_memspec opt_phdr opt_fill opt_comma
474 /* A memory specification for an output section. */
477 { script_set_section_region
(closure
, $2.value
, $2.length
, 1); }
481 /* A memory specification for where to load an output section. */
484 { script_set_section_region
(closure
, $3.value
, $3.length
, 0); }
488 /* The program segment an output section should go into. */
491 { $$
= script_string_list_push_back
($1, $3.value
, $3.length
); }
496 /* The value to use to fill an output section. FIXME: This does not
497 handle a string of arbitrary length. */
505 /* Commands which may appear within the description of an output
506 section in a SECTIONS block. */
509 | section_cmds section_cmd
512 /* A command which may appear within the description of an output
513 section in a SECTIONS block. */
517 | data_length
'(' parse_exp
')'
518 { script_add_data
(closure
, $1, $3); }
519 | ASSERT_K
'(' parse_exp
',' string ')'
520 { script_add_assertion
(closure
, $3, $5.value
, $5.length
); }
521 | FILL
'(' parse_exp
')'
522 { script_add_fill
(closure
, $3); }
525 /* The GNU linker uses CONSTRUCTORS for the a.out object
526 file format. It does nothing when using ELF. Since
527 some ELF linker scripts use it although it does
528 nothing, we accept it and ignore it. */
530 | SORT_BY_NAME
'(' CONSTRUCTORS
')'
534 /* The length of data which may appear within the description of an
535 output section in a SECTIONS block. */
549 /* An input section specification. This may appear within the
550 description of an output section in a SECTIONS block. */
552 input_section_no_keep
553 { script_add_input_section
(closure
, &$1, 0); }
554 | KEEP
'(' input_section_no_keep
')'
555 { script_add_input_section
(closure
, &$3, 1); }
558 /* An input section specification within a KEEP clause. */
559 input_section_no_keep:
563 $$.file.sort
= SORT_WILDCARD_NONE
;
564 $$.input_sections.sections
= NULL
;
565 $$.input_sections.exclude
= NULL
;
567 | wildcard_file
'(' wildcard_sections
')'
570 $$.input_sections
= $3;
574 /* A wildcard file specification. */
579 $$.sort
= SORT_WILDCARD_NONE
;
581 | SORT_BY_NAME
'(' wildcard_name
')'
584 $$.sort
= SORT_WILDCARD_BY_NAME
;
588 /* A list of wild card section specifications. */
590 wildcard_sections opt_comma wildcard_section
592 $$.sections
= script_string_sort_list_add
($1.sections
, &$3);
593 $$.exclude
= $1.exclude
;
597 $$.sections
= script_new_string_sort_list
(&$1);
600 | wildcard_sections opt_comma EXCLUDE_FILE
'(' exclude_names
')'
602 $$.sections
= $1.sections
;
603 $$.exclude
= script_string_list_append
($1.exclude
, $5);
605 | EXCLUDE_FILE
'(' exclude_names
')'
612 /* A single wild card specification. */
617 $$.sort
= SORT_WILDCARD_NONE
;
619 | SORT_BY_NAME
'(' wildcard_section
')'
624 case SORT_WILDCARD_NONE
:
625 $$.sort
= SORT_WILDCARD_BY_NAME
;
627 case SORT_WILDCARD_BY_NAME
:
628 case SORT_WILDCARD_BY_NAME_BY_ALIGNMENT
:
630 case SORT_WILDCARD_BY_ALIGNMENT
:
631 case SORT_WILDCARD_BY_ALIGNMENT_BY_NAME
:
632 $$.sort
= SORT_WILDCARD_BY_NAME_BY_ALIGNMENT
;
638 | SORT_BY_ALIGNMENT
'(' wildcard_section
')'
643 case SORT_WILDCARD_NONE
:
644 $$.sort
= SORT_WILDCARD_BY_ALIGNMENT
;
646 case SORT_WILDCARD_BY_ALIGNMENT
:
647 case SORT_WILDCARD_BY_ALIGNMENT_BY_NAME
:
649 case SORT_WILDCARD_BY_NAME
:
650 case SORT_WILDCARD_BY_NAME_BY_ALIGNMENT
:
651 $$.sort
= SORT_WILDCARD_BY_ALIGNMENT_BY_NAME
;
659 /* A list of file names to exclude. */
661 exclude_names opt_comma wildcard_name
662 { $$
= script_string_list_push_back
($1, $3.value
, $3.length
); }
664 { $$
= script_new_string_list
($1.value
, $1.length
); }
667 /* A single wildcard name. We recognize '*' and '?' specially since
668 they are expression tokens. */
684 /* A command which may appear at the top level of a linker script, or
685 within a SECTIONS block. */
686 file_or_sections_cmd:
688 { script_set_entry
(closure
, $3.value
, $3.length
); }
690 | ASSERT_K
'(' parse_exp
',' string ')'
691 { script_add_assertion
(closure
, $3, $5.value
, $5.length
); }
694 /* A list of MEMORY definitions. */
696 memory_defs opt_comma memory_def
700 /* A single MEMORY definition. */
702 string memory_attr
':' memory_origin
'=' parse_exp opt_comma memory_length
'=' parse_exp
703 { script_add_memory
(closure
, $1.value
, $1.length
, $2, $6, $10); }
705 /* LD supports an INCLUDE directive here, currently GOLD does not. */
707 { script_include_directive
(closure
, $2.value
, $2.length
); }
711 /* The (optional) attributes of a MEMORY region. */
714 { $$
= script_parse_memory_attr
(closure
, $2.value
, $2.length
, 0); }
715 |
/* Inverted attributes. */
717 { $$
= script_parse_memory_attr
(closure
, $3.value
, $3.length
, 1); }
738 /* A list of program header definitions. */
744 /* A program header definition. */
746 string phdr_type phdr_info
';'
747 { script_add_phdr
(closure
, $1.value
, $1.length
, $2, &$3); }
750 /* A program header type. The GNU linker accepts a general expression
751 here, but that would be a pain because we would have to dig into
752 the expression structure. It's unlikely that anybody uses anything
753 other than a string or a number here, so that is all we expect. */
756 { $$
= script_phdr_string_to_type
(closure
, $1.value
, $1.length
); }
761 /* Additional information for a program header. */
764 { memset
(&$$
, 0, sizeof
(struct Phdr_info
)); }
768 if
($1.length
== 7 && strncmp
($1.value
, "FILEHDR", 7) == 0)
769 $$.includes_filehdr
= 1;
771 yyerror(closure
, "PHDRS syntax error");
776 $$.includes_phdrs
= 1;
778 |
string '(' INTEGER
')' phdr_info
781 if
($1.length
== 5 && strncmp
($1.value
, "FLAGS", 5) == 0)
783 $$.is_flags_valid
= 1;
787 yyerror(closure
, "PHDRS syntax error");
789 | AT
'(' parse_exp
')' phdr_info
792 $$.load_address
= $3;
796 /* Set a symbol to a value. */
799 { script_set_symbol
(closure
, $1.value
, $1.length
, $3, 0, 0); }
800 |
string PLUSEQ parse_exp
802 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
803 Expression_ptr e
= script_exp_binary_add
(s
, $3);
804 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
806 |
string MINUSEQ parse_exp
808 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
809 Expression_ptr e
= script_exp_binary_sub
(s
, $3);
810 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
812 |
string MULTEQ parse_exp
814 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
815 Expression_ptr e
= script_exp_binary_mult
(s
, $3);
816 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
818 |
string DIVEQ parse_exp
820 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
821 Expression_ptr e
= script_exp_binary_div
(s
, $3);
822 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
824 |
string LSHIFTEQ parse_exp
826 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
827 Expression_ptr e
= script_exp_binary_lshift
(s
, $3);
828 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
830 |
string RSHIFTEQ parse_exp
832 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
833 Expression_ptr e
= script_exp_binary_rshift
(s
, $3);
834 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
836 |
string ANDEQ parse_exp
838 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
839 Expression_ptr e
= script_exp_binary_bitwise_and
(s
, $3);
840 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
842 |
string OREQ parse_exp
844 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
845 Expression_ptr e
= script_exp_binary_bitwise_or
(s
, $3);
846 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
848 | PROVIDE
'(' string '=' parse_exp
')'
849 { script_set_symbol
(closure
, $3.value
, $3.length
, $5, 1, 0); }
850 | PROVIDE_HIDDEN
'(' string '=' parse_exp
')'
851 { script_set_symbol
(closure
, $3.value
, $3.length
, $5, 1, 1); }
854 /* Parse an expression, putting the lexer into the right mode. */
856 { script_push_lex_into_expression_mode
(closure
); }
859 script_pop_lex_mode
(closure
);
868 |
'-' exp %prec UNARY
869 { $$
= script_exp_unary_minus
($2); }
870 |
'!' exp %prec UNARY
871 { $$
= script_exp_unary_logical_not
($2); }
872 |
'~' exp %prec UNARY
873 { $$
= script_exp_unary_bitwise_not
($2); }
874 |
'+' exp %prec UNARY
877 { $$
= script_exp_binary_mult
($1, $3); }
879 { $$
= script_exp_binary_div
($1, $3); }
881 { $$
= script_exp_binary_mod
($1, $3); }
883 { $$
= script_exp_binary_add
($1, $3); }
885 { $$
= script_exp_binary_sub
($1, $3); }
887 { $$
= script_exp_binary_lshift
($1, $3); }
889 { $$
= script_exp_binary_rshift
($1, $3); }
891 { $$
= script_exp_binary_eq
($1, $3); }
893 { $$
= script_exp_binary_ne
($1, $3); }
895 { $$
= script_exp_binary_le
($1, $3); }
897 { $$
= script_exp_binary_ge
($1, $3); }
899 { $$
= script_exp_binary_lt
($1, $3); }
901 { $$
= script_exp_binary_gt
($1, $3); }
903 { $$
= script_exp_binary_bitwise_and
($1, $3); }
905 { $$
= script_exp_binary_bitwise_xor
($1, $3); }
907 { $$
= script_exp_binary_bitwise_or
($1, $3); }
909 { $$
= script_exp_binary_logical_and
($1, $3); }
911 { $$
= script_exp_binary_logical_or
($1, $3); }
912 | exp
'?' exp
':' exp
913 { $$
= script_exp_trinary_cond
($1, $3, $5); }
915 { $$
= script_exp_integer
($1); }
917 { $$
= script_symbol
(closure
, $1.value
, $1.length
); }
918 | MAX_K
'(' exp
',' exp
')'
919 { $$
= script_exp_function_max
($3, $5); }
920 | MIN_K
'(' exp
',' exp
')'
921 { $$
= script_exp_function_min
($3, $5); }
922 | DEFINED
'(' string ')'
923 { $$
= script_exp_function_defined
($3.value
, $3.length
); }
925 { $$
= script_exp_function_sizeof_headers
(); }
926 | ALIGNOF
'(' string ')'
927 { $$
= script_exp_function_alignof
($3.value
, $3.length
); }
928 | SIZEOF
'(' string ')'
929 { $$
= script_exp_function_sizeof
($3.value
, $3.length
); }
930 | ADDR
'(' string ')'
931 { $$
= script_exp_function_addr
($3.value
, $3.length
); }
932 | LOADADDR
'(' string ')'
933 { $$
= script_exp_function_loadaddr
($3.value
, $3.length
); }
934 | ORIGIN
'(' string ')'
935 { $$
= script_exp_function_origin
(closure
, $3.value
, $3.length
); }
936 | LENGTH
'(' string ')'
937 { $$
= script_exp_function_length
(closure
, $3.value
, $3.length
); }
938 | CONSTANT
'(' string ')'
939 { $$
= script_exp_function_constant
($3.value
, $3.length
); }
940 | ABSOLUTE
'(' exp
')'
941 { $$
= script_exp_function_absolute
($3); }
942 | ALIGN_K
'(' exp
')'
943 { $$
= script_exp_function_align
(script_exp_string
(".", 1), $3); }
944 | ALIGN_K
'(' exp
',' exp
')'
945 { $$
= script_exp_function_align
($3, $5); }
947 { $$
= script_exp_function_align
(script_exp_string
(".", 1), $3); }
948 | DATA_SEGMENT_ALIGN
'(' exp
',' exp
')'
950 script_data_segment_align
(closure
);
951 $$
= script_exp_function_data_segment_align
($3, $5);
953 | DATA_SEGMENT_RELRO_END
'(' exp
',' exp
')'
955 script_data_segment_relro_end
(closure
);
956 $$
= script_exp_function_data_segment_relro_end
($3, $5);
958 | DATA_SEGMENT_END
'(' exp
')'
959 { $$
= script_exp_function_data_segment_end
($3); }
960 | SEGMENT_START
'(' string ',' exp
')'
962 $$
= script_exp_function_segment_start
($3.value
, $3.length
, $5);
963 /* We need to take note of any SEGMENT_START expressions
964 because they change the behaviour of -Ttext, -Tdata and
966 script_saw_segment_start_expression
(closure
);
968 | ASSERT_K
'(' exp
',' string ')'
969 { $$
= script_exp_function_assert
($3, $5.value
, $5.length
); }
972 /* Handle the --defsym option. */
975 { script_set_symbol
(closure
, $1.value
, $1.length
, $3, 0, 0); }
978 /* Handle the --dynamic-list option. A dynamic list has the format
979 { sym1; sym2; extern "C++" { namespace::sym3 }; };
980 We store the symbol we see in the "local" list; that is where
981 Command_line::in_dynamic_list() will look to do its check.
982 TODO(csilvers): More than one of these brace-lists can appear, and
983 should just be merged and treated as a single list. */
984 dynamic_list_expr: dynamic_list_nodes
;
988 | dynamic_list_nodes dynamic_list_node
992 '{' vers_defns
';' '}' ';'
993 { script_new_vers_node
(closure
, NULL
, $2); }
996 /* A version script. */
1003 | vers_nodes vers_node
1007 '{' vers_tag
'}' ';'
1009 script_register_vers_node
(closure
, NULL
, 0, $2, NULL
);
1011 |
string '{' vers_tag
'}' ';'
1013 script_register_vers_node
(closure
, $1.value
, $1.length
, $3,
1016 |
string '{' vers_tag
'}' verdep
';'
1018 script_register_vers_node
(closure
, $1.value
, $1.length
, $3, $5);
1025 $$
= script_add_vers_depend
(closure
, NULL
, $1.value
, $1.length
);
1029 $$
= script_add_vers_depend
(closure
, $1, $2.value
, $2.length
);
1035 { $$
= script_new_vers_node
(closure
, NULL
, NULL
); }
1037 { $$
= script_new_vers_node
(closure
, $1, NULL
); }
1038 | GLOBAL
':' vers_defns
';'
1039 { $$
= script_new_vers_node
(closure
, $3, NULL
); }
1040 | LOCAL
':' vers_defns
';'
1041 { $$
= script_new_vers_node
(closure
, NULL
, $3); }
1042 | GLOBAL
':' vers_defns
';' LOCAL
':' vers_defns
';'
1043 { $$
= script_new_vers_node
(closure
, $3, $7); }
1046 /* Here is one of the rare places we care about the distinction
1047 between STRING and QUOTED_STRING. For QUOTED_STRING, we do exact
1048 matching on the pattern, so we pass in true for the exact_match
1049 parameter. For STRING, we do glob matching and pass in false. */
1053 $$
= script_new_vers_pattern
(closure
, NULL
, $1.value
,
1058 $$
= script_new_vers_pattern
(closure
, NULL
, $1.value
,
1061 | vers_defns
';' STRING
1063 $$
= script_new_vers_pattern
(closure
, $1, $3.value
,
1066 | vers_defns
';' QUOTED_STRING
1068 $$
= script_new_vers_pattern
(closure
, $1, $3.value
,
1071 |
/* Push string on the language stack. */
1073 { version_script_push_lang
(closure
, $2.value
, $2.length
); }
1074 vers_defns opt_semicolon
'}'
1077 version_script_pop_lang
(closure
);
1079 |
/* Push string on the language stack. This is more complicated
1080 than the other cases because we need to merge the linked-list
1081 state from the pre-EXTERN defns and the post-EXTERN defns. */
1082 vers_defns
';' EXTERN
string '{'
1083 { version_script_push_lang
(closure
, $4.value
, $4.length
); }
1084 vers_defns opt_semicolon
'}'
1086 $$
= script_merge_expressions
($1, $7);
1087 version_script_pop_lang
(closure
);
1089 | EXTERN
// "extern" as a symbol name
1091 $$
= script_new_vers_pattern
(closure
, NULL
, "extern",
1092 sizeof
("extern") - 1, 1);
1094 | vers_defns
';' EXTERN
1096 $$
= script_new_vers_pattern
(closure
, $1, "extern",
1097 sizeof
("extern") - 1, 1);
1101 /* A string can be either a STRING or a QUOTED_STRING. Almost all the
1102 time we don't care, and we use this rule. */
1110 /* Some statements require a terminator, which may be a semicolon or a
1117 /* An optional semicolon. */
1123 /* An optional comma. */