1 /* yyscript.y -- linker script grammar for gold. */
3 /* Copyright (C) 2006-2019 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 */
143 %token INHIBIT_COMMON_ALLOCATION
148 %token LENGTH
/* LENGTH, l, len */
150 %token LOCAL
/* local */
153 %token MAX_K
/* MAX */
155 %token MIN_K
/* MIN */
163 %token ORIGIN
/* ORIGIN, o, org */
170 %token PROVIDE_HIDDEN
177 %token SIZEOF_HEADERS
/* SIZEOF_HEADERS, sizeof_headers */
178 %token SORT_BY_ALIGNMENT
179 %token SORT_BY_INIT_PRIORITY
186 %token TARGET_K
/* TARGET */
188 %token VERSIONK
/* VERSION */
190 /* Keywords, part 2. These are keywords that are unique to gold,
191 and not present in the old GNU linker. As before, unless the
192 comments say otherwise, the keyword is recognized as the token
193 name in upper case. */
197 /* Special tokens used to tell the grammar what type of tokens we are
198 parsing. The token stream always begins with one of these tokens.
199 We do this because version scripts can appear embedded within
200 linker scripts, and because --defsym uses the expression
202 %token PARSING_LINKER_SCRIPT
203 %token PARSING_VERSION_SCRIPT
204 %token PARSING_DEFSYM
205 %token PARSING_DYNAMIC_LIST
206 %token PARSING_SECTIONS_BLOCK
207 %token PARSING_SECTION_COMMANDS
208 %token PARSING_MEMORY_DEF
210 /* Non-terminal types, where needed. */
212 %type
<expr
> parse_exp exp
213 %type
<expr
> opt_at opt_align opt_subalign opt_fill
214 %type
<output_section_header
> section_header opt_address_and_section_type
215 %type
<section_type
> section_type
216 %type
<output_section_trailer
> section_trailer
217 %type
<constraint
> opt_constraint
218 %type
<string_list
> opt_phdr
219 %type
<integer
> data_length
220 %type
<input_section_spec
> input_section_no_keep
221 %type
<wildcard_sections
> wildcard_sections
222 %type
<wildcard_section
> wildcard_file wildcard_section
223 %type
<string_list
> exclude_names
224 %type
<string> wildcard_name
225 %type
<integer
> phdr_type memory_attr
226 %type
<phdr_info
> phdr_info
227 %type
<versyms
> vers_defns
228 %type
<versnode
> vers_tag
229 %type
<deplist
> verdep
230 %type
<string> string
234 /* Read the special token to see what to read next. */
236 PARSING_LINKER_SCRIPT linker_script
237 | PARSING_VERSION_SCRIPT version_script
238 | PARSING_DEFSYM defsym_expr
239 | PARSING_DYNAMIC_LIST dynamic_list_expr
240 | PARSING_SECTIONS_BLOCK sections_block
241 | PARSING_SECTION_COMMANDS section_cmds
242 | PARSING_MEMORY_DEF memory_defs
245 /* A file contains a list of commands. */
247 linker_script file_cmd
251 /* A command which may appear at top level of a linker script. */
253 EXTERN
'(' extern_name_list
')'
254 | FORCE_COMMON_ALLOCATION
255 { script_set_common_allocation
(closure
, 1); }
257 { script_start_group
(closure
); }
259 { script_end_group
(closure
); }
260 | INHIBIT_COMMON_ALLOCATION
261 { script_set_common_allocation
(closure
, 0); }
262 | INPUT
'(' input_list
')'
263 | MEMORY
'{' memory_defs
'}'
264 | OPTION
'(' string ')'
265 { script_parse_option
(closure
, $3.value
, $3.length
); }
266 | OUTPUT_FORMAT
'(' string ')'
268 if
(!script_check_output_format
(closure
, $3.value
, $3.length
,
272 | OUTPUT_FORMAT
'(' string ',' string ',' string ')'
274 if
(!script_check_output_format
(closure
, $3.value
, $3.length
,
276 $7.value
, $7.length
))
279 | PHDRS
'{' phdrs_defs
'}'
280 | SEARCH_DIR
'(' string ')'
281 { script_add_search_dir
(closure
, $3.value
, $3.length
); }
283 { script_start_sections
(closure
); }
285 { script_finish_sections
(closure
); }
286 | TARGET_K
'(' string ')'
287 { script_set_target
(closure
, $3.value
, $3.length
); }
289 { script_push_lex_into_version_mode
(closure
); }
291 { script_pop_lex_mode
(closure
); }
292 | ENTRY
'(' string ')'
293 { script_set_entry
(closure
, $3.value
, $3.length
); }
295 | ASSERT_K
'(' parse_exp
',' string ')'
296 { script_add_assertion
(closure
, $3, $5.value
, $5.length
); }
298 { script_include_directive
(PARSING_LINKER_SCRIPT
, closure
,
299 $2.value
, $2.length
); }
304 /* Top level commands which we ignore. The GNU linker uses these to
305 select the output format, but we don't offer a choice. Ignoring
306 these is more-or-less OK since most scripts simply explicitly
307 choose the default. */
309 OUTPUT_ARCH
'(' string ')'
312 /* A list of external undefined symbols. We put the lexer into
313 expression mode so that commas separate names; this is what the GNU
317 { script_push_lex_into_expression_mode
(closure
); }
318 extern_name_list_body
319 { script_pop_lex_mode
(closure
); }
322 extern_name_list_body:
324 { script_add_extern
(closure
, $1.value
, $1.length
); }
325 | extern_name_list_body
string
326 { script_add_extern
(closure
, $2.value
, $2.length
); }
327 | extern_name_list_body
',' string
328 { script_add_extern
(closure
, $3.value
, $3.length
); }
331 /* A list of input file names. */
334 | input_list opt_comma input_list_element
337 /* An input file name. */
340 { script_add_file
(closure
, $1.value
, $1.length
); }
342 { script_add_library
(closure
, $2.value
, $2.length
); }
344 { script_start_as_needed
(closure
); }
346 { script_end_as_needed
(closure
); }
349 /* Commands in a SECTIONS block. */
351 sections_block section_block_cmd
355 /* A command which may appear within a SECTIONS block. */
358 { script_set_entry
(closure
, $3.value
, $3.length
); }
360 | ASSERT_K
'(' parse_exp
',' string ')'
361 { script_add_assertion
(closure
, $3, $5.value
, $5.length
); }
363 { script_include_directive
(PARSING_SECTIONS_BLOCK
, closure
,
364 $2.value
, $2.length
); }
365 |
string section_header
366 { script_start_output_section
(closure
, $1.value
, $1.length
, &$2); }
367 '{' section_cmds
'}' section_trailer
368 { script_finish_output_section
(closure
, &$7); }
371 /* The header of an output section in a SECTIONS block--everything
374 { script_push_lex_into_expression_mode
(closure
); }
375 opt_address_and_section_type opt_at opt_align opt_subalign
376 { script_pop_lex_mode
(closure
); }
379 $$.address
= $2.address
;
380 $$.section_type
= $2.section_type
;
381 $$.load_address
= $3;
388 /* The optional address followed by the optional section type. This
389 is a separate nonterminal to avoid a shift/reduce conflict on
390 '(' in section_header. */
392 opt_address_and_section_type:
396 $$.section_type
= SCRIPT_SECTION_TYPE_NONE
;
401 $$.section_type
= SCRIPT_SECTION_TYPE_NONE
;
406 $$.section_type
= SCRIPT_SECTION_TYPE_NONE
;
411 $$.section_type
= SCRIPT_SECTION_TYPE_NONE
;
413 |
'(' section_type
')' ':'
416 $$.section_type
= $2;
418 | exp
'(' section_type
')' ':'
421 $$.section_type
= $3;
425 /* We only support NOLOAD. */
428 { $$
= SCRIPT_SECTION_TYPE_NOLOAD
; }
431 yyerror(closure
, "DSECT section type is unsupported");
432 $$
= SCRIPT_SECTION_TYPE_DSECT
;
436 yyerror(closure
, "COPY section type is unsupported");
437 $$
= SCRIPT_SECTION_TYPE_COPY
;
441 yyerror(closure
, "INFO section type is unsupported");
442 $$
= SCRIPT_SECTION_TYPE_INFO
;
446 yyerror(closure
, "OVERLAY section type is unsupported");
447 $$
= SCRIPT_SECTION_TYPE_OVERLAY
;
451 /* The address at which an output section should be loaded. */
459 /* The alignment of an output section. */
463 | ALIGN_K
'(' exp
')'
467 /* The input section alignment within an output section. */
471 | SUBALIGN
'(' exp
')'
475 /* A section constraint. */
478 { $$
= CONSTRAINT_NONE
; }
480 { $$
= CONSTRAINT_ONLY_IF_RO
; }
482 { $$
= CONSTRAINT_ONLY_IF_RW
; }
484 { $$
= CONSTRAINT_SPECIAL
; }
487 /* The trailer of an output section in a SECTIONS block. */
489 opt_memspec opt_at_memspec opt_phdr opt_fill opt_comma
496 /* A memory specification for an output section. */
499 { script_set_section_region
(closure
, $2.value
, $2.length
, 1); }
503 /* A memory specification for where to load an output section. */
506 { script_set_section_region
(closure
, $3.value
, $3.length
, 0); }
510 /* The program segment an output section should go into. */
513 { $$
= script_string_list_push_back
($1, $3.value
, $3.length
); }
518 /* The value to use to fill an output section. FIXME: This does not
519 handle a string of arbitrary length. */
527 /* Commands which may appear within the description of an output
528 section in a SECTIONS block. */
531 | section_cmds section_cmd
534 /* A command which may appear within the description of an output
535 section in a SECTIONS block. */
539 | data_length
'(' parse_exp
')'
540 { script_add_data
(closure
, $1, $3); }
541 | ASSERT_K
'(' parse_exp
',' string ')'
542 { script_add_assertion
(closure
, $3, $5.value
, $5.length
); }
543 | FILL
'(' parse_exp
')'
544 { script_add_fill
(closure
, $3); }
547 /* The GNU linker uses CONSTRUCTORS for the a.out object
548 file format. It does nothing when using ELF. Since
549 some ELF linker scripts use it although it does
550 nothing, we accept it and ignore it. */
552 | SORT_BY_NAME
'(' CONSTRUCTORS
')'
554 { script_include_directive
(PARSING_SECTION_COMMANDS
, closure
,
555 $2.value
, $2.length
); }
559 /* The length of data which may appear within the description of an
560 output section in a SECTIONS block. */
574 /* An input section specification. This may appear within the
575 description of an output section in a SECTIONS block. */
577 input_section_no_keep
578 { script_add_input_section
(closure
, &$1, 0); }
579 | KEEP
'(' input_section_no_keep
')'
580 { script_add_input_section
(closure
, &$3, 1); }
583 /* An input section specification within a KEEP clause. */
584 input_section_no_keep:
588 $$.file.sort
= SORT_WILDCARD_NONE
;
589 $$.input_sections.sections
= NULL
;
590 $$.input_sections.exclude
= NULL
;
592 | wildcard_file
'(' wildcard_sections
')'
595 $$.input_sections
= $3;
599 /* A wildcard file specification. */
604 $$.sort
= SORT_WILDCARD_NONE
;
606 | SORT_BY_NAME
'(' wildcard_name
')'
609 $$.sort
= SORT_WILDCARD_BY_NAME
;
613 /* A list of wild card section specifications. */
615 wildcard_sections opt_comma wildcard_section
617 $$.sections
= script_string_sort_list_add
($1.sections
, &$3);
618 $$.exclude
= $1.exclude
;
622 $$.sections
= script_new_string_sort_list
(&$1);
625 | wildcard_sections opt_comma EXCLUDE_FILE
'(' exclude_names
')'
627 $$.sections
= $1.sections
;
628 $$.exclude
= script_string_list_append
($1.exclude
, $5);
630 | EXCLUDE_FILE
'(' exclude_names
')'
637 /* A single wild card specification. */
642 $$.sort
= SORT_WILDCARD_NONE
;
644 | SORT_BY_NAME
'(' wildcard_section
')'
649 case SORT_WILDCARD_NONE
:
650 $$.sort
= SORT_WILDCARD_BY_NAME
;
652 case SORT_WILDCARD_BY_NAME
:
653 case SORT_WILDCARD_BY_NAME_BY_ALIGNMENT
:
655 case SORT_WILDCARD_BY_ALIGNMENT
:
656 case SORT_WILDCARD_BY_ALIGNMENT_BY_NAME
:
657 $$.sort
= SORT_WILDCARD_BY_NAME_BY_ALIGNMENT
;
663 | SORT_BY_ALIGNMENT
'(' wildcard_section
')'
668 case SORT_WILDCARD_NONE
:
669 $$.sort
= SORT_WILDCARD_BY_ALIGNMENT
;
671 case SORT_WILDCARD_BY_ALIGNMENT
:
672 case SORT_WILDCARD_BY_ALIGNMENT_BY_NAME
:
674 case SORT_WILDCARD_BY_NAME
:
675 case SORT_WILDCARD_BY_NAME_BY_ALIGNMENT
:
676 $$.sort
= SORT_WILDCARD_BY_ALIGNMENT_BY_NAME
;
682 | SORT_BY_INIT_PRIORITY
'(' wildcard_name
')'
685 $$.sort
= SORT_WILDCARD_BY_INIT_PRIORITY
;
689 /* A list of file names to exclude. */
691 exclude_names opt_comma wildcard_name
692 { $$
= script_string_list_push_back
($1, $3.value
, $3.length
); }
694 { $$
= script_new_string_list
($1.value
, $1.length
); }
697 /* A single wildcard name. We recognize '*' and '?' specially since
698 they are expression tokens. */
714 /* A list of MEMORY definitions. */
716 memory_defs opt_comma memory_def
720 /* A single MEMORY definition. */
722 string memory_attr
':' memory_origin
'=' parse_exp opt_comma memory_length
'=' parse_exp
723 { script_add_memory
(closure
, $1.value
, $1.length
, $2, $6, $10); }
726 { script_include_directive
(PARSING_MEMORY_DEF
, closure
,
727 $2.value
, $2.length
); }
731 /* The (optional) attributes of a MEMORY region. */
734 { $$
= script_parse_memory_attr
(closure
, $2.value
, $2.length
, 0); }
735 |
/* Inverted attributes. */
737 { $$
= script_parse_memory_attr
(closure
, $3.value
, $3.length
, 1); }
758 /* A list of program header definitions. */
764 /* A program header definition. */
766 string phdr_type phdr_info
';'
767 { script_add_phdr
(closure
, $1.value
, $1.length
, $2, &$3); }
770 /* A program header type. The GNU linker accepts a general expression
771 here, but that would be a pain because we would have to dig into
772 the expression structure. It's unlikely that anybody uses anything
773 other than a string or a number here, so that is all we expect. */
776 { $$
= script_phdr_string_to_type
(closure
, $1.value
, $1.length
); }
781 /* Additional information for a program header. */
784 { memset
(&$$
, 0, sizeof
(struct Phdr_info
)); }
788 if
($1.length
== 7 && strncmp
($1.value
, "FILEHDR", 7) == 0)
789 $$.includes_filehdr
= 1;
791 yyerror(closure
, "PHDRS syntax error");
796 $$.includes_phdrs
= 1;
798 |
string '(' INTEGER
')' phdr_info
801 if
($1.length
== 5 && strncmp
($1.value
, "FLAGS", 5) == 0)
803 $$.is_flags_valid
= 1;
807 yyerror(closure
, "PHDRS syntax error");
809 | AT
'(' parse_exp
')' phdr_info
812 $$.load_address
= $3;
816 /* Set a symbol to a value. */
819 { script_set_symbol
(closure
, $1.value
, $1.length
, $3, 0, 0); }
820 |
string PLUSEQ parse_exp
822 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
823 Expression_ptr e
= script_exp_binary_add
(s
, $3);
824 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
826 |
string MINUSEQ parse_exp
828 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
829 Expression_ptr e
= script_exp_binary_sub
(s
, $3);
830 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
832 |
string MULTEQ parse_exp
834 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
835 Expression_ptr e
= script_exp_binary_mult
(s
, $3);
836 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
838 |
string DIVEQ parse_exp
840 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
841 Expression_ptr e
= script_exp_binary_div
(s
, $3);
842 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
844 |
string LSHIFTEQ parse_exp
846 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
847 Expression_ptr e
= script_exp_binary_lshift
(s
, $3);
848 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
850 |
string RSHIFTEQ parse_exp
852 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
853 Expression_ptr e
= script_exp_binary_rshift
(s
, $3);
854 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
856 |
string ANDEQ parse_exp
858 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
859 Expression_ptr e
= script_exp_binary_bitwise_and
(s
, $3);
860 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
862 |
string OREQ parse_exp
864 Expression_ptr s
= script_exp_string
($1.value
, $1.length
);
865 Expression_ptr e
= script_exp_binary_bitwise_or
(s
, $3);
866 script_set_symbol
(closure
, $1.value
, $1.length
, e
, 0, 0);
868 | HIDDEN
'(' string '=' parse_exp
')'
869 { script_set_symbol
(closure
, $3.value
, $3.length
, $5, 0, 1); }
870 | PROVIDE
'(' string '=' parse_exp
')'
871 { script_set_symbol
(closure
, $3.value
, $3.length
, $5, 1, 0); }
872 | PROVIDE_HIDDEN
'(' string '=' parse_exp
')'
873 { script_set_symbol
(closure
, $3.value
, $3.length
, $5, 1, 1); }
876 /* Parse an expression, putting the lexer into the right mode. */
878 { script_push_lex_into_expression_mode
(closure
); }
881 script_pop_lex_mode
(closure
);
890 |
'-' exp %prec UNARY
891 { $$
= script_exp_unary_minus
($2); }
892 |
'!' exp %prec UNARY
893 { $$
= script_exp_unary_logical_not
($2); }
894 |
'~' exp %prec UNARY
895 { $$
= script_exp_unary_bitwise_not
($2); }
896 |
'+' exp %prec UNARY
899 { $$
= script_exp_binary_mult
($1, $3); }
901 { $$
= script_exp_binary_div
($1, $3); }
903 { $$
= script_exp_binary_mod
($1, $3); }
905 { $$
= script_exp_binary_add
($1, $3); }
907 { $$
= script_exp_binary_sub
($1, $3); }
909 { $$
= script_exp_binary_lshift
($1, $3); }
911 { $$
= script_exp_binary_rshift
($1, $3); }
913 { $$
= script_exp_binary_eq
($1, $3); }
915 { $$
= script_exp_binary_ne
($1, $3); }
917 { $$
= script_exp_binary_le
($1, $3); }
919 { $$
= script_exp_binary_ge
($1, $3); }
921 { $$
= script_exp_binary_lt
($1, $3); }
923 { $$
= script_exp_binary_gt
($1, $3); }
925 { $$
= script_exp_binary_bitwise_and
($1, $3); }
927 { $$
= script_exp_binary_bitwise_xor
($1, $3); }
929 { $$
= script_exp_binary_bitwise_or
($1, $3); }
931 { $$
= script_exp_binary_logical_and
($1, $3); }
933 { $$
= script_exp_binary_logical_or
($1, $3); }
934 | exp
'?' exp
':' exp
935 { $$
= script_exp_trinary_cond
($1, $3, $5); }
937 { $$
= script_exp_integer
($1); }
939 { $$
= script_symbol
(closure
, $1.value
, $1.length
); }
940 | MAX_K
'(' exp
',' exp
')'
941 { $$
= script_exp_function_max
($3, $5); }
942 | MIN_K
'(' exp
',' exp
')'
943 { $$
= script_exp_function_min
($3, $5); }
944 | DEFINED
'(' string ')'
945 { $$
= script_exp_function_defined
($3.value
, $3.length
); }
947 { $$
= script_exp_function_sizeof_headers
(); }
948 | ALIGNOF
'(' string ')'
949 { $$
= script_exp_function_alignof
($3.value
, $3.length
); }
950 | SIZEOF
'(' string ')'
951 { $$
= script_exp_function_sizeof
($3.value
, $3.length
); }
952 | ADDR
'(' string ')'
953 { $$
= script_exp_function_addr
($3.value
, $3.length
); }
954 | LOADADDR
'(' string ')'
955 { $$
= script_exp_function_loadaddr
($3.value
, $3.length
); }
956 | ORIGIN
'(' string ')'
957 { $$
= script_exp_function_origin
(closure
, $3.value
, $3.length
); }
958 | LENGTH
'(' string ')'
959 { $$
= script_exp_function_length
(closure
, $3.value
, $3.length
); }
960 | CONSTANT
'(' string ')'
961 { $$
= script_exp_function_constant
($3.value
, $3.length
); }
962 | ABSOLUTE
'(' exp
')'
963 { $$
= script_exp_function_absolute
($3); }
964 | ALIGN_K
'(' exp
')'
965 { $$
= script_exp_function_align
(script_exp_string
(".", 1), $3); }
966 | ALIGN_K
'(' exp
',' exp
')'
967 { $$
= script_exp_function_align
($3, $5); }
969 { $$
= script_exp_function_align
(script_exp_string
(".", 1), $3); }
970 | DATA_SEGMENT_ALIGN
'(' exp
',' exp
')'
972 script_data_segment_align
(closure
);
973 $$
= script_exp_function_data_segment_align
($3, $5);
975 | DATA_SEGMENT_RELRO_END
'(' exp
',' exp
')'
977 script_data_segment_relro_end
(closure
);
978 $$
= script_exp_function_data_segment_relro_end
($3, $5);
980 | DATA_SEGMENT_END
'(' exp
')'
981 { $$
= script_exp_function_data_segment_end
($3); }
982 | SEGMENT_START
'(' string ',' exp
')'
984 $$
= script_exp_function_segment_start
($3.value
, $3.length
, $5);
985 /* We need to take note of any SEGMENT_START expressions
986 because they change the behaviour of -Ttext, -Tdata and
988 script_saw_segment_start_expression
(closure
);
990 | ASSERT_K
'(' exp
',' string ')'
991 { $$
= script_exp_function_assert
($3, $5.value
, $5.length
); }
994 /* Handle the --defsym option. */
997 { script_set_symbol
(closure
, $1.value
, $1.length
, $3, 0, 0); }
1000 /* Handle the --dynamic-list option. A dynamic list has the format
1001 { sym1; sym2; extern "C++" { namespace::sym3 }; };
1002 We store the symbol we see in the "local" list; that is where
1003 Command_line::in_dynamic_list() will look to do its check.
1004 TODO(csilvers): More than one of these brace-lists can appear, and
1005 should just be merged and treated as a single list. */
1006 dynamic_list_expr: dynamic_list_nodes
;
1010 | dynamic_list_nodes dynamic_list_node
1014 '{' vers_defns
';' '}' ';'
1015 { script_new_vers_node
(closure
, NULL
, $2); }
1018 /* A version script. */
1025 | vers_nodes vers_node
1029 '{' vers_tag
'}' ';'
1031 script_register_vers_node
(closure
, NULL
, 0, $2, NULL
);
1033 |
string '{' vers_tag
'}' ';'
1035 script_register_vers_node
(closure
, $1.value
, $1.length
, $3,
1038 |
string '{' vers_tag
'}' verdep
';'
1040 script_register_vers_node
(closure
, $1.value
, $1.length
, $3, $5);
1047 $$
= script_add_vers_depend
(closure
, NULL
, $1.value
, $1.length
);
1051 $$
= script_add_vers_depend
(closure
, $1, $2.value
, $2.length
);
1057 { $$
= script_new_vers_node
(closure
, NULL
, NULL
); }
1059 { $$
= script_new_vers_node
(closure
, $1, NULL
); }
1060 | GLOBAL
':' vers_defns
';'
1061 { $$
= script_new_vers_node
(closure
, $3, NULL
); }
1062 | LOCAL
':' vers_defns
';'
1063 { $$
= script_new_vers_node
(closure
, NULL
, $3); }
1064 | GLOBAL
':' vers_defns
';' LOCAL
':' vers_defns
';'
1065 { $$
= script_new_vers_node
(closure
, $3, $7); }
1068 /* Here is one of the rare places we care about the distinction
1069 between STRING and QUOTED_STRING. For QUOTED_STRING, we do exact
1070 matching on the pattern, so we pass in true for the exact_match
1071 parameter. For STRING, we do glob matching and pass in false. */
1075 $$
= script_new_vers_pattern
(closure
, NULL
, $1.value
,
1080 $$
= script_new_vers_pattern
(closure
, NULL
, $1.value
,
1083 | vers_defns
';' STRING
1085 $$
= script_new_vers_pattern
(closure
, $1, $3.value
,
1088 | vers_defns
';' QUOTED_STRING
1090 $$
= script_new_vers_pattern
(closure
, $1, $3.value
,
1093 |
/* Push string on the language stack. */
1095 { version_script_push_lang
(closure
, $2.value
, $2.length
); }
1096 vers_defns opt_semicolon
'}'
1099 version_script_pop_lang
(closure
);
1101 |
/* Push string on the language stack. This is more complicated
1102 than the other cases because we need to merge the linked-list
1103 state from the pre-EXTERN defns and the post-EXTERN defns. */
1104 vers_defns
';' EXTERN
string '{'
1105 { version_script_push_lang
(closure
, $4.value
, $4.length
); }
1106 vers_defns opt_semicolon
'}'
1108 $$
= script_merge_expressions
($1, $7);
1109 version_script_pop_lang
(closure
);
1111 | EXTERN
// "extern" as a symbol name
1113 $$
= script_new_vers_pattern
(closure
, NULL
, "extern",
1114 sizeof
("extern") - 1, 1);
1116 | vers_defns
';' EXTERN
1118 $$
= script_new_vers_pattern
(closure
, $1, "extern",
1119 sizeof
("extern") - 1, 1);
1123 /* A string can be either a STRING or a QUOTED_STRING. Almost all the
1124 time we don't care, and we use this rule. */
1132 /* Some statements require a terminator, which may be a semicolon or a
1139 /* An optional semicolon. */
1145 /* An optional comma. */