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)); }
424 /* The '*' and '?' cases are there because the lexer returns them as
425 separate tokens rather than as NAME. */
441 wildcard_maybe_exclude:
446 $$.exclude_name_list = NULL;
447 $$.section_flag_list = NULL;
449 | EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name
453 $$.exclude_name_list = $3;
454 $$.section_flag_list = NULL;
459 wildcard_maybe_exclude
460 | SORT_BY_NAME '(' wildcard_maybe_exclude ')'
465 | SORT_NONE '(' wildcard_maybe_exclude ')'
473 wildcard_maybe_exclude
474 | SORT_BY_NAME '(' wildcard_maybe_exclude ')'
479 | SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')'
482 $$.sorted = by_alignment;
484 | SORT_NONE '(' wildcard_maybe_exclude ')'
489 | SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')' ')'
492 $$.sorted = by_name_alignment;
494 | SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_maybe_exclude ')' ')'
499 | SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_maybe_exclude ')' ')'
502 $$.sorted = by_alignment_name;
504 | SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')' ')'
507 $$.sorted = by_alignment;
509 | SORT_BY_INIT_PRIORITY '(' wildcard_maybe_exclude ')'
512 $$.sorted = by_init_priority;
518 struct flag_info_list *n;
519 n = ((struct flag_info_list *) xmalloc (sizeof *n));
522 n->with = without_flags;
527 n->with = with_flags;
534 | sect_flag_list '&' NAME
536 struct flag_info_list *n;
537 n = ((struct flag_info_list *) xmalloc (sizeof *n));
540 n->with = without_flags;
545 n->with = with_flags;
555 INPUT_SECTION_FLAGS '(' sect_flag_list ')'
558 n = ((struct flag_info *) xmalloc (sizeof *n));
560 n->flags_initialized = false;
561 n->not_with_flags = 0;
562 n->only_with_flags = 0;
568 exclude_name_list wildcard_name
570 struct name_list *tmp;
571 tmp = (struct name_list *) xmalloc (sizeof *tmp);
579 struct name_list *tmp;
580 tmp = (struct name_list *) xmalloc (sizeof *tmp);
588 section_name_list opt_comma section_name_spec
590 struct wildcard_list *tmp;
591 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
599 struct wildcard_list *tmp;
600 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
607 input_section_spec_no_keep:
610 struct wildcard_spec tmp;
612 tmp.exclude_name_list = NULL;
614 tmp.section_flag_list = NULL;
615 lang_add_wild (&tmp, NULL, ldgram_had_keep);
619 struct wildcard_spec tmp;
621 tmp.exclude_name_list = NULL;
623 tmp.section_flag_list = $1;
624 lang_add_wild (&tmp, NULL, ldgram_had_keep);
626 | '[' section_name_list ']'
628 lang_add_wild (NULL, $2, ldgram_had_keep);
630 | sect_flags '[' section_name_list ']'
632 struct wildcard_spec tmp;
634 tmp.exclude_name_list = NULL;
636 tmp.section_flag_list = $1;
637 lang_add_wild (&tmp, $3, ldgram_had_keep);
639 | filename_spec '(' section_name_list ')'
641 lang_add_wild (&$1, $3, ldgram_had_keep);
643 | sect_flags filename_spec '(' section_name_list ')'
645 $2.section_flag_list = $1;
646 lang_add_wild (&$2, $4, ldgram_had_keep);
651 input_section_spec_no_keep
653 { ldgram_had_keep = true; }
654 input_section_spec_no_keep ')'
655 { ldgram_had_keep = false; }
660 | assignment separator
661 | CREATE_OBJECT_SYMBOLS
663 lang_add_attribute (lang_object_symbols_statement_enum);
667 lang_add_attribute (lang_constructors_statement_enum);
669 | SORT_BY_NAME '(' CONSTRUCTORS ')'
671 constructors_sorted = true;
672 lang_add_attribute (lang_constructors_statement_enum);
675 | length '(' mustbe_exp ')'
677 lang_add_data ((int) $1, $3);
680 | FILL '(' fill_exp ')'
685 { ldlex_expression (); }
686 '(' exp ',' NAME ')' separator
689 lang_add_assignment (exp_assert ($4, $6));
693 ldfile_open_command_file ($2);
695 statement_list_opt END
699 statement_list statement
724 $$ = exp_get_fill ($1, 0, "fill value");
731 | { $$ = (fill_type *) 0; }
761 lang_add_assignment (exp_assign ($1, $3, false));
763 | NAME assign_op mustbe_exp
765 lang_add_assignment (exp_assign ($1,
771 | HIDDEN '(' NAME '=' mustbe_exp ')'
773 lang_add_assignment (exp_assign ($3, $5, true));
775 | PROVIDE '(' NAME '=' mustbe_exp ')'
777 lang_add_assignment (exp_provide ($3, $5, false));
779 | PROVIDE_HIDDEN '(' NAME '=' mustbe_exp ')'
781 lang_add_assignment (exp_provide ($3, $5, true));
791 MEMORY '{' memory_spec_list_opt '}'
794 memory_spec_list_opt: memory_spec_list | ;
797 memory_spec_list opt_comma memory_spec
803 { region = lang_memory_region_lookup ($1, true); }
805 origin_spec opt_comma length_spec
808 { ldfile_open_command_file ($2); }
809 memory_spec_list_opt END
813 ORIGIN '=' mustbe_exp
815 region->origin_exp = $3;
820 LENGTH '=' mustbe_exp
822 region->length_exp = $3;
828 { /* dummy action to avoid bison 1.25 error message */ }
829 | '(' attributes_list ')'
834 | attributes_list attributes_string
839 { lang_set_flags (region, $1, 0); }
841 { lang_set_flags (region, $2, 1); }
845 STARTUP '(' filename ')'
846 { lang_startup($3); }
850 HLL '(' high_level_library_NAME_list ')'
852 { ldemul_hll((char *)NULL); }
855 high_level_library_NAME_list:
856 high_level_library_NAME_list opt_comma filename
863 SYSLIB '(' low_level_library_NAME_list ')'
866 low_level_library_NAME_list:
867 low_level_library_NAME_list opt_comma filename
868 { ldemul_syslib($3); }
872 floating_point_support:
874 { lang_float(true); }
876 { lang_float(false); }
884 | NAME nocrossref_list
886 struct lang_nocrossref *n;
888 n = (struct lang_nocrossref *) xmalloc (sizeof *n);
893 | NAME ',' nocrossref_list
895 struct lang_nocrossref *n;
897 n = (struct lang_nocrossref *) xmalloc (sizeof *n);
904 paren_script_name: { ldlex_script (); }
906 { ldlex_popstate (); $$ = $3; }
908 mustbe_exp: { ldlex_expression (); }
910 { ldlex_popstate (); $$ = $2; }
915 { $$ = exp_unop ('-', $2); }
918 | NEXT '(' exp ')' %prec UNARY
919 { $$ = exp_unop ((int) $1,$3); }
920 | '!' exp %prec UNARY
921 { $$ = exp_unop ('!', $2); }
922 | '+' exp %prec UNARY
924 | '~' exp %prec UNARY
925 { $$ = exp_unop ('~', $2);}
928 { $$ = exp_binop ('*', $1, $3); }
930 { $$ = exp_binop ('/', $1, $3); }
932 { $$ = exp_binop ('%', $1, $3); }
934 { $$ = exp_binop ('+', $1, $3); }
936 { $$ = exp_binop ('-' , $1, $3); }
938 { $$ = exp_binop (LSHIFT , $1, $3); }
940 { $$ = exp_binop (RSHIFT , $1, $3); }
942 { $$ = exp_binop (EQ , $1, $3); }
944 { $$ = exp_binop (NE , $1, $3); }
946 { $$ = exp_binop (LE , $1, $3); }
948 { $$ = exp_binop (GE , $1, $3); }
950 { $$ = exp_binop ('<' , $1, $3); }
952 { $$ = exp_binop ('>' , $1, $3); }
954 { $$ = exp_binop ('&' , $1, $3); }
956 { $$ = exp_binop ('^' , $1, $3); }
958 { $$ = exp_binop ('|' , $1, $3); }
959 | exp '?' exp ':' exp
960 { $$ = exp_trinop ('?' , $1, $3, $5); }
962 { $$ = exp_binop (ANDAND , $1, $3); }
964 { $$ = exp_binop (OROR , $1, $3); }
965 | DEFINED '(' NAME ')'
966 { $$ = exp_nameop (DEFINED, $3); }
968 { $$ = exp_bigintop ($1.integer, $1.str); }
970 { $$ = exp_nameop (SIZEOF_HEADERS,0); }
972 | ALIGNOF paren_script_name
973 { $$ = exp_nameop (ALIGNOF, $2); }
974 | SIZEOF paren_script_name
975 { $$ = exp_nameop (SIZEOF, $2); }
976 | ADDR paren_script_name
977 { $$ = exp_nameop (ADDR, $2); }
978 | LOADADDR paren_script_name
979 { $$ = exp_nameop (LOADADDR, $2); }
980 | CONSTANT '(' NAME ')'
981 { $$ = exp_nameop (CONSTANT,$3); }
982 | ABSOLUTE '(' exp ')'
983 { $$ = exp_unop (ABSOLUTE, $3); }
984 | ALIGN_K '(' exp ')'
985 { $$ = exp_unop (ALIGN_K,$3); }
986 | ALIGN_K '(' exp ',' exp ')'
987 { $$ = exp_binop (ALIGN_K,$3,$5); }
988 | DATA_SEGMENT_ALIGN '(' exp ',' exp ')'
989 { $$ = exp_binop (DATA_SEGMENT_ALIGN, $3, $5); }
990 | DATA_SEGMENT_RELRO_END '(' exp ',' exp ')'
991 { $$ = exp_binop (DATA_SEGMENT_RELRO_END, $5, $3); }
992 | DATA_SEGMENT_END '(' exp ')'
993 { $$ = exp_unop (DATA_SEGMENT_END, $3); }
994 | SEGMENT_START { ldlex_script (); } '(' NAME
995 { ldlex_popstate (); } ',' exp ')'
996 { /* The operands to the expression node are
997 placed in the opposite order from the way
998 in which they appear in the script as
999 that allows us to reuse more code in
1001 $$ = exp_binop (SEGMENT_START,
1003 exp_nameop (NAME, $4)); }
1005 { $$ = exp_unop (ALIGN_K,$3); }
1007 { $$ = exp_nameop (NAME,$1); }
1008 | MAX_K '(' exp ',' exp ')'
1009 { $$ = exp_binop (MAX_K, $3, $5 ); }
1010 | MIN_K '(' exp ',' exp ')'
1011 { $$ = exp_binop (MIN_K, $3, $5 ); }
1012 | ASSERT_K '(' exp ',' NAME ')'
1013 { $$ = exp_assert ($3, $5); }
1014 | ORIGIN paren_script_name
1015 { $$ = exp_nameop (ORIGIN, $2); }
1016 | LENGTH paren_script_name
1017 { $$ = exp_nameop (LENGTH, $2); }
1018 | LOG2CEIL '(' exp ')'
1019 { $$ = exp_unop (LOG2CEIL, $3); }
1024 AT '>' NAME { $$ = $3; }
1029 AT '(' exp ')' { $$ = $3; }
1034 ALIGN_K '(' exp ')' { $$ = $3; }
1038 opt_align_with_input:
1039 ALIGN_WITH_INPUT { $$ = ALIGN_WITH_INPUT; }
1044 SUBALIGN '(' exp ')' { $$ = $3; }
1049 ONLY_IF_RO { $$ = ONLY_IF_RO; }
1050 | ONLY_IF_RW { $$ = ONLY_IF_RW; }
1051 | SPECIAL { $$ = SPECIAL; }
1056 { ldlex_expression(); }
1060 opt_align_with_input
1066 lang_enter_output_section_statement($1, $3, sectype,
1073 { ldlex_popstate (); }
1074 memspec_opt memspec_at_opt phdr_opt fill_opt
1076 lang_leave_output_section_statement ($17, $14,
1081 { ldlex_expression (); }
1082 opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
1083 { ldlex_popstate (); }
1086 lang_enter_overlay ($3, $6);
1090 memspec_opt memspec_at_opt phdr_opt fill_opt
1092 lang_leave_overlay ($5, (int) $4,
1093 $15, $12, $14, $13);
1096 | /* The GROUP case is just enough to support the gcc
1097 svr3.ifile script. It is not intended to be full
1098 support. I'm not even sure what GROUP is supposed
1101 { ldlex_expression (); }
1105 lang_add_assignment (exp_assign (".", $3, false));
1107 '{' sec_or_group_p1 '}'
1110 ldfile_open_command_file ($2);
1116 NOLOAD { sectype = noload_section; }
1117 | DSECT { sectype = noalloc_section; }
1118 | COPY { sectype = noalloc_section; }
1119 | INFO { sectype = noalloc_section; }
1120 | OVERLAY { sectype = noalloc_section; }
1121 | READONLY { sectype = readonly_section; }
1126 | /* EMPTY */ { sectype = normal_section; }
1127 | '(' ')' { sectype = normal_section; }
1131 exp atype ':' { $$ = $1; }
1132 | atype ':' { $$ = (etree_type *)NULL; }
1133 | /* The BIND cases are to support the gcc svr3.ifile
1134 script. They aren't intended to implement full
1135 support for the BIND keyword. I'm not even sure
1136 what BIND is supposed to mean. */
1137 BIND '(' exp ')' atype ':' { $$ = $3; }
1138 | BIND '(' exp ')' BLOCK '(' exp ')' atype ':'
1142 opt_exp_without_type:
1143 exp ':' { $$ = $1; }
1144 | ':' { $$ = (etree_type *) NULL; }
1157 | { $$ = DEFAULT_MEMORY_REGION; }
1167 struct lang_output_section_phdr_list *n;
1169 n = ((struct lang_output_section_phdr_list *)
1170 xmalloc (sizeof *n));
1184 lang_enter_overlay_section ($2);
1189 { ldlex_popstate (); }
1192 lang_leave_overlay_section ($9, $8);
1198 PHDRS '{' phdr_list '}'
1207 NAME { ldlex_expression (); }
1208 phdr_type phdr_qualifiers { ldlex_popstate (); }
1211 lang_new_phdr ($1, $3, $4.filehdr, $4.phdrs, $4.at,
1221 if ($1->type.node_class == etree_name
1222 && $1->type.node_code == NAME)
1226 static const char * const phdr_types[] =
1228 "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
1229 "PT_INTERP", "PT_NOTE", "PT_SHLIB",
1235 i < sizeof phdr_types / sizeof phdr_types[0];
1237 if (strcmp (s, phdr_types[i]) == 0)
1242 if (i == sizeof phdr_types / sizeof phdr_types[0])
1244 if (strcmp (s, "PT_GNU_EH_FRAME") == 0)
1245 $$ = exp_intop (0x6474e550);
1246 else if (strcmp (s, "PT_GNU_STACK") == 0)
1247 $$ = exp_intop (0x6474e551);
1251 %X%P:%pS: unknown phdr type `%s' (try integer literal)\n"),
1263 memset (&$$, 0, sizeof (struct phdr_info));
1265 | NAME phdr_val phdr_qualifiers
1268 if (strcmp ($1, "FILEHDR") == 0 && $2 == NULL)
1270 else if (strcmp ($1, "PHDRS") == 0 && $2 == NULL)
1272 else if (strcmp ($1, "FLAGS") == 0 && $2 != NULL)
1275 einfo (_("%X%P:%pS: PHDRS syntax error at `%s'\n"),
1278 | AT '(' exp ')' phdr_qualifiers
1298 ldlex_version_file ();
1299 PUSH_ERROR (_("dynamic list"));
1310 | dynamic_list_nodes dynamic_list_node
1314 '{' dynamic_list_tag '}' ';'
1320 lang_append_dynamic_list (current_dynamic_list_p, $1);
1324 /* This syntax is used within an external version script file. */
1326 version_script_file:
1328 ldlex_version_file ();
1329 PUSH_ERROR (_("VERSION script"));
1338 /* This is used within a normal linker script file. */
1342 ldlex_version_script ();
1344 VERSIONK '{' vers_nodes '}'
1352 | vers_nodes vers_node
1356 '{' vers_tag '}' ';'
1358 lang_register_vers_node (NULL, $2, NULL);
1360 | VERS_TAG '{' vers_tag '}' ';'
1362 lang_register_vers_node ($1, $3, NULL);
1364 | VERS_TAG '{' vers_tag '}' verdep ';'
1366 lang_register_vers_node ($1, $3, $5);
1373 $$ = lang_add_vers_depend (NULL, $1);
1377 $$ = lang_add_vers_depend ($1, $2);
1384 $$ = lang_new_vers_node (NULL, NULL);
1388 $$ = lang_new_vers_node ($1, NULL);
1390 | GLOBAL ':' vers_defns ';'
1392 $$ = lang_new_vers_node ($3, NULL);
1394 | LOCAL ':' vers_defns ';'
1396 $$ = lang_new_vers_node (NULL, $3);
1398 | GLOBAL ':' vers_defns ';' LOCAL ':' vers_defns ';'
1400 $$ = lang_new_vers_node ($3, $7);
1407 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, false);
1411 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, true);
1413 | vers_defns ';' VERS_IDENTIFIER
1415 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, false);
1417 | vers_defns ';' NAME
1419 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, true);
1421 | vers_defns ';' EXTERN NAME '{'
1423 $<name>$ = ldgram_vers_current_lang;
1424 ldgram_vers_current_lang = $4;
1426 vers_defns opt_semicolon '}'
1428 struct bfd_elf_version_expr *pat;
1429 for (pat = $7; pat->next != NULL; pat = pat->next);
1432 ldgram_vers_current_lang = $<name>6;
1436 $<name>$ = ldgram_vers_current_lang;
1437 ldgram_vers_current_lang = $2;
1439 vers_defns opt_semicolon '}'
1442 ldgram_vers_current_lang = $<name>4;
1446 $$ = lang_new_vers_pattern (NULL, "global", ldgram_vers_current_lang, false);
1448 | vers_defns ';' GLOBAL
1450 $$ = lang_new_vers_pattern ($1, "global", ldgram_vers_current_lang, false);
1454 $$ = lang_new_vers_pattern (NULL, "local", ldgram_vers_current_lang, false);
1456 | vers_defns ';' LOCAL
1458 $$ = lang_new_vers_pattern ($1, "local", ldgram_vers_current_lang, false);
1462 $$ = lang_new_vers_pattern (NULL, "extern", ldgram_vers_current_lang, false);
1464 | vers_defns ';' EXTERN
1466 $$ = lang_new_vers_pattern ($1, "extern", ldgram_vers_current_lang, false);
1480 if (ldfile_assumed_script)
1481 einfo (_("%P:%s: file format not recognized; treating as linker script\n"),
1483 if (error_index > 0 && error_index < ERROR_NAME_MAX)
1484 einfo ("%F%P:%pS: %s in %s\n", NULL, arg, error_names[error_index - 1]);
1486 einfo ("%F%P:%pS: %s\n", NULL, arg);