1 /* A YACC grammar to parse a superset of the AT&T linker scripting language.
2 Copyright (C) 1991-2021 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
49 static enum section_type sectype;
50 static lang_memory_region_type *region;
52 static bool ldgram_had_keep = false;
53 static char *ldgram_vers_current_lang = NULL;
55 #define ERROR_NAME_MAX 20
56 static char *error_names[ERROR_NAME_MAX];
57 static int error_index;
58 #define PUSH_ERROR(x) if (error_index < ERROR_NAME_MAX) error_names[error_index] = x; error_index++;
59 #define POP_ERROR() error_index--;
71 struct wildcard_spec wildcard;
72 struct wildcard_list *wildcard_list;
73 struct name_list *name_list;
74 struct flag_info_list *flag_info_list;
75 struct flag_info *flag_info;
77 union etree_union *etree;
82 union etree_union *at;
83 union etree_union *flags;
85 struct lang_nocrossref *nocrossref;
86 struct lang_output_section_phdr_list *section_phdr;
87 struct bfd_elf_version_deps *deflist;
88 struct bfd_elf_version_expr *versyms;
89 struct bfd_elf_version_tree *versnode;
92 %type <etree> exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val
93 %type <etree> opt_exp_without_type opt_subalign opt_align
94 %type <fill> fill_opt fill_exp
95 %type <name_list> exclude_name_list
96 %type <wildcard_list> section_name_list
97 %type <flag_info_list> sect_flag_list
98 %type <flag_info> sect_flags
99 %type <name> memspec_opt memspec_at_opt paren_script_name casesymlist
100 %type <cname> wildcard_name
101 %type <wildcard> section_name_spec filename_spec wildcard_maybe_exclude
103 %token <name> NAME LNAME
104 %type <integer> length
105 %type <phdr> phdr_qualifiers
106 %type <nocrossref> nocrossref_list
107 %type <section_phdr> phdr_opt
108 %type <integer> opt_nocrossrefs
110 %right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
111 %right <token> '?' ':'
118 %left <token> '<' '>' LE GE
119 %left <token> LSHIFT RSHIFT
121 %left <token> '+' '-'
122 %left <token> '*' '/' '%'
127 %token <token> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE
128 %token SECTIONS PHDRS INSERT_K AFTER BEFORE
129 %token DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END
130 %token SORT_BY_NAME SORT_BY_ALIGNMENT SORT_NONE
131 %token SORT_BY_INIT_PRIORITY
133 %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
134 %token INHIBIT_COMMON_ALLOCATION FORCE_GROUP_ALLOCATION
140 %token NOLOAD DSECT COPY INFO OVERLAY
142 %token DEFINED TARGET_K SEARCH_DIR MAP ENTRY
143 %token <integer> NEXT
144 %token SIZEOF ALIGNOF ADDR LOADADDR MAX_K MIN_K
145 %token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS NOCROSSREFS_TO
147 %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS
148 %token ALIGNMOD AT SUBALIGN HIDDEN PROVIDE PROVIDE_HIDDEN AS_NEEDED
149 %type <token> assign_op atype attributes_opt sect_constraint opt_align_with_input
150 %type <name> filename
151 %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K
152 %token LOG2CEIL FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL
153 %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START
154 %token <name> VERS_TAG VERS_IDENTIFIER
155 %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT
156 %token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL INPUT_SECTION_FLAGS ALIGN_WITH_INPUT
159 %type <versyms> vers_defns
160 %type <versnode> vers_tag
161 %type <deflist> verdep
162 %token INPUT_DYNAMIC_LIST
167 INPUT_SCRIPT script_file
168 | INPUT_MRI_SCRIPT mri_script_file
169 | INPUT_VERSION_SCRIPT version_script_file
170 | INPUT_DYNAMIC_LIST dynamic_list_file
171 | INPUT_DEFSYM defsym_expr
179 { ldlex_expression(); }
181 { ldlex_popstate(); }
184 /* SYNTAX WITHIN AN MRI SCRIPT FILE */
188 PUSH_ERROR (_("MRI style script"));
199 mri_script_lines mri_script_command NEWLINE
207 einfo(_("%F%P: unrecognised keyword in MRI style script '%s'\n"),$1);
210 config.map_filename = "-";
212 | ORDER ordernamelist
214 | PUBLIC NAME '=' exp
215 { mri_public($2, $4); }
216 | PUBLIC NAME ',' exp
217 { mri_public($2, $4); }
219 { mri_public($2, $3); }
223 { mri_output_section($2, $4);}
225 { mri_output_section($2, $3);}
227 { mri_output_section($2, $4);}
228 | ALIGN_K NAME '=' exp
229 { mri_align($2,$4); }
230 | ALIGN_K NAME ',' exp
231 { mri_align($2,$4); }
232 | ALIGNMOD NAME '=' exp
233 { mri_alignmod($2,$4); }
234 | ALIGNMOD NAME ',' exp
235 { mri_alignmod($2,$4); }
236 | ABSOLUTE mri_abs_name_list
237 | LOAD mri_load_name_list
240 | ALIAS NAME ',' NAME
241 { mri_alias($2,$4,0);}
243 { mri_alias ($2, 0, (int) $4.integer); }
247 { mri_truncate ((unsigned int) $2.integer); }
249 | EXTERN extern_name_list
251 { ldfile_open_command_file ($2); }
254 { lang_add_entry ($2, false); }
259 ordernamelist ',' NAME { mri_order($3); }
260 | ordernamelist NAME { mri_order($2); }
267 | mri_load_name_list ',' NAME { mri_load($3); }
272 { mri_only_load($1); }
273 | mri_abs_name_list ',' NAME
274 { mri_only_load($3); }
278 /* empty */ { $$ = NULL; }
280 | casesymlist ',' NAME
285 { ldlang_add_undef ($1, false); }
286 | extern_name_list NAME
287 { ldlang_add_undef ($2, false); }
288 | extern_name_list ',' NAME
289 { ldlang_add_undef ($3, false); }
295 { ldlex_popstate (); }
311 | floating_point_support
315 | TARGET_K '(' NAME ')'
316 { lang_add_target($3); }
317 | SEARCH_DIR '(' filename ')'
318 { ldfile_add_library_path ($3, false); }
319 | OUTPUT '(' filename ')'
320 { lang_add_output($3, 1); }
321 | OUTPUT_FORMAT '(' NAME ')'
322 { lang_add_output_format ($3, (char *) NULL,
324 | OUTPUT_FORMAT '(' NAME ',' NAME ',' NAME ')'
325 { lang_add_output_format ($3, $5, $7, 1); }
326 | OUTPUT_ARCH '(' NAME ')'
327 { ldfile_set_output_arch ($3, bfd_arch_unknown); }
328 | FORCE_COMMON_ALLOCATION
329 { command_line.force_common_definition = true ; }
330 | FORCE_GROUP_ALLOCATION
331 { command_line.force_group_allocation = true ; }
332 | INHIBIT_COMMON_ALLOCATION
333 { link_info.inhibit_common_definition = true ; }
334 | INPUT '(' input_list ')'
336 { lang_enter_group (); }
338 { lang_leave_group (); }
339 | MAP '(' filename ')'
340 { lang_add_map($3); }
342 { ldfile_open_command_file ($2); }
344 | NOCROSSREFS '(' nocrossref_list ')'
346 lang_add_nocrossref ($3);
348 | NOCROSSREFS_TO '(' nocrossref_list ')'
350 lang_add_nocrossref_to ($3);
352 | EXTERN '(' { ldlex_expression (); } extern_name_list ')'
353 { ldlex_popstate (); }
354 | INSERT_K AFTER NAME
355 { lang_add_insert ($3, 0); }
356 | INSERT_K BEFORE NAME
357 { lang_add_insert ($3, 1); }
358 | REGION_ALIAS '(' NAME ',' NAME ')'
359 { lang_memory_region_alias ($3, $5); }
360 | LD_FEATURE '(' NAME ')'
361 { lang_ld_feature ($3); }
365 { ldlex_inputlist(); }
367 { ldlex_popstate(); }
371 { lang_add_input_file($1,lang_input_file_is_search_file_enum,
373 | input_list1 ',' NAME
374 { lang_add_input_file($3,lang_input_file_is_search_file_enum,
377 { lang_add_input_file($2,lang_input_file_is_search_file_enum,
380 { lang_add_input_file($1,lang_input_file_is_l_enum,
382 | input_list1 ',' LNAME
383 { lang_add_input_file($3,lang_input_file_is_l_enum,
386 { lang_add_input_file($2,lang_input_file_is_l_enum,
389 { $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
390 input_flags.add_DT_NEEDED_for_regular = true; }
392 { input_flags.add_DT_NEEDED_for_regular = $<integer>3; }
393 | input_list1 ',' AS_NEEDED '('
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>5; }
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>4; }
406 SECTIONS '{' sec_or_group_p1 '}'
410 sec_or_group_p1 section
411 | sec_or_group_p1 statement_anywhere
417 { lang_add_entry ($3, false); }
418 | assignment separator
419 | ASSERT_K {ldlex_expression ();} '(' exp ',' NAME ')'
421 lang_add_assignment (exp_assert ($4, $6)); }
431 wildcard_maybe_exclude:
436 $$.exclude_name_list = NULL;
437 $$.section_flag_list = NULL;
439 | EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name
443 $$.exclude_name_list = $3;
444 $$.section_flag_list = NULL;
449 wildcard_maybe_exclude
450 | SORT_BY_NAME '(' wildcard_maybe_exclude ')'
455 | SORT_NONE '(' wildcard_maybe_exclude ')'
463 wildcard_maybe_exclude
464 | SORT_BY_NAME '(' wildcard_maybe_exclude ')'
469 | SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')'
472 $$.sorted = by_alignment;
474 | SORT_NONE '(' wildcard_maybe_exclude ')'
479 | SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')' ')'
482 $$.sorted = by_name_alignment;
484 | SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_maybe_exclude ')' ')'
489 | SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_maybe_exclude ')' ')'
492 $$.sorted = by_alignment_name;
494 | SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')' ')'
497 $$.sorted = by_alignment;
499 | SORT_BY_INIT_PRIORITY '(' wildcard_maybe_exclude ')'
502 $$.sorted = by_init_priority;
508 struct flag_info_list *n;
509 n = ((struct flag_info_list *) xmalloc (sizeof *n));
512 n->with = without_flags;
517 n->with = with_flags;
524 | sect_flag_list '&' NAME
526 struct flag_info_list *n;
527 n = ((struct flag_info_list *) xmalloc (sizeof *n));
530 n->with = without_flags;
535 n->with = with_flags;
545 INPUT_SECTION_FLAGS '(' sect_flag_list ')'
548 n = ((struct flag_info *) xmalloc (sizeof *n));
550 n->flags_initialized = false;
551 n->not_with_flags = 0;
552 n->only_with_flags = 0;
558 exclude_name_list wildcard_name
560 struct name_list *tmp;
561 tmp = (struct name_list *) xmalloc (sizeof *tmp);
569 struct name_list *tmp;
570 tmp = (struct name_list *) xmalloc (sizeof *tmp);
578 section_name_list opt_comma section_name_spec
580 struct wildcard_list *tmp;
581 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
589 struct wildcard_list *tmp;
590 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
597 input_section_spec_no_keep:
600 struct wildcard_spec tmp;
602 tmp.exclude_name_list = NULL;
604 tmp.section_flag_list = NULL;
605 lang_add_wild (&tmp, NULL, ldgram_had_keep);
609 struct wildcard_spec tmp;
611 tmp.exclude_name_list = NULL;
613 tmp.section_flag_list = $1;
614 lang_add_wild (&tmp, NULL, ldgram_had_keep);
616 | '[' section_name_list ']'
618 lang_add_wild (NULL, $2, ldgram_had_keep);
620 | sect_flags '[' section_name_list ']'
622 struct wildcard_spec tmp;
624 tmp.exclude_name_list = NULL;
626 tmp.section_flag_list = $1;
627 lang_add_wild (&tmp, $3, ldgram_had_keep);
629 | filename_spec '(' section_name_list ')'
631 lang_add_wild (&$1, $3, ldgram_had_keep);
633 | sect_flags filename_spec '(' section_name_list ')'
635 $2.section_flag_list = $1;
636 lang_add_wild (&$2, $4, ldgram_had_keep);
641 input_section_spec_no_keep
643 { ldgram_had_keep = true; }
644 input_section_spec_no_keep ')'
645 { ldgram_had_keep = false; }
650 | assignment separator
651 | CREATE_OBJECT_SYMBOLS
653 lang_add_attribute (lang_object_symbols_statement_enum);
657 lang_add_attribute (lang_constructors_statement_enum);
659 | SORT_BY_NAME '(' CONSTRUCTORS ')'
661 constructors_sorted = true;
662 lang_add_attribute (lang_constructors_statement_enum);
665 | length '(' mustbe_exp ')'
667 lang_add_data ((int) $1, $3);
670 | FILL '(' fill_exp ')'
675 { ldlex_expression (); }
676 '(' exp ',' NAME ')' separator
679 lang_add_assignment (exp_assert ($4, $6));
683 ldfile_open_command_file ($2);
685 statement_list_opt END
689 statement_list statement
714 $$ = exp_get_fill ($1, 0, "fill value");
721 | { $$ = (fill_type *) 0; }
751 lang_add_assignment (exp_assign ($1, $3, false));
753 | NAME assign_op mustbe_exp
755 lang_add_assignment (exp_assign ($1,
761 | HIDDEN '(' NAME '=' mustbe_exp ')'
763 lang_add_assignment (exp_assign ($3, $5, true));
765 | PROVIDE '(' NAME '=' mustbe_exp ')'
767 lang_add_assignment (exp_provide ($3, $5, false));
769 | PROVIDE_HIDDEN '(' NAME '=' mustbe_exp ')'
771 lang_add_assignment (exp_provide ($3, $5, true));
781 MEMORY '{' memory_spec_list_opt '}'
784 memory_spec_list_opt: memory_spec_list | ;
787 memory_spec_list opt_comma memory_spec
793 { region = lang_memory_region_lookup ($1, true); }
795 origin_spec opt_comma length_spec
798 { ldfile_open_command_file ($2); }
799 memory_spec_list_opt END
803 ORIGIN '=' mustbe_exp
805 region->origin_exp = $3;
810 LENGTH '=' mustbe_exp
817 region->length_exp = $3;
823 { /* dummy action to avoid bison 1.25 error message */ }
824 | '(' attributes_list ')'
829 | attributes_list attributes_string
834 { lang_set_flags (region, $1, 0); }
836 { lang_set_flags (region, $2, 1); }
840 STARTUP '(' filename ')'
841 { lang_startup($3); }
845 HLL '(' high_level_library_NAME_list ')'
847 { ldemul_hll((char *)NULL); }
850 high_level_library_NAME_list:
851 high_level_library_NAME_list opt_comma filename
858 SYSLIB '(' low_level_library_NAME_list ')'
861 low_level_library_NAME_list:
862 low_level_library_NAME_list opt_comma filename
863 { ldemul_syslib($3); }
867 floating_point_support:
869 { lang_float(true); }
871 { lang_float(false); }
879 | NAME nocrossref_list
881 struct lang_nocrossref *n;
883 n = (struct lang_nocrossref *) xmalloc (sizeof *n);
888 | NAME ',' nocrossref_list
890 struct lang_nocrossref *n;
892 n = (struct lang_nocrossref *) xmalloc (sizeof *n);
899 paren_script_name: { ldlex_script (); }
901 { ldlex_popstate (); $$ = $3; }
903 mustbe_exp: { ldlex_expression (); }
905 { ldlex_popstate (); $$ = $2; }
910 { $$ = exp_unop ('-', $2); }
913 | NEXT '(' exp ')' %prec UNARY
914 { $$ = exp_unop ((int) $1,$3); }
915 | '!' exp %prec UNARY
916 { $$ = exp_unop ('!', $2); }
917 | '+' exp %prec UNARY
919 | '~' exp %prec UNARY
920 { $$ = exp_unop ('~', $2);}
923 { $$ = exp_binop ('*', $1, $3); }
925 { $$ = exp_binop ('/', $1, $3); }
927 { $$ = exp_binop ('%', $1, $3); }
929 { $$ = exp_binop ('+', $1, $3); }
931 { $$ = exp_binop ('-' , $1, $3); }
933 { $$ = exp_binop (LSHIFT , $1, $3); }
935 { $$ = exp_binop (RSHIFT , $1, $3); }
937 { $$ = exp_binop (EQ , $1, $3); }
939 { $$ = exp_binop (NE , $1, $3); }
941 { $$ = exp_binop (LE , $1, $3); }
943 { $$ = exp_binop (GE , $1, $3); }
945 { $$ = exp_binop ('<' , $1, $3); }
947 { $$ = exp_binop ('>' , $1, $3); }
949 { $$ = exp_binop ('&' , $1, $3); }
951 { $$ = exp_binop ('^' , $1, $3); }
953 { $$ = exp_binop ('|' , $1, $3); }
954 | exp '?' exp ':' exp
955 { $$ = exp_trinop ('?' , $1, $3, $5); }
957 { $$ = exp_binop (ANDAND , $1, $3); }
959 { $$ = exp_binop (OROR , $1, $3); }
960 | DEFINED '(' NAME ')'
961 { $$ = exp_nameop (DEFINED, $3); }
963 { $$ = exp_bigintop ($1.integer, $1.str); }
965 { $$ = exp_nameop (SIZEOF_HEADERS,0); }
967 | ALIGNOF paren_script_name
968 { $$ = exp_nameop (ALIGNOF, $2); }
969 | SIZEOF paren_script_name
970 { $$ = exp_nameop (SIZEOF, $2); }
971 | ADDR paren_script_name
972 { $$ = exp_nameop (ADDR, $2); }
973 | LOADADDR paren_script_name
974 { $$ = exp_nameop (LOADADDR, $2); }
975 | CONSTANT '(' NAME ')'
976 { $$ = exp_nameop (CONSTANT,$3); }
977 | ABSOLUTE '(' exp ')'
978 { $$ = exp_unop (ABSOLUTE, $3); }
979 | ALIGN_K '(' exp ')'
980 { $$ = exp_unop (ALIGN_K,$3); }
981 | ALIGN_K '(' exp ',' exp ')'
982 { $$ = exp_binop (ALIGN_K,$3,$5); }
983 | DATA_SEGMENT_ALIGN '(' exp ',' exp ')'
984 { $$ = exp_binop (DATA_SEGMENT_ALIGN, $3, $5); }
985 | DATA_SEGMENT_RELRO_END '(' exp ',' exp ')'
986 { $$ = exp_binop (DATA_SEGMENT_RELRO_END, $5, $3); }
987 | DATA_SEGMENT_END '(' exp ')'
988 { $$ = exp_unop (DATA_SEGMENT_END, $3); }
989 | SEGMENT_START { ldlex_script (); } '(' NAME
990 { ldlex_popstate (); } ',' exp ')'
991 { /* The operands to the expression node are
992 placed in the opposite order from the way
993 in which they appear in the script as
994 that allows us to reuse more code in
996 $$ = exp_binop (SEGMENT_START,
998 exp_nameop (NAME, $4)); }
1000 { $$ = exp_unop (ALIGN_K,$3); }
1002 { $$ = exp_nameop (NAME,$1); }
1003 | MAX_K '(' exp ',' exp ')'
1004 { $$ = exp_binop (MAX_K, $3, $5 ); }
1005 | MIN_K '(' exp ',' exp ')'
1006 { $$ = exp_binop (MIN_K, $3, $5 ); }
1007 | ASSERT_K '(' exp ',' NAME ')'
1008 { $$ = exp_assert ($3, $5); }
1009 | ORIGIN paren_script_name
1010 { $$ = exp_nameop (ORIGIN, $2); }
1011 | LENGTH paren_script_name
1012 { $$ = exp_nameop (LENGTH, $2); }
1013 | LOG2CEIL '(' exp ')'
1014 { $$ = exp_unop (LOG2CEIL, $3); }
1019 AT '>' NAME { $$ = $3; }
1024 AT '(' exp ')' { $$ = $3; }
1029 ALIGN_K '(' exp ')' { $$ = $3; }
1033 opt_align_with_input:
1034 ALIGN_WITH_INPUT { $$ = ALIGN_WITH_INPUT; }
1039 SUBALIGN '(' exp ')' { $$ = $3; }
1044 ONLY_IF_RO { $$ = ONLY_IF_RO; }
1045 | ONLY_IF_RW { $$ = ONLY_IF_RW; }
1046 | SPECIAL { $$ = SPECIAL; }
1051 { ldlex_expression(); }
1055 opt_align_with_input
1061 lang_enter_output_section_statement($1, $3, sectype,
1068 { ldlex_popstate (); }
1069 memspec_opt memspec_at_opt phdr_opt fill_opt
1071 /* fill_opt may have switched the lexer into
1072 expression state, and back again, but in
1073 order to find the end of the fill
1074 expression the parser must look ahead one
1075 token. If it is a NAME, throw it away as
1076 it will have been lexed in the wrong
1083 lang_leave_output_section_statement ($17, $14,
1088 { ldlex_expression (); }
1089 opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
1090 { ldlex_popstate (); }
1093 lang_enter_overlay ($3, $6);
1097 memspec_opt memspec_at_opt phdr_opt fill_opt
1104 lang_leave_overlay ($5, (int) $4,
1105 $15, $12, $14, $13);
1108 | /* The GROUP case is just enough to support the gcc
1109 svr3.ifile script. It is not intended to be full
1110 support. I'm not even sure what GROUP is supposed
1113 { ldlex_expression (); }
1117 lang_add_assignment (exp_assign (".", $3, false));
1119 '{' sec_or_group_p1 '}'
1122 ldfile_open_command_file ($2);
1128 NOLOAD { sectype = noload_section; }
1129 | DSECT { sectype = noalloc_section; }
1130 | COPY { sectype = noalloc_section; }
1131 | INFO { sectype = noalloc_section; }
1132 | OVERLAY { sectype = noalloc_section; }
1133 | READONLY { sectype = readonly_section; }
1138 | /* EMPTY */ { sectype = normal_section; }
1139 | '(' ')' { sectype = normal_section; }
1143 exp atype ':' { $$ = $1; }
1144 | atype ':' { $$ = (etree_type *)NULL; }
1145 | /* The BIND cases are to support the gcc svr3.ifile
1146 script. They aren't intended to implement full
1147 support for the BIND keyword. I'm not even sure
1148 what BIND is supposed to mean. */
1149 BIND '(' exp ')' atype ':' { $$ = $3; }
1150 | BIND '(' exp ')' BLOCK '(' exp ')' atype ':'
1154 opt_exp_without_type:
1155 exp ':' { $$ = $1; }
1156 | ':' { $$ = (etree_type *) NULL; }
1169 | { $$ = DEFAULT_MEMORY_REGION; }
1179 struct lang_output_section_phdr_list *n;
1181 n = ((struct lang_output_section_phdr_list *)
1182 xmalloc (sizeof *n));
1196 lang_enter_overlay_section ($2);
1201 { ldlex_popstate (); }
1209 lang_leave_overlay_section ($9, $8);
1215 PHDRS '{' phdr_list '}'
1224 NAME { ldlex_expression (); }
1225 phdr_type phdr_qualifiers { ldlex_popstate (); }
1228 lang_new_phdr ($1, $3, $4.filehdr, $4.phdrs, $4.at,
1238 if ($1->type.node_class == etree_name
1239 && $1->type.node_code == NAME)
1243 static const char * const phdr_types[] =
1245 "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
1246 "PT_INTERP", "PT_NOTE", "PT_SHLIB",
1252 i < sizeof phdr_types / sizeof phdr_types[0];
1254 if (strcmp (s, phdr_types[i]) == 0)
1259 if (i == sizeof phdr_types / sizeof phdr_types[0])
1261 if (strcmp (s, "PT_GNU_EH_FRAME") == 0)
1262 $$ = exp_intop (0x6474e550);
1263 else if (strcmp (s, "PT_GNU_STACK") == 0)
1264 $$ = exp_intop (0x6474e551);
1268 %X%P:%pS: unknown phdr type `%s' (try integer literal)\n"),
1280 memset (&$$, 0, sizeof (struct phdr_info));
1282 | NAME phdr_val phdr_qualifiers
1285 if (strcmp ($1, "FILEHDR") == 0 && $2 == NULL)
1287 else if (strcmp ($1, "PHDRS") == 0 && $2 == NULL)
1289 else if (strcmp ($1, "FLAGS") == 0 && $2 != NULL)
1292 einfo (_("%X%P:%pS: PHDRS syntax error at `%s'\n"),
1295 | AT '(' exp ')' phdr_qualifiers
1315 ldlex_version_file ();
1316 PUSH_ERROR (_("dynamic list"));
1327 | dynamic_list_nodes dynamic_list_node
1331 '{' dynamic_list_tag '}' ';'
1337 lang_append_dynamic_list (current_dynamic_list_p, $1);
1341 /* This syntax is used within an external version script file. */
1343 version_script_file:
1345 ldlex_version_file ();
1346 PUSH_ERROR (_("VERSION script"));
1355 /* This is used within a normal linker script file. */
1359 ldlex_version_script ();
1361 VERSIONK '{' vers_nodes '}'
1369 | vers_nodes vers_node
1373 '{' vers_tag '}' ';'
1375 lang_register_vers_node (NULL, $2, NULL);
1377 | VERS_TAG '{' vers_tag '}' ';'
1379 lang_register_vers_node ($1, $3, NULL);
1381 | VERS_TAG '{' vers_tag '}' verdep ';'
1383 lang_register_vers_node ($1, $3, $5);
1390 $$ = lang_add_vers_depend (NULL, $1);
1394 $$ = lang_add_vers_depend ($1, $2);
1401 $$ = lang_new_vers_node (NULL, NULL);
1405 $$ = lang_new_vers_node ($1, NULL);
1407 | GLOBAL ':' vers_defns ';'
1409 $$ = lang_new_vers_node ($3, NULL);
1411 | LOCAL ':' vers_defns ';'
1413 $$ = lang_new_vers_node (NULL, $3);
1415 | GLOBAL ':' vers_defns ';' LOCAL ':' vers_defns ';'
1417 $$ = lang_new_vers_node ($3, $7);
1424 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, false);
1428 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, true);
1430 | vers_defns ';' VERS_IDENTIFIER
1432 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, false);
1434 | vers_defns ';' NAME
1436 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, true);
1438 | vers_defns ';' EXTERN NAME '{'
1440 $<name>$ = ldgram_vers_current_lang;
1441 ldgram_vers_current_lang = $4;
1443 vers_defns opt_semicolon '}'
1445 struct bfd_elf_version_expr *pat;
1446 for (pat = $7; pat->next != NULL; pat = pat->next);
1449 ldgram_vers_current_lang = $<name>6;
1453 $<name>$ = ldgram_vers_current_lang;
1454 ldgram_vers_current_lang = $2;
1456 vers_defns opt_semicolon '}'
1459 ldgram_vers_current_lang = $<name>4;
1463 $$ = lang_new_vers_pattern (NULL, "global", ldgram_vers_current_lang, false);
1465 | vers_defns ';' GLOBAL
1467 $$ = lang_new_vers_pattern ($1, "global", ldgram_vers_current_lang, false);
1471 $$ = lang_new_vers_pattern (NULL, "local", ldgram_vers_current_lang, false);
1473 | vers_defns ';' LOCAL
1475 $$ = lang_new_vers_pattern ($1, "local", ldgram_vers_current_lang, false);
1479 $$ = lang_new_vers_pattern (NULL, "extern", ldgram_vers_current_lang, false);
1481 | vers_defns ';' EXTERN
1483 $$ = lang_new_vers_pattern ($1, "extern", ldgram_vers_current_lang, false);
1497 if (ldfile_assumed_script)
1498 einfo (_("%P:%s: file format not recognized; treating as linker script\n"),
1500 if (error_index > 0 && error_index < ERROR_NAME_MAX)
1501 einfo ("%F%P:%pS: %s in %s\n", NULL, arg, error_names[error_index - 1]);
1503 einfo ("%F%P:%pS: %s\n", NULL, arg);