1 /* A YACC grammar to parse a superset of the AT&T linker scripting language.
2 Copyright (C) 1991-2024 Free Software Foundation, Inc.
3 Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
5 This file is part of the GNU Binutils.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
27 #define DONTDECLARE_MALLOC
30 #include "libiberty.h"
50 static enum section_type sectype
;
51 static etree_type
*sectype_value
;
52 static lang_memory_region_type
*region
;
54 static bool ldgram_had_keep
= false
;
55 static char *ldgram_vers_current_lang
= NULL
;
57 #define ERROR_NAME_MAX 20
58 static char *error_names
[ERROR_NAME_MAX
];
59 static int error_index
;
60 #define PUSH_ERROR(x) if (error_index < ERROR_NAME_MAX) error_names[error_index] = x; error_index++;
61 #define POP_ERROR() error_index--;
63 static void yyerror (const char *);
75 struct wildcard_spec wildcard
;
76 struct wildcard_list
*wildcard_list
;
77 struct name_list
*name_list
;
78 struct flag_info_list
*flag_info_list
;
79 struct flag_info
*flag_info
;
81 union etree_union
*etree
;
86 union etree_union
*at
;
87 union etree_union
*flags
;
89 struct lang_nocrossref
*nocrossref
;
90 struct lang_output_section_phdr_list
*section_phdr
;
91 struct bfd_elf_version_deps
*deflist
;
92 struct bfd_elf_version_expr
*versyms
;
93 struct bfd_elf_version_tree
*versnode
;
96 %type
<etree
> exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val
97 %type
<etree
> opt_exp_without_type opt_subalign opt_align
98 %type
<fill
> fill_opt fill_exp
99 %type
<name_list
> exclude_name_list
100 %type
<wildcard_list
> section_name_list
101 %type
<flag_info_list
> sect_flag_list
102 %type
<flag_info
> sect_flags
103 %type
<name
> memspec_opt memspec_at_opt paren_script_name casesymlist
104 %type
<cname
> wildcard_name
105 %type
<wildcard
> section_name_spec filename_spec wildcard_maybe_exclude wildcard_maybe_reverse
107 %token
<name
> NAME LNAME
108 %type
<integer
> length
109 %type
<phdr
> phdr_qualifiers
110 %type
<nocrossref
> nocrossref_list
111 %type
<section_phdr
> phdr_opt
112 %type
<integer
> opt_nocrossrefs
114 %right
<token
> PLUSEQ MINUSEQ MULTEQ DIVEQ
'=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ XOREQ
115 %right
<token
> '?' ':'
122 %left
<token
> '<' '>' LE GE
123 %left
<token
> LSHIFT RSHIFT
125 %left
<token
> '+' '-'
126 %left
<token
> '*' '/' '%'
131 %token
<token
> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE ASCIZ
132 %token SECTIONS PHDRS INSERT_K AFTER BEFORE LINKER_VERSION
133 %token DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END
134 %token SORT_BY_NAME SORT_BY_ALIGNMENT SORT_NONE
135 %token SORT_BY_INIT_PRIORITY REVERSE
137 %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
138 %token INHIBIT_COMMON_ALLOCATION FORCE_GROUP_ALLOCATION
144 %token NOLOAD DSECT COPY INFO OVERLAY
147 %token DEFINED TARGET_K SEARCH_DIR MAP ENTRY
148 %token
<integer
> NEXT
149 %token SIZEOF ALIGNOF ADDR LOADADDR MAX_K MIN_K
150 %token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS NOCROSSREFS_TO
152 %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS
153 %token ALIGNMOD AT SUBALIGN HIDDEN PROVIDE PROVIDE_HIDDEN AS_NEEDED
154 %type
<token
> assign_op atype attributes_opt sect_constraint opt_align_with_input
155 %type
<name
> filename
156 %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K
157 %token LOG2CEIL FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL
158 %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START
159 %token
<name
> VERS_TAG VERS_IDENTIFIER
160 %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT INPUT_SECTION_ORDERING_SCRIPT
161 %token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL INPUT_SECTION_FLAGS ALIGN_WITH_INPUT
164 %type
<versyms
> vers_defns
165 %type
<versnode
> vers_tag
166 %type
<deflist
> verdep
167 %token INPUT_DYNAMIC_LIST
172 INPUT_SCRIPT script_file
173 | INPUT_MRI_SCRIPT mri_script_file
174 | INPUT_VERSION_SCRIPT version_script_file
175 | INPUT_SECTION_ORDERING_SCRIPT section_ordering_script_file
176 | INPUT_DYNAMIC_LIST dynamic_list_file
177 | INPUT_DEFSYM defsym_expr
185 { ldlex_expression
(); }
187 { ldlex_popstate
(); }
190 /* SYNTAX WITHIN AN MRI SCRIPT FILE */
194 PUSH_ERROR
(_
("MRI style script"));
205 mri_script_lines mri_script_command NEWLINE
213 einfo
(_
("%F%P: unrecognised keyword in MRI style script '%s'\n"),$1);
216 config.map_filename
= "-";
218 | ORDER ordernamelist
220 | PUBLIC NAME
'=' exp
221 { mri_public
($2, $4); }
222 | PUBLIC NAME
',' exp
223 { mri_public
($2, $4); }
225 { mri_public
($2, $3); }
229 { mri_output_section
($2, $4);}
231 { mri_output_section
($2, $3);}
233 { mri_output_section
($2, $4);}
234 | ALIGN_K NAME
'=' exp
235 { mri_align
($2,$4); }
236 | ALIGN_K NAME
',' exp
237 { mri_align
($2,$4); }
238 | ALIGNMOD NAME
'=' exp
239 { mri_alignmod
($2,$4); }
240 | ALIGNMOD NAME
',' exp
241 { mri_alignmod
($2,$4); }
242 | ABSOLUTE mri_abs_name_list
243 | LOAD mri_load_name_list
246 | ALIAS NAME
',' NAME
247 { mri_alias
($2,$4,0);}
249 { mri_alias
($2, 0, (int) $4.integer
); }
253 { mri_truncate
((unsigned int) $2.integer
); }
255 | EXTERN extern_name_list
257 { ldfile_open_command_file
($2); }
260 { lang_add_entry
($2, false
); }
265 ordernamelist
',' NAME
{ mri_order
($3); }
266 | ordernamelist NAME
{ mri_order
($2); }
273 | mri_load_name_list
',' NAME
{ mri_load
($3); }
278 { mri_only_load
($1); }
279 | mri_abs_name_list
',' NAME
280 { mri_only_load
($3); }
284 /* empty */ { $$
= NULL
; }
286 | casesymlist
',' NAME
291 { ldlang_add_undef
($1, false
); }
292 | extern_name_list NAME
293 { ldlang_add_undef
($2, false
); }
294 | extern_name_list
',' NAME
295 { ldlang_add_undef
($3, false
); }
301 { ldlex_popstate
(); }
317 | floating_point_support
321 | TARGET_K
'(' NAME
')'
322 { lang_add_target
($3); }
323 | SEARCH_DIR
'(' filename
')'
324 { ldfile_add_library_path
($3, false
); }
325 | OUTPUT
'(' filename
')'
326 { lang_add_output
($3, 1); }
327 | OUTPUT_FORMAT
'(' NAME
')'
328 { lang_add_output_format
($3, (char *) NULL
,
330 | OUTPUT_FORMAT
'(' NAME
',' NAME
',' NAME
')'
331 { lang_add_output_format
($3, $5, $7, 1); }
332 | OUTPUT_ARCH
'(' NAME
')'
333 { ldfile_set_output_arch
($3, bfd_arch_unknown
); }
334 | FORCE_COMMON_ALLOCATION
335 { command_line.force_common_definition
= true
; }
336 | FORCE_GROUP_ALLOCATION
337 { command_line.force_group_allocation
= true
; }
338 | INHIBIT_COMMON_ALLOCATION
339 { link_info.inhibit_common_definition
= true
; }
340 | INPUT
'(' input_list
')'
342 { lang_enter_group
(); }
344 { lang_leave_group
(); }
345 | MAP
'(' filename
')'
346 { lang_add_map
($3); }
348 { ldfile_open_command_file
($2); }
350 | NOCROSSREFS
'(' nocrossref_list
')'
352 lang_add_nocrossref
($3);
354 | NOCROSSREFS_TO
'(' nocrossref_list
')'
356 lang_add_nocrossref_to
($3);
358 | EXTERN
'(' { ldlex_expression
(); } extern_name_list
')'
359 { ldlex_popstate
(); }
360 | INSERT_K AFTER NAME
361 { lang_add_insert
($3, 0); }
362 | INSERT_K BEFORE NAME
363 { lang_add_insert
($3, 1); }
364 | REGION_ALIAS
'(' NAME
',' NAME
')'
365 { lang_memory_region_alias
($3, $5); }
366 | LD_FEATURE
'(' NAME
')'
367 { lang_ld_feature
($3); }
371 { ldlex_inputlist
(); }
373 { ldlex_popstate
(); }
377 { lang_add_input_file
($1,lang_input_file_is_search_file_enum
,
379 | input_list1
',' NAME
380 { lang_add_input_file
($3,lang_input_file_is_search_file_enum
,
383 { lang_add_input_file
($2,lang_input_file_is_search_file_enum
,
386 { lang_add_input_file
($1,lang_input_file_is_l_enum
,
388 | input_list1
',' LNAME
389 { lang_add_input_file
($3,lang_input_file_is_l_enum
,
392 { lang_add_input_file
($2,lang_input_file_is_l_enum
,
395 { $
<integer
>$
= input_flags.add_DT_NEEDED_for_regular
;
396 input_flags.add_DT_NEEDED_for_regular
= true
; }
398 { input_flags.add_DT_NEEDED_for_regular
= $
<integer
>3; }
399 | input_list1
',' AS_NEEDED
'('
400 { $
<integer
>$
= input_flags.add_DT_NEEDED_for_regular
;
401 input_flags.add_DT_NEEDED_for_regular
= true
; }
403 { input_flags.add_DT_NEEDED_for_regular
= $
<integer
>5; }
404 | input_list1 AS_NEEDED
'('
405 { $
<integer
>$
= input_flags.add_DT_NEEDED_for_regular
;
406 input_flags.add_DT_NEEDED_for_regular
= true
; }
408 { input_flags.add_DT_NEEDED_for_regular
= $
<integer
>4; }
412 SECTIONS
'{' sec_or_group_p1
'}'
416 sec_or_group_p1 section
417 | sec_or_group_p1 statement_anywhere
423 { lang_add_entry
($3, false
); }
424 | assignment separator
425 | ASSERT_K
{ldlex_expression
();} '(' exp
',' NAME
')'
427 lang_add_assignment
(exp_assert
($4, $6)); }
437 wildcard_maybe_exclude:
442 $$.exclude_name_list
= NULL
;
443 $$.section_flag_list
= NULL
;
446 | EXCLUDE_FILE
'(' exclude_name_list
')' wildcard_name
450 $$.exclude_name_list
= $3;
451 $$.section_flag_list
= NULL
;
456 wildcard_maybe_reverse:
457 wildcard_maybe_exclude
458 | REVERSE
'(' wildcard_maybe_exclude
')'
467 wildcard_maybe_reverse
468 | SORT_BY_NAME
'(' wildcard_maybe_reverse
')'
473 | SORT_NONE
'(' wildcard_maybe_reverse
')'
479 | REVERSE
'(' SORT_BY_NAME
'(' wildcard_maybe_exclude
')' ')'
488 wildcard_maybe_reverse
489 | SORT_BY_NAME
'(' wildcard_maybe_reverse
')'
494 | SORT_BY_ALIGNMENT
'(' wildcard_maybe_reverse
')'
497 $$.sorted
= by_alignment
;
499 | SORT_NONE
'(' wildcard_maybe_reverse
')'
504 | SORT_BY_NAME
'(' SORT_BY_ALIGNMENT
'(' wildcard_maybe_reverse
')' ')'
507 $$.sorted
= by_name_alignment
;
509 | SORT_BY_NAME
'(' SORT_BY_NAME
'(' wildcard_maybe_reverse
')' ')'
514 | SORT_BY_ALIGNMENT
'(' SORT_BY_NAME
'(' wildcard_maybe_reverse
')' ')'
517 $$.sorted
= by_alignment_name
;
519 | SORT_BY_ALIGNMENT
'(' SORT_BY_ALIGNMENT
'(' wildcard_maybe_reverse
')' ')'
522 $$.sorted
= by_alignment
;
524 | SORT_BY_INIT_PRIORITY
'(' wildcard_maybe_reverse
')'
527 $$.sorted
= by_init_priority
;
529 | REVERSE
'(' SORT_BY_NAME
'(' wildcard_maybe_exclude
')' ')'
535 | REVERSE
'(' SORT_BY_INIT_PRIORITY
'(' wildcard_maybe_exclude
')' ')'
538 $$.sorted
= by_init_priority
;
545 struct flag_info_list
*n
;
546 n
= ((struct flag_info_list
*) xmalloc
(sizeof
*n
));
549 n
->with
= without_flags
;
554 n
->with
= with_flags
;
561 | sect_flag_list
'&' NAME
563 struct flag_info_list
*n
;
564 n
= ((struct flag_info_list
*) xmalloc
(sizeof
*n
));
567 n
->with
= without_flags
;
572 n
->with
= with_flags
;
582 INPUT_SECTION_FLAGS
'(' sect_flag_list
')'
585 n
= ((struct flag_info
*) xmalloc
(sizeof
*n
));
587 n
->flags_initialized
= false
;
588 n
->not_with_flags
= 0;
589 n
->only_with_flags
= 0;
595 exclude_name_list wildcard_name
597 struct name_list
*tmp
;
598 tmp
= (struct name_list
*) xmalloc
(sizeof
*tmp
);
606 struct name_list
*tmp
;
607 tmp
= (struct name_list
*) xmalloc
(sizeof
*tmp
);
615 section_name_list opt_comma section_name_spec
617 struct wildcard_list
*tmp
;
618 tmp
= (struct wildcard_list
*) xmalloc
(sizeof
*tmp
);
626 struct wildcard_list
*tmp
;
627 tmp
= (struct wildcard_list
*) xmalloc
(sizeof
*tmp
);
634 input_section_spec_no_keep:
637 struct wildcard_spec tmp
;
639 tmp.exclude_name_list
= NULL
;
641 tmp.section_flag_list
= NULL
;
642 lang_add_wild
(&tmp
, NULL
, ldgram_had_keep
);
646 struct wildcard_spec tmp
;
648 tmp.exclude_name_list
= NULL
;
650 tmp.section_flag_list
= $1;
651 lang_add_wild
(&tmp
, NULL
, ldgram_had_keep
);
653 |
'[' section_name_list
']'
655 lang_add_wild
(NULL
, $2, ldgram_had_keep
);
657 | sect_flags
'[' section_name_list
']'
659 struct wildcard_spec tmp
;
661 tmp.exclude_name_list
= NULL
;
663 tmp.section_flag_list
= $1;
664 lang_add_wild
(&tmp
, $3, ldgram_had_keep
);
666 | filename_spec
'(' section_name_list
')'
668 lang_add_wild
(&$1, $3, ldgram_had_keep
);
670 | sect_flags filename_spec
'(' section_name_list
')'
672 $2.section_flag_list
= $1;
673 lang_add_wild
(&$2, $4, ldgram_had_keep
);
678 input_section_spec_no_keep
680 { ldgram_had_keep
= true
; }
681 input_section_spec_no_keep
')'
682 { ldgram_had_keep
= false
; }
687 | assignment separator
688 | CREATE_OBJECT_SYMBOLS
690 lang_add_attribute
(lang_object_symbols_statement_enum
);
694 lang_add_attribute
(lang_constructors_statement_enum
);
696 | SORT_BY_NAME
'(' CONSTRUCTORS
')'
698 constructors_sorted
= true
;
699 lang_add_attribute
(lang_constructors_statement_enum
);
702 | length
'(' mustbe_exp
')'
704 lang_add_data
((int) $1, $3);
708 lang_add_string
($2);
710 | FILL
'(' fill_exp
')'
716 lang_add_version_string
();
719 { ldlex_expression
(); }
720 '(' exp
',' NAME
')' separator
723 lang_add_assignment
(exp_assert
($4, $6));
727 ldfile_open_command_file
($2);
729 statement_list_opt END
733 statement_list statement
758 $$
= exp_get_fill
($1, 0, _
("fill value"));
765 |
{ $$
= (fill_type
*) 0; }
797 lang_add_assignment
(exp_assign
($1, $3, false
));
799 | NAME assign_op mustbe_exp
801 lang_add_assignment
(exp_assign
($1,
807 | HIDDEN
'(' NAME
'=' mustbe_exp
')'
809 lang_add_assignment
(exp_assign
($3, $5, true
));
811 | PROVIDE
'(' NAME
'=' mustbe_exp
')'
813 lang_add_assignment
(exp_provide
($3, $5, false
));
815 | PROVIDE_HIDDEN
'(' NAME
'=' mustbe_exp
')'
817 lang_add_assignment
(exp_provide
($3, $5, true
));
827 MEMORY
'{' memory_spec_list_opt
'}'
830 memory_spec_list_opt: memory_spec_list |
;
833 memory_spec_list opt_comma memory_spec
839 { region
= lang_memory_region_lookup
($1, true
); }
841 origin_spec opt_comma length_spec
844 { ldfile_open_command_file
($2); }
845 memory_spec_list_opt END
849 ORIGIN
'=' mustbe_exp
851 region
->origin_exp
= $3;
856 LENGTH
'=' mustbe_exp
863 region
->length_exp
= $3;
869 { /* dummy action to avoid bison 1.25 error message */ }
870 |
'(' attributes_list
')'
875 | attributes_list attributes_string
880 { lang_set_flags
(region
, $1, 0); }
882 { lang_set_flags
(region
, $2, 1); }
886 STARTUP
'(' filename
')'
887 { lang_startup
($3); }
891 HLL
'(' high_level_library_NAME_list
')'
893 { ldemul_hll
((char *)NULL
); }
896 high_level_library_NAME_list:
897 high_level_library_NAME_list opt_comma filename
904 SYSLIB
'(' low_level_library_NAME_list
')'
907 low_level_library_NAME_list:
908 low_level_library_NAME_list opt_comma filename
909 { ldemul_syslib
($3); }
913 floating_point_support:
915 { lang_float
(true
); }
917 { lang_float
(false
); }
925 | NAME nocrossref_list
927 struct lang_nocrossref
*n
;
929 n
= (struct lang_nocrossref
*) xmalloc
(sizeof
*n
);
934 | NAME
',' nocrossref_list
936 struct lang_nocrossref
*n
;
938 n
= (struct lang_nocrossref
*) xmalloc
(sizeof
*n
);
945 paren_script_name: { ldlex_script
(); }
947 { ldlex_popstate
(); $$
= $3; }
949 mustbe_exp: { ldlex_expression
(); }
951 { ldlex_popstate
(); $$
= $2; }
956 { $$
= exp_unop
('-', $2); }
959 | NEXT
'(' exp
')' %prec UNARY
960 { $$
= exp_unop
((int) $1,$3); }
961 |
'!' exp %prec UNARY
962 { $$
= exp_unop
('!', $2); }
963 |
'+' exp %prec UNARY
965 |
'~' exp %prec UNARY
966 { $$
= exp_unop
('~', $2);}
969 { $$
= exp_binop
('*', $1, $3); }
971 { $$
= exp_binop
('/', $1, $3); }
973 { $$
= exp_binop
('%', $1, $3); }
975 { $$
= exp_binop
('+', $1, $3); }
977 { $$
= exp_binop
('-' , $1, $3); }
979 { $$
= exp_binop
(LSHIFT
, $1, $3); }
981 { $$
= exp_binop
(RSHIFT
, $1, $3); }
983 { $$
= exp_binop
(EQ
, $1, $3); }
985 { $$
= exp_binop
(NE
, $1, $3); }
987 { $$
= exp_binop
(LE
, $1, $3); }
989 { $$
= exp_binop
(GE
, $1, $3); }
991 { $$
= exp_binop
('<' , $1, $3); }
993 { $$
= exp_binop
('>' , $1, $3); }
995 { $$
= exp_binop
('&' , $1, $3); }
997 { $$
= exp_binop
('^' , $1, $3); }
999 { $$
= exp_binop
('|' , $1, $3); }
1000 | exp
'?' exp
':' exp
1001 { $$
= exp_trinop
('?' , $1, $3, $5); }
1003 { $$
= exp_binop
(ANDAND
, $1, $3); }
1005 { $$
= exp_binop
(OROR
, $1, $3); }
1006 | DEFINED
'(' NAME
')'
1007 { $$
= exp_nameop
(DEFINED
, $3); }
1009 { $$
= exp_bigintop
($1.integer
, $1.str
); }
1011 { $$
= exp_nameop
(SIZEOF_HEADERS
,0); }
1013 | ALIGNOF paren_script_name
1014 { $$
= exp_nameop
(ALIGNOF
, $2); }
1015 | SIZEOF paren_script_name
1016 { $$
= exp_nameop
(SIZEOF
, $2); }
1017 | ADDR paren_script_name
1018 { $$
= exp_nameop
(ADDR
, $2); }
1019 | LOADADDR paren_script_name
1020 { $$
= exp_nameop
(LOADADDR
, $2); }
1021 | CONSTANT
'(' NAME
')'
1022 { $$
= exp_nameop
(CONSTANT
,$3); }
1023 | ABSOLUTE
'(' exp
')'
1024 { $$
= exp_unop
(ABSOLUTE
, $3); }
1025 | ALIGN_K
'(' exp
')'
1026 { $$
= exp_unop
(ALIGN_K
,$3); }
1027 | ALIGN_K
'(' exp
',' exp
')'
1028 { $$
= exp_binop
(ALIGN_K
,$3,$5); }
1029 | DATA_SEGMENT_ALIGN
'(' exp
',' exp
')'
1030 { $$
= exp_binop
(DATA_SEGMENT_ALIGN
, $3, $5); }
1031 | DATA_SEGMENT_RELRO_END
'(' exp
',' exp
')'
1032 { $$
= exp_binop
(DATA_SEGMENT_RELRO_END
, $5, $3); }
1033 | DATA_SEGMENT_END
'(' exp
')'
1034 { $$
= exp_unop
(DATA_SEGMENT_END
, $3); }
1035 | SEGMENT_START
{ ldlex_script
(); } '(' NAME
1036 { ldlex_popstate
(); } ',' exp
')'
1037 { /* The operands to the expression node are
1038 placed in the opposite order from the way
1039 in which they appear in the script as
1040 that allows us to reuse more code in
1042 $$
= exp_binop
(SEGMENT_START
,
1044 exp_nameop
(NAME
, $4)); }
1046 { $$
= exp_unop
(ALIGN_K
,$3); }
1048 { $$
= exp_nameop
(NAME
,$1); }
1049 | MAX_K
'(' exp
',' exp
')'
1050 { $$
= exp_binop
(MAX_K
, $3, $5 ); }
1051 | MIN_K
'(' exp
',' exp
')'
1052 { $$
= exp_binop
(MIN_K
, $3, $5 ); }
1053 | ASSERT_K
'(' exp
',' NAME
')'
1054 { $$
= exp_assert
($3, $5); }
1055 | ORIGIN paren_script_name
1056 { $$
= exp_nameop
(ORIGIN
, $2); }
1057 | LENGTH paren_script_name
1058 { $$
= exp_nameop
(LENGTH
, $2); }
1059 | LOG2CEIL
'(' exp
')'
1060 { $$
= exp_unop
(LOG2CEIL
, $3); }
1065 AT
'>' NAME
{ $$
= $3; }
1070 AT
'(' exp
')' { $$
= $3; }
1075 ALIGN_K
'(' exp
')' { $$
= $3; }
1079 opt_align_with_input:
1080 ALIGN_WITH_INPUT
{ $$
= ALIGN_WITH_INPUT
; }
1085 SUBALIGN
'(' exp
')' { $$
= $3; }
1090 ONLY_IF_RO
{ $$
= ONLY_IF_RO
; }
1091 | ONLY_IF_RW
{ $$
= ONLY_IF_RW
; }
1092 | SPECIAL
{ $$
= SPECIAL
; }
1097 { ldlex_expression
(); }
1101 opt_align_with_input
1107 lang_enter_output_section_statement
($1, $3, sectype
,
1108 sectype_value
, $5, $7, $4, $8, $6);
1113 { ldlex_popstate
(); }
1114 memspec_opt memspec_at_opt phdr_opt fill_opt
1116 /* fill_opt may have switched the lexer into
1117 expression state, and back again, but in
1118 order to find the end of the fill
1119 expression the parser must look ahead one
1120 token. If it is a NAME, throw it away as
1121 it will have been lexed in the wrong
1128 lang_leave_output_section_statement
($17, $14,
1133 { ldlex_expression
(); }
1134 opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
1135 { ldlex_popstate
(); }
1138 lang_enter_overlay
($3, $6);
1142 memspec_opt memspec_at_opt phdr_opt fill_opt
1149 lang_leave_overlay
($5, (int) $4,
1150 $15, $12, $14, $13);
1153 |
/* The GROUP case is just enough to support the gcc
1154 svr3.ifile script. It is not intended to be full
1155 support. I'm not even sure what GROUP is supposed
1158 { ldlex_expression
(); }
1162 lang_add_assignment
(exp_assign
(".", $3, false
));
1164 '{' sec_or_group_p1
'}'
1167 ldfile_open_command_file
($2);
1173 NOLOAD
{ sectype
= noload_section
; }
1174 | DSECT
{ sectype
= noalloc_section
; }
1175 | COPY
{ sectype
= noalloc_section
; }
1176 | INFO
{ sectype
= noalloc_section
; }
1177 | OVERLAY
{ sectype
= noalloc_section
; }
1178 | READONLY
'(' TYPE
'=' exp
')' { sectype
= typed_readonly_section
; sectype_value
= $5; }
1179 | READONLY
{ sectype
= readonly_section
; }
1180 | TYPE
'=' exp
{ sectype
= type_section
; sectype_value
= $3; }
1185 |
/* EMPTY */ { sectype
= normal_section
; }
1186 |
'(' ')' { sectype
= normal_section
; }
1190 exp atype
':' { $$
= $1; }
1191 | atype
':' { $$
= (etree_type
*)NULL
; }
1192 |
/* The BIND cases are to support the gcc svr3.ifile
1193 script. They aren't intended to implement full
1194 support for the BIND keyword. I'm not even sure
1195 what BIND is supposed to mean. */
1196 BIND
'(' exp
')' atype
':' { $$
= $3; }
1197 | BIND
'(' exp
')' BLOCK
'(' exp
')' atype
':'
1201 opt_exp_without_type:
1202 exp
':' { $$
= $1; }
1203 |
':' { $$
= (etree_type
*) NULL
; }
1216 |
{ $$
= DEFAULT_MEMORY_REGION
; }
1226 struct lang_output_section_phdr_list
*n
;
1228 n
= ((struct lang_output_section_phdr_list
*)
1229 xmalloc
(sizeof
*n
));
1243 lang_enter_overlay_section
($2);
1248 { ldlex_popstate
(); }
1256 lang_leave_overlay_section
($9, $8);
1262 PHDRS
'{' phdr_list
'}'
1271 NAME
{ ldlex_expression
(); }
1272 phdr_type phdr_qualifiers
{ ldlex_popstate
(); }
1275 lang_new_phdr
($1, $3, $4.filehdr
, $4.phdrs
, $4.at
,
1285 if
($1->type.node_class
== etree_name
1286 && $1->type.node_code
== NAME
)
1290 static const char * const phdr_types
[] =
1292 "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
1293 "PT_INTERP", "PT_NOTE", "PT_SHLIB",
1299 i
< sizeof phdr_types
/ sizeof phdr_types
[0];
1301 if
(strcmp
(s
, phdr_types
[i
]) == 0)
1306 if
(i
== sizeof phdr_types
/ sizeof phdr_types
[0])
1308 if
(strcmp
(s
, "PT_GNU_EH_FRAME") == 0)
1309 $$
= exp_intop
(0x6474e550);
1310 else if
(strcmp
(s
, "PT_GNU_STACK") == 0)
1311 $$
= exp_intop
(0x6474e551);
1312 else if
(strcmp
(s
, "PT_GNU_RELRO") == 0)
1313 $$
= exp_intop
(0x6474e552);
1314 else if
(strcmp
(s
, "PT_GNU_PROPERTY") == 0)
1315 $$
= exp_intop
(0x6474e553);
1319 %X%P:%pS: unknown phdr type `%s' (try integer literal)\n"),
1331 memset
(&$$
, 0, sizeof
(struct phdr_info
));
1333 | NAME phdr_val phdr_qualifiers
1336 if
(strcmp
($1, "FILEHDR") == 0 && $2 == NULL
)
1338 else if
(strcmp
($1, "PHDRS") == 0 && $2 == NULL
)
1340 else if
(strcmp
($1, "FLAGS") == 0 && $2 != NULL
)
1343 einfo
(_
("%X%P:%pS: PHDRS syntax error at `%s'\n"),
1346 | AT
'(' exp
')' phdr_qualifiers
1366 ldlex_version_file
();
1367 PUSH_ERROR
(_
("dynamic list"));
1378 | dynamic_list_nodes dynamic_list_node
1382 '{' dynamic_list_tag
'}' ';'
1388 lang_append_dynamic_list
(current_dynamic_list_p
, $1);
1392 /* This syntax is used within an external version script file. */
1394 version_script_file:
1396 ldlex_version_file
();
1397 PUSH_ERROR
(_
("VERSION script"));
1406 /* This is used within a normal linker script file. */
1410 ldlex_version_script
();
1412 VERSIONK
'{' vers_nodes
'}'
1420 | vers_nodes vers_node
1424 '{' vers_tag
'}' ';'
1426 lang_register_vers_node
(NULL
, $2, NULL
);
1428 | VERS_TAG
'{' vers_tag
'}' ';'
1430 lang_register_vers_node
($1, $3, NULL
);
1432 | VERS_TAG
'{' vers_tag
'}' verdep
';'
1434 lang_register_vers_node
($1, $3, $5);
1441 $$
= lang_add_vers_depend
(NULL
, $1);
1445 $$
= lang_add_vers_depend
($1, $2);
1452 $$
= lang_new_vers_node
(NULL
, NULL
);
1456 $$
= lang_new_vers_node
($1, NULL
);
1458 | GLOBAL
':' vers_defns
';'
1460 $$
= lang_new_vers_node
($3, NULL
);
1462 | LOCAL
':' vers_defns
';'
1464 $$
= lang_new_vers_node
(NULL
, $3);
1466 | GLOBAL
':' vers_defns
';' LOCAL
':' vers_defns
';'
1468 $$
= lang_new_vers_node
($3, $7);
1475 $$
= lang_new_vers_pattern
(NULL
, $1, ldgram_vers_current_lang
, false
);
1479 $$
= lang_new_vers_pattern
(NULL
, $1, ldgram_vers_current_lang
, true
);
1481 | vers_defns
';' VERS_IDENTIFIER
1483 $$
= lang_new_vers_pattern
($1, $3, ldgram_vers_current_lang
, false
);
1485 | vers_defns
';' NAME
1487 $$
= lang_new_vers_pattern
($1, $3, ldgram_vers_current_lang
, true
);
1489 | vers_defns
';' EXTERN NAME
'{'
1491 $
<name
>$
= ldgram_vers_current_lang
;
1492 ldgram_vers_current_lang
= $4;
1494 vers_defns opt_semicolon
'}'
1496 struct bfd_elf_version_expr
*pat
;
1497 for
(pat
= $7; pat
->next
!= NULL
; pat
= pat
->next
);
1500 ldgram_vers_current_lang
= $
<name
>6;
1504 $
<name
>$
= ldgram_vers_current_lang
;
1505 ldgram_vers_current_lang
= $2;
1507 vers_defns opt_semicolon
'}'
1510 ldgram_vers_current_lang
= $
<name
>4;
1514 $$
= lang_new_vers_pattern
(NULL
, "global", ldgram_vers_current_lang
, false
);
1516 | vers_defns
';' GLOBAL
1518 $$
= lang_new_vers_pattern
($1, "global", ldgram_vers_current_lang
, false
);
1522 $$
= lang_new_vers_pattern
(NULL
, "local", ldgram_vers_current_lang
, false
);
1524 | vers_defns
';' LOCAL
1526 $$
= lang_new_vers_pattern
($1, "local", ldgram_vers_current_lang
, false
);
1530 $$
= lang_new_vers_pattern
(NULL
, "extern", ldgram_vers_current_lang
, false
);
1532 | vers_defns
';' EXTERN
1534 $$
= lang_new_vers_pattern
($1, "extern", ldgram_vers_current_lang
, false
);
1543 section_ordering_script_file:
1546 PUSH_ERROR
(_
("section-ordering-file script"));
1548 section_ordering_list
1555 section_ordering_list:
1556 section_ordering_list section_order
1557 | section_ordering_list statement_anywhere
1561 section_order: NAME
':'
1564 lang_enter_output_section_statement
1565 ($1, NULL
, 0, NULL
, NULL
, NULL
, NULL
, 0, 0);
1572 lang_leave_output_section_statement
(NULL
, NULL
, NULL
, NULL
);
1578 yyerror (const char *arg
)
1580 if
(ldfile_assumed_script
)
1581 einfo
(_
("%P:%s: file format not recognized; treating as linker script\n"),
1583 if
(error_index
> 0 && error_index
< ERROR_NAME_MAX
)
1584 einfo
(_
("%F%P:%pS: %s in %s\n"), NULL
, arg
, error_names
[error_index
- 1]);
1586 einfo
("%F%P:%pS: %s\n", NULL
, arg
);