1 /* A YACC grammar to parse a superset of the AT&T linker scripting language.
2 Copyright (C) 1991-2023 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
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
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
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_DYNAMIC_LIST dynamic_list_file
176 | INPUT_DEFSYM defsym_expr
184 { ldlex_expression(); }
186 { ldlex_popstate(); }
189 /* SYNTAX WITHIN AN MRI SCRIPT FILE */
193 PUSH_ERROR (_("MRI style script"));
204 mri_script_lines mri_script_command NEWLINE
212 einfo(_("%F%P: unrecognised keyword in MRI style script '%s'\n"),$1);
215 config.map_filename = "-";
217 | ORDER ordernamelist
219 | PUBLIC NAME '=' exp
220 { mri_public($2, $4); }
221 | PUBLIC NAME ',' exp
222 { mri_public($2, $4); }
224 { mri_public($2, $3); }
228 { mri_output_section($2, $4);}
230 { mri_output_section($2, $3);}
232 { mri_output_section($2, $4);}
233 | ALIGN_K NAME '=' exp
234 { mri_align($2,$4); }
235 | ALIGN_K NAME ',' exp
236 { mri_align($2,$4); }
237 | ALIGNMOD NAME '=' exp
238 { mri_alignmod($2,$4); }
239 | ALIGNMOD NAME ',' exp
240 { mri_alignmod($2,$4); }
241 | ABSOLUTE mri_abs_name_list
242 | LOAD mri_load_name_list
245 | ALIAS NAME ',' NAME
246 { mri_alias($2,$4,0);}
248 { mri_alias ($2, 0, (int) $4.integer); }
252 { mri_truncate ((unsigned int) $2.integer); }
254 | EXTERN extern_name_list
256 { ldfile_open_command_file ($2); }
259 { lang_add_entry ($2, false); }
264 ordernamelist ',' NAME { mri_order($3); }
265 | ordernamelist NAME { mri_order($2); }
272 | mri_load_name_list ',' NAME { mri_load($3); }
277 { mri_only_load($1); }
278 | mri_abs_name_list ',' NAME
279 { mri_only_load($3); }
283 /* empty */ { $$ = NULL; }
285 | casesymlist ',' NAME
290 { ldlang_add_undef ($1, false); }
291 | extern_name_list NAME
292 { ldlang_add_undef ($2, false); }
293 | extern_name_list ',' NAME
294 { ldlang_add_undef ($3, false); }
300 { ldlex_popstate (); }
316 | floating_point_support
320 | TARGET_K '(' NAME ')'
321 { lang_add_target($3); }
322 | SEARCH_DIR '(' filename ')'
323 { ldfile_add_library_path ($3, false); }
324 | OUTPUT '(' filename ')'
325 { lang_add_output($3, 1); }
326 | OUTPUT_FORMAT '(' NAME ')'
327 { lang_add_output_format ($3, (char *) NULL,
329 | OUTPUT_FORMAT '(' NAME ',' NAME ',' NAME ')'
330 { lang_add_output_format ($3, $5, $7, 1); }
331 | OUTPUT_ARCH '(' NAME ')'
332 { ldfile_set_output_arch ($3, bfd_arch_unknown); }
333 | FORCE_COMMON_ALLOCATION
334 { command_line.force_common_definition = true ; }
335 | FORCE_GROUP_ALLOCATION
336 { command_line.force_group_allocation = true ; }
337 | INHIBIT_COMMON_ALLOCATION
338 { link_info.inhibit_common_definition = true ; }
339 | INPUT '(' input_list ')'
341 { lang_enter_group (); }
343 { lang_leave_group (); }
344 | MAP '(' filename ')'
345 { lang_add_map($3); }
347 { ldfile_open_command_file ($2); }
349 | NOCROSSREFS '(' nocrossref_list ')'
351 lang_add_nocrossref ($3);
353 | NOCROSSREFS_TO '(' nocrossref_list ')'
355 lang_add_nocrossref_to ($3);
357 | EXTERN '(' { ldlex_expression (); } extern_name_list ')'
358 { ldlex_popstate (); }
359 | INSERT_K AFTER NAME
360 { lang_add_insert ($3, 0); }
361 | INSERT_K BEFORE NAME
362 { lang_add_insert ($3, 1); }
363 | REGION_ALIAS '(' NAME ',' NAME ')'
364 { lang_memory_region_alias ($3, $5); }
365 | LD_FEATURE '(' NAME ')'
366 { lang_ld_feature ($3); }
370 { ldlex_inputlist(); }
372 { ldlex_popstate(); }
376 { lang_add_input_file($1,lang_input_file_is_search_file_enum,
378 | input_list1 ',' NAME
379 { lang_add_input_file($3,lang_input_file_is_search_file_enum,
382 { lang_add_input_file($2,lang_input_file_is_search_file_enum,
385 { lang_add_input_file($1,lang_input_file_is_l_enum,
387 | input_list1 ',' LNAME
388 { lang_add_input_file($3,lang_input_file_is_l_enum,
391 { lang_add_input_file($2,lang_input_file_is_l_enum,
394 { $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
395 input_flags.add_DT_NEEDED_for_regular = true; }
397 { input_flags.add_DT_NEEDED_for_regular = $<integer>3; }
398 | input_list1 ',' AS_NEEDED '('
399 { $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
400 input_flags.add_DT_NEEDED_for_regular = true; }
402 { input_flags.add_DT_NEEDED_for_regular = $<integer>5; }
403 | input_list1 AS_NEEDED '('
404 { $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
405 input_flags.add_DT_NEEDED_for_regular = true; }
407 { input_flags.add_DT_NEEDED_for_regular = $<integer>4; }
411 SECTIONS '{' sec_or_group_p1 '}'
415 sec_or_group_p1 section
416 | sec_or_group_p1 statement_anywhere
422 { lang_add_entry ($3, false); }
423 | assignment separator
424 | ASSERT_K {ldlex_expression ();} '(' exp ',' NAME ')'
426 lang_add_assignment (exp_assert ($4, $6)); }
436 wildcard_maybe_exclude:
441 $$.exclude_name_list = NULL;
442 $$.section_flag_list = NULL;
444 | EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name
448 $$.exclude_name_list = $3;
449 $$.section_flag_list = NULL;
454 wildcard_maybe_exclude
455 | SORT_BY_NAME '(' wildcard_maybe_exclude ')'
460 | SORT_NONE '(' wildcard_maybe_exclude ')'
468 wildcard_maybe_exclude
469 | SORT_BY_NAME '(' wildcard_maybe_exclude ')'
474 | SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')'
477 $$.sorted = by_alignment;
479 | SORT_NONE '(' wildcard_maybe_exclude ')'
484 | SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')' ')'
487 $$.sorted = by_name_alignment;
489 | SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_maybe_exclude ')' ')'
494 | SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_maybe_exclude ')' ')'
497 $$.sorted = by_alignment_name;
499 | SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')' ')'
502 $$.sorted = by_alignment;
504 | SORT_BY_INIT_PRIORITY '(' wildcard_maybe_exclude ')'
507 $$.sorted = by_init_priority;
513 struct flag_info_list *n;
514 n = ((struct flag_info_list *) xmalloc (sizeof *n));
517 n->with = without_flags;
522 n->with = with_flags;
529 | sect_flag_list '&' NAME
531 struct flag_info_list *n;
532 n = ((struct flag_info_list *) xmalloc (sizeof *n));
535 n->with = without_flags;
540 n->with = with_flags;
550 INPUT_SECTION_FLAGS '(' sect_flag_list ')'
553 n = ((struct flag_info *) xmalloc (sizeof *n));
555 n->flags_initialized = false;
556 n->not_with_flags = 0;
557 n->only_with_flags = 0;
563 exclude_name_list wildcard_name
565 struct name_list *tmp;
566 tmp = (struct name_list *) xmalloc (sizeof *tmp);
574 struct name_list *tmp;
575 tmp = (struct name_list *) xmalloc (sizeof *tmp);
583 section_name_list opt_comma section_name_spec
585 struct wildcard_list *tmp;
586 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
594 struct wildcard_list *tmp;
595 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
602 input_section_spec_no_keep:
605 struct wildcard_spec tmp;
607 tmp.exclude_name_list = NULL;
609 tmp.section_flag_list = NULL;
610 lang_add_wild (&tmp, NULL, ldgram_had_keep);
614 struct wildcard_spec tmp;
616 tmp.exclude_name_list = NULL;
618 tmp.section_flag_list = $1;
619 lang_add_wild (&tmp, NULL, ldgram_had_keep);
621 | '[' section_name_list ']'
623 lang_add_wild (NULL, $2, ldgram_had_keep);
625 | sect_flags '[' section_name_list ']'
627 struct wildcard_spec tmp;
629 tmp.exclude_name_list = NULL;
631 tmp.section_flag_list = $1;
632 lang_add_wild (&tmp, $3, ldgram_had_keep);
634 | filename_spec '(' section_name_list ')'
636 lang_add_wild (&$1, $3, ldgram_had_keep);
638 | sect_flags filename_spec '(' section_name_list ')'
640 $2.section_flag_list = $1;
641 lang_add_wild (&$2, $4, ldgram_had_keep);
646 input_section_spec_no_keep
648 { ldgram_had_keep = true; }
649 input_section_spec_no_keep ')'
650 { ldgram_had_keep = false; }
655 | assignment separator
656 | CREATE_OBJECT_SYMBOLS
658 lang_add_attribute (lang_object_symbols_statement_enum);
662 lang_add_attribute (lang_constructors_statement_enum);
664 | SORT_BY_NAME '(' CONSTRUCTORS ')'
666 constructors_sorted = true;
667 lang_add_attribute (lang_constructors_statement_enum);
670 | length '(' mustbe_exp ')'
672 lang_add_data ((int) $1, $3);
676 lang_add_string ($2);
678 | FILL '(' fill_exp ')'
684 lang_add_version_string ();
687 { ldlex_expression (); }
688 '(' exp ',' NAME ')' separator
691 lang_add_assignment (exp_assert ($4, $6));
695 ldfile_open_command_file ($2);
697 statement_list_opt END
701 statement_list statement
726 $$ = exp_get_fill ($1, 0, _("fill value"));
733 | { $$ = (fill_type *) 0; }
765 lang_add_assignment (exp_assign ($1, $3, false));
767 | NAME assign_op mustbe_exp
769 lang_add_assignment (exp_assign ($1,
775 | HIDDEN '(' NAME '=' mustbe_exp ')'
777 lang_add_assignment (exp_assign ($3, $5, true));
779 | PROVIDE '(' NAME '=' mustbe_exp ')'
781 lang_add_assignment (exp_provide ($3, $5, false));
783 | PROVIDE_HIDDEN '(' NAME '=' mustbe_exp ')'
785 lang_add_assignment (exp_provide ($3, $5, true));
795 MEMORY '{' memory_spec_list_opt '}'
798 memory_spec_list_opt: memory_spec_list | ;
801 memory_spec_list opt_comma memory_spec
807 { region = lang_memory_region_lookup ($1, true); }
809 origin_spec opt_comma length_spec
812 { ldfile_open_command_file ($2); }
813 memory_spec_list_opt END
817 ORIGIN '=' mustbe_exp
819 region->origin_exp = $3;
824 LENGTH '=' mustbe_exp
831 region->length_exp = $3;
837 { /* dummy action to avoid bison 1.25 error message */ }
838 | '(' attributes_list ')'
843 | attributes_list attributes_string
848 { lang_set_flags (region, $1, 0); }
850 { lang_set_flags (region, $2, 1); }
854 STARTUP '(' filename ')'
855 { lang_startup($3); }
859 HLL '(' high_level_library_NAME_list ')'
861 { ldemul_hll((char *)NULL); }
864 high_level_library_NAME_list:
865 high_level_library_NAME_list opt_comma filename
872 SYSLIB '(' low_level_library_NAME_list ')'
875 low_level_library_NAME_list:
876 low_level_library_NAME_list opt_comma filename
877 { ldemul_syslib($3); }
881 floating_point_support:
883 { lang_float(true); }
885 { lang_float(false); }
893 | NAME nocrossref_list
895 struct lang_nocrossref *n;
897 n = (struct lang_nocrossref *) xmalloc (sizeof *n);
902 | NAME ',' nocrossref_list
904 struct lang_nocrossref *n;
906 n = (struct lang_nocrossref *) xmalloc (sizeof *n);
913 paren_script_name: { ldlex_script (); }
915 { ldlex_popstate (); $$ = $3; }
917 mustbe_exp: { ldlex_expression (); }
919 { ldlex_popstate (); $$ = $2; }
924 { $$ = exp_unop ('-', $2); }
927 | NEXT '(' exp ')' %prec UNARY
928 { $$ = exp_unop ((int) $1,$3); }
929 | '!' exp %prec UNARY
930 { $$ = exp_unop ('!', $2); }
931 | '+' exp %prec UNARY
933 | '~' exp %prec UNARY
934 { $$ = exp_unop ('~', $2);}
937 { $$ = exp_binop ('*', $1, $3); }
939 { $$ = exp_binop ('/', $1, $3); }
941 { $$ = exp_binop ('%', $1, $3); }
943 { $$ = exp_binop ('+', $1, $3); }
945 { $$ = exp_binop ('-' , $1, $3); }
947 { $$ = exp_binop (LSHIFT , $1, $3); }
949 { $$ = exp_binop (RSHIFT , $1, $3); }
951 { $$ = exp_binop (EQ , $1, $3); }
953 { $$ = exp_binop (NE , $1, $3); }
955 { $$ = exp_binop (LE , $1, $3); }
957 { $$ = exp_binop (GE , $1, $3); }
959 { $$ = exp_binop ('<' , $1, $3); }
961 { $$ = exp_binop ('>' , $1, $3); }
963 { $$ = exp_binop ('&' , $1, $3); }
965 { $$ = exp_binop ('^' , $1, $3); }
967 { $$ = exp_binop ('|' , $1, $3); }
968 | exp '?' exp ':' exp
969 { $$ = exp_trinop ('?' , $1, $3, $5); }
971 { $$ = exp_binop (ANDAND , $1, $3); }
973 { $$ = exp_binop (OROR , $1, $3); }
974 | DEFINED '(' NAME ')'
975 { $$ = exp_nameop (DEFINED, $3); }
977 { $$ = exp_bigintop ($1.integer, $1.str); }
979 { $$ = exp_nameop (SIZEOF_HEADERS,0); }
981 | ALIGNOF paren_script_name
982 { $$ = exp_nameop (ALIGNOF, $2); }
983 | SIZEOF paren_script_name
984 { $$ = exp_nameop (SIZEOF, $2); }
985 | ADDR paren_script_name
986 { $$ = exp_nameop (ADDR, $2); }
987 | LOADADDR paren_script_name
988 { $$ = exp_nameop (LOADADDR, $2); }
989 | CONSTANT '(' NAME ')'
990 { $$ = exp_nameop (CONSTANT,$3); }
991 | ABSOLUTE '(' exp ')'
992 { $$ = exp_unop (ABSOLUTE, $3); }
993 | ALIGN_K '(' exp ')'
994 { $$ = exp_unop (ALIGN_K,$3); }
995 | ALIGN_K '(' exp ',' exp ')'
996 { $$ = exp_binop (ALIGN_K,$3,$5); }
997 | DATA_SEGMENT_ALIGN '(' exp ',' exp ')'
998 { $$ = exp_binop (DATA_SEGMENT_ALIGN, $3, $5); }
999 | DATA_SEGMENT_RELRO_END '(' exp ',' exp ')'
1000 { $$ = exp_binop (DATA_SEGMENT_RELRO_END, $5, $3); }
1001 | DATA_SEGMENT_END '(' exp ')'
1002 { $$ = exp_unop (DATA_SEGMENT_END, $3); }
1003 | SEGMENT_START { ldlex_script (); } '(' NAME
1004 { ldlex_popstate (); } ',' exp ')'
1005 { /* The operands to the expression node are
1006 placed in the opposite order from the way
1007 in which they appear in the script as
1008 that allows us to reuse more code in
1010 $$ = exp_binop (SEGMENT_START,
1012 exp_nameop (NAME, $4)); }
1014 { $$ = exp_unop (ALIGN_K,$3); }
1016 { $$ = exp_nameop (NAME,$1); }
1017 | MAX_K '(' exp ',' exp ')'
1018 { $$ = exp_binop (MAX_K, $3, $5 ); }
1019 | MIN_K '(' exp ',' exp ')'
1020 { $$ = exp_binop (MIN_K, $3, $5 ); }
1021 | ASSERT_K '(' exp ',' NAME ')'
1022 { $$ = exp_assert ($3, $5); }
1023 | ORIGIN paren_script_name
1024 { $$ = exp_nameop (ORIGIN, $2); }
1025 | LENGTH paren_script_name
1026 { $$ = exp_nameop (LENGTH, $2); }
1027 | LOG2CEIL '(' exp ')'
1028 { $$ = exp_unop (LOG2CEIL, $3); }
1033 AT '>' NAME { $$ = $3; }
1038 AT '(' exp ')' { $$ = $3; }
1043 ALIGN_K '(' exp ')' { $$ = $3; }
1047 opt_align_with_input:
1048 ALIGN_WITH_INPUT { $$ = ALIGN_WITH_INPUT; }
1053 SUBALIGN '(' exp ')' { $$ = $3; }
1058 ONLY_IF_RO { $$ = ONLY_IF_RO; }
1059 | ONLY_IF_RW { $$ = ONLY_IF_RW; }
1060 | SPECIAL { $$ = SPECIAL; }
1065 { ldlex_expression(); }
1069 opt_align_with_input
1075 lang_enter_output_section_statement ($1, $3, sectype,
1076 sectype_value, $5, $7, $4, $8, $6);
1081 { ldlex_popstate (); }
1082 memspec_opt memspec_at_opt phdr_opt fill_opt
1084 /* fill_opt may have switched the lexer into
1085 expression state, and back again, but in
1086 order to find the end of the fill
1087 expression the parser must look ahead one
1088 token. If it is a NAME, throw it away as
1089 it will have been lexed in the wrong
1096 lang_leave_output_section_statement ($17, $14,
1101 { ldlex_expression (); }
1102 opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
1103 { ldlex_popstate (); }
1106 lang_enter_overlay ($3, $6);
1110 memspec_opt memspec_at_opt phdr_opt fill_opt
1117 lang_leave_overlay ($5, (int) $4,
1118 $15, $12, $14, $13);
1121 | /* The GROUP case is just enough to support the gcc
1122 svr3.ifile script. It is not intended to be full
1123 support. I'm not even sure what GROUP is supposed
1126 { ldlex_expression (); }
1130 lang_add_assignment (exp_assign (".", $3, false));
1132 '{' sec_or_group_p1 '}'
1135 ldfile_open_command_file ($2);
1141 NOLOAD { sectype = noload_section; }
1142 | DSECT { sectype = noalloc_section; }
1143 | COPY { sectype = noalloc_section; }
1144 | INFO { sectype = noalloc_section; }
1145 | OVERLAY { sectype = noalloc_section; }
1146 | READONLY '(' TYPE '=' exp ')' { sectype = typed_readonly_section; sectype_value = $5; }
1147 | READONLY { sectype = readonly_section; }
1148 | TYPE '=' exp { sectype = type_section; sectype_value = $3; }
1153 | /* EMPTY */ { sectype = normal_section; }
1154 | '(' ')' { sectype = normal_section; }
1158 exp atype ':' { $$ = $1; }
1159 | atype ':' { $$ = (etree_type *)NULL; }
1160 | /* The BIND cases are to support the gcc svr3.ifile
1161 script. They aren't intended to implement full
1162 support for the BIND keyword. I'm not even sure
1163 what BIND is supposed to mean. */
1164 BIND '(' exp ')' atype ':' { $$ = $3; }
1165 | BIND '(' exp ')' BLOCK '(' exp ')' atype ':'
1169 opt_exp_without_type:
1170 exp ':' { $$ = $1; }
1171 | ':' { $$ = (etree_type *) NULL; }
1184 | { $$ = DEFAULT_MEMORY_REGION; }
1194 struct lang_output_section_phdr_list *n;
1196 n = ((struct lang_output_section_phdr_list *)
1197 xmalloc (sizeof *n));
1211 lang_enter_overlay_section ($2);
1216 { ldlex_popstate (); }
1224 lang_leave_overlay_section ($9, $8);
1230 PHDRS '{' phdr_list '}'
1239 NAME { ldlex_expression (); }
1240 phdr_type phdr_qualifiers { ldlex_popstate (); }
1243 lang_new_phdr ($1, $3, $4.filehdr, $4.phdrs, $4.at,
1253 if ($1->type.node_class == etree_name
1254 && $1->type.node_code == NAME)
1258 static const char * const phdr_types[] =
1260 "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
1261 "PT_INTERP", "PT_NOTE", "PT_SHLIB",
1267 i < sizeof phdr_types / sizeof phdr_types[0];
1269 if (strcmp (s, phdr_types[i]) == 0)
1274 if (i == sizeof phdr_types / sizeof phdr_types[0])
1276 if (strcmp (s, "PT_GNU_EH_FRAME") == 0)
1277 $$ = exp_intop (0x6474e550);
1278 else if (strcmp (s, "PT_GNU_STACK") == 0)
1279 $$ = exp_intop (0x6474e551);
1280 else if (strcmp (s, "PT_GNU_RELRO") == 0)
1281 $$ = exp_intop (0x6474e552);
1282 else if (strcmp (s, "PT_GNU_PROPERTY") == 0)
1283 $$ = exp_intop (0x6474e553);
1287 %X%P:%pS: unknown phdr type `%s' (try integer literal)\n"),
1299 memset (&$$, 0, sizeof (struct phdr_info));
1301 | NAME phdr_val phdr_qualifiers
1304 if (strcmp ($1, "FILEHDR") == 0 && $2 == NULL)
1306 else if (strcmp ($1, "PHDRS") == 0 && $2 == NULL)
1308 else if (strcmp ($1, "FLAGS") == 0 && $2 != NULL)
1311 einfo (_("%X%P:%pS: PHDRS syntax error at `%s'\n"),
1314 | AT '(' exp ')' phdr_qualifiers
1334 ldlex_version_file ();
1335 PUSH_ERROR (_("dynamic list"));
1346 | dynamic_list_nodes dynamic_list_node
1350 '{' dynamic_list_tag '}' ';'
1356 lang_append_dynamic_list (current_dynamic_list_p, $1);
1360 /* This syntax is used within an external version script file. */
1362 version_script_file:
1364 ldlex_version_file ();
1365 PUSH_ERROR (_("VERSION script"));
1374 /* This is used within a normal linker script file. */
1378 ldlex_version_script ();
1380 VERSIONK '{' vers_nodes '}'
1388 | vers_nodes vers_node
1392 '{' vers_tag '}' ';'
1394 lang_register_vers_node (NULL, $2, NULL);
1396 | VERS_TAG '{' vers_tag '}' ';'
1398 lang_register_vers_node ($1, $3, NULL);
1400 | VERS_TAG '{' vers_tag '}' verdep ';'
1402 lang_register_vers_node ($1, $3, $5);
1409 $$ = lang_add_vers_depend (NULL, $1);
1413 $$ = lang_add_vers_depend ($1, $2);
1420 $$ = lang_new_vers_node (NULL, NULL);
1424 $$ = lang_new_vers_node ($1, NULL);
1426 | GLOBAL ':' vers_defns ';'
1428 $$ = lang_new_vers_node ($3, NULL);
1430 | LOCAL ':' vers_defns ';'
1432 $$ = lang_new_vers_node (NULL, $3);
1434 | GLOBAL ':' vers_defns ';' LOCAL ':' vers_defns ';'
1436 $$ = lang_new_vers_node ($3, $7);
1443 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, false);
1447 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, true);
1449 | vers_defns ';' VERS_IDENTIFIER
1451 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, false);
1453 | vers_defns ';' NAME
1455 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, true);
1457 | vers_defns ';' EXTERN NAME '{'
1459 $<name>$ = ldgram_vers_current_lang;
1460 ldgram_vers_current_lang = $4;
1462 vers_defns opt_semicolon '}'
1464 struct bfd_elf_version_expr *pat;
1465 for (pat = $7; pat->next != NULL; pat = pat->next);
1468 ldgram_vers_current_lang = $<name>6;
1472 $<name>$ = ldgram_vers_current_lang;
1473 ldgram_vers_current_lang = $2;
1475 vers_defns opt_semicolon '}'
1478 ldgram_vers_current_lang = $<name>4;
1482 $$ = lang_new_vers_pattern (NULL, "global", ldgram_vers_current_lang, false);
1484 | vers_defns ';' GLOBAL
1486 $$ = lang_new_vers_pattern ($1, "global", ldgram_vers_current_lang, false);
1490 $$ = lang_new_vers_pattern (NULL, "local", ldgram_vers_current_lang, false);
1492 | vers_defns ';' LOCAL
1494 $$ = lang_new_vers_pattern ($1, "local", ldgram_vers_current_lang, false);
1498 $$ = lang_new_vers_pattern (NULL, "extern", ldgram_vers_current_lang, false);
1500 | vers_defns ';' EXTERN
1502 $$ = lang_new_vers_pattern ($1, "extern", ldgram_vers_current_lang, false);
1513 yyerror (const char *arg)
1515 if (ldfile_assumed_script)
1516 einfo (_("%P:%s: file format not recognized; treating as linker script\n"),
1518 if (error_index > 0 && error_index < ERROR_NAME_MAX)
1519 einfo (_("%F%P:%pS: %s in %s\n"), NULL, arg, error_names[error_index - 1]);
1521 einfo ("%F%P:%pS: %s\n", NULL, arg);