1 /* A YACC grammar to parse a superset of the AT&T linker scripting language.
2 Copyright 1991-2013 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
48 static enum section_type sectype;
49 static lang_memory_region_type *region;
51 bfd_boolean ldgram_had_keep = FALSE;
52 char *ldgram_vers_current_lang = NULL;
54 #define ERROR_NAME_MAX 20
55 static char *error_names[ERROR_NAME_MAX];
56 static int error_index;
57 #define PUSH_ERROR(x) if (error_index < ERROR_NAME_MAX) error_names[error_index] = x; error_index++;
58 #define POP_ERROR() error_index--;
70 struct wildcard_spec wildcard;
71 struct wildcard_list *wildcard_list;
72 struct name_list *name_list;
73 struct flag_info_list *flag_info_list;
74 struct flag_info *flag_info;
76 union etree_union *etree;
81 union etree_union *at;
82 union etree_union *flags;
84 struct lang_nocrossref *nocrossref;
85 struct lang_output_section_phdr_list *section_phdr;
86 struct bfd_elf_version_deps *deflist;
87 struct bfd_elf_version_expr *versyms;
88 struct bfd_elf_version_tree *versnode;
91 %type <etree> exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val
92 %type <etree> opt_exp_without_type opt_subalign opt_align
93 %type <fill> fill_opt fill_exp
94 %type <name_list> exclude_name_list
95 %type <wildcard_list> file_NAME_list
96 %type <flag_info_list> sect_flag_list
97 %type <flag_info> sect_flags
98 %type <name> memspec_opt casesymlist
99 %type <name> memspec_at_opt
100 %type <cname> wildcard_name
101 %type <wildcard> wildcard_spec
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
140 %token NOLOAD DSECT COPY INFO OVERLAY
141 %token DEFINED TARGET_K SEARCH_DIR MAP ENTRY
142 %token <integer> NEXT
143 %token SIZEOF ALIGNOF ADDR LOADADDR MAX_K MIN_K
144 %token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS
146 %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS
147 %token ALIGNMOD AT SUBALIGN HIDDEN PROVIDE PROVIDE_HIDDEN AS_NEEDED
148 %type <token> assign_op atype attributes_opt sect_constraint opt_align_with_input
149 %type <name> filename
150 %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K
151 %token FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL
152 %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START
153 %token <name> VERS_TAG VERS_IDENTIFIER
154 %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT
155 %token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL INPUT_SECTION_FLAGS ALIGN_WITH_INPUT
158 %type <versyms> vers_defns
159 %type <versnode> vers_tag
160 %type <deflist> verdep
161 %token INPUT_DYNAMIC_LIST
166 INPUT_SCRIPT script_file
167 | INPUT_MRI_SCRIPT mri_script_file
168 | INPUT_VERSION_SCRIPT version_script_file
169 | INPUT_DYNAMIC_LIST dynamic_list_file
170 | INPUT_DEFSYM defsym_expr
182 lang_add_assignment (exp_defsym ($2, $4));
186 /* SYNTAX WITHIN AN MRI SCRIPT FILE */
190 PUSH_ERROR (_("MRI style script"));
201 mri_script_lines mri_script_command NEWLINE
209 einfo(_("%P%F: unrecognised keyword in MRI style script '%s'\n"),$1);
212 config.map_filename = "-";
214 | ORDER ordernamelist
216 | PUBLIC NAME '=' exp
217 { mri_public($2, $4); }
218 | PUBLIC NAME ',' exp
219 { mri_public($2, $4); }
221 { mri_public($2, $3); }
225 { mri_output_section($2, $4);}
227 { mri_output_section($2, $3);}
229 { mri_output_section($2, $4);}
230 | ALIGN_K NAME '=' exp
231 { mri_align($2,$4); }
232 | ALIGN_K NAME ',' exp
233 { mri_align($2,$4); }
234 | ALIGNMOD NAME '=' exp
235 { mri_alignmod($2,$4); }
236 | ALIGNMOD NAME ',' exp
237 { mri_alignmod($2,$4); }
238 | ABSOLUTE mri_abs_name_list
239 | LOAD mri_load_name_list
242 | ALIAS NAME ',' NAME
243 { mri_alias($2,$4,0);}
245 { mri_alias ($2, 0, (int) $4.integer); }
249 { mri_truncate ((unsigned int) $2.integer); }
251 | EXTERN extern_name_list
253 { ldlex_script (); ldfile_open_command_file($2); }
255 { ldlex_popstate (); }
257 { lang_add_entry ($2, FALSE); }
262 ordernamelist ',' NAME { mri_order($3); }
263 | ordernamelist NAME { mri_order($2); }
270 | mri_load_name_list ',' NAME { mri_load($3); }
275 { mri_only_load($1); }
276 | mri_abs_name_list ',' NAME
277 { mri_only_load($3); }
281 /* empty */ { $$ = NULL; }
283 | casesymlist ',' NAME
286 /* Parsed as expressions so that commas separate entries */
288 { ldlex_expression (); }
289 extern_name_list_body
290 { ldlex_popstate (); }
292 extern_name_list_body:
294 { ldlang_add_undef ($1, FALSE); }
295 | extern_name_list_body NAME
296 { ldlang_add_undef ($2, FALSE); }
297 | extern_name_list_body ',' NAME
298 { ldlang_add_undef ($3, FALSE); }
304 { ldlex_popstate(); }
320 | floating_point_support
324 | TARGET_K '(' NAME ')'
325 { lang_add_target($3); }
326 | SEARCH_DIR '(' filename ')'
327 { ldfile_add_library_path ($3, FALSE); }
328 | OUTPUT '(' filename ')'
329 { lang_add_output($3, 1); }
330 | OUTPUT_FORMAT '(' NAME ')'
331 { lang_add_output_format ($3, (char *) NULL,
333 | OUTPUT_FORMAT '(' NAME ',' NAME ',' NAME ')'
334 { lang_add_output_format ($3, $5, $7, 1); }
335 | OUTPUT_ARCH '(' NAME ')'
336 { ldfile_set_output_arch ($3, bfd_arch_unknown); }
337 | FORCE_COMMON_ALLOCATION
338 { command_line.force_common_definition = TRUE ; }
339 | INHIBIT_COMMON_ALLOCATION
340 { command_line.inhibit_common_definition = TRUE ; }
341 | INPUT '(' input_list ')'
343 { lang_enter_group (); }
345 { lang_leave_group (); }
346 | MAP '(' filename ')'
347 { lang_add_map($3); }
349 { ldlex_script (); ldfile_open_command_file($2); }
351 { ldlex_popstate (); }
352 | NOCROSSREFS '(' nocrossref_list ')'
354 lang_add_nocrossref ($3);
356 | EXTERN '(' extern_name_list ')'
357 | INSERT_K AFTER NAME
358 { lang_add_insert ($3, 0); }
359 | INSERT_K BEFORE NAME
360 { lang_add_insert ($3, 1); }
361 | REGION_ALIAS '(' NAME ',' NAME ')'
362 { lang_memory_region_alias ($3, $5); }
363 | LD_FEATURE '(' NAME ')'
364 { lang_ld_feature ($3); }
369 { lang_add_input_file($1,lang_input_file_is_search_file_enum,
371 | input_list ',' NAME
372 { lang_add_input_file($3,lang_input_file_is_search_file_enum,
375 { lang_add_input_file($2,lang_input_file_is_search_file_enum,
378 { lang_add_input_file($1,lang_input_file_is_l_enum,
380 | input_list ',' LNAME
381 { lang_add_input_file($3,lang_input_file_is_l_enum,
384 { lang_add_input_file($2,lang_input_file_is_l_enum,
387 { $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
388 input_flags.add_DT_NEEDED_for_regular = TRUE; }
390 { input_flags.add_DT_NEEDED_for_regular = $<integer>3; }
391 | input_list ',' AS_NEEDED '('
392 { $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
393 input_flags.add_DT_NEEDED_for_regular = TRUE; }
395 { input_flags.add_DT_NEEDED_for_regular = $<integer>5; }
396 | input_list AS_NEEDED '('
397 { $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
398 input_flags.add_DT_NEEDED_for_regular = TRUE; }
400 { input_flags.add_DT_NEEDED_for_regular = $<integer>4; }
404 SECTIONS '{' sec_or_group_p1 '}'
408 sec_or_group_p1 section
409 | sec_or_group_p1 statement_anywhere
415 { lang_add_entry ($3, FALSE); }
417 | ASSERT_K {ldlex_expression ();} '(' exp ',' NAME ')'
419 lang_add_assignment (exp_assert ($4, $6)); }
422 /* The '*' and '?' cases are there because the lexer returns them as
423 separate tokens rather than as NAME. */
444 $$.exclude_name_list = NULL;
445 $$.section_flag_list = NULL;
447 | EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name
451 $$.exclude_name_list = $3;
452 $$.section_flag_list = NULL;
454 | SORT_BY_NAME '(' wildcard_name ')'
458 $$.exclude_name_list = NULL;
459 $$.section_flag_list = NULL;
461 | SORT_BY_ALIGNMENT '(' wildcard_name ')'
464 $$.sorted = by_alignment;
465 $$.exclude_name_list = NULL;
466 $$.section_flag_list = NULL;
468 | SORT_NONE '(' wildcard_name ')'
472 $$.exclude_name_list = NULL;
473 $$.section_flag_list = NULL;
475 | SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')'
478 $$.sorted = by_name_alignment;
479 $$.exclude_name_list = NULL;
480 $$.section_flag_list = NULL;
482 | SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_name ')' ')'
486 $$.exclude_name_list = NULL;
487 $$.section_flag_list = NULL;
489 | SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_name ')' ')'
492 $$.sorted = by_alignment_name;
493 $$.exclude_name_list = NULL;
494 $$.section_flag_list = NULL;
496 | SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')'
499 $$.sorted = by_alignment;
500 $$.exclude_name_list = NULL;
501 $$.section_flag_list = NULL;
503 | SORT_BY_NAME '(' EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name ')'
507 $$.exclude_name_list = $5;
508 $$.section_flag_list = NULL;
510 | SORT_BY_INIT_PRIORITY '(' wildcard_name ')'
513 $$.sorted = by_init_priority;
514 $$.exclude_name_list = NULL;
515 $$.section_flag_list = NULL;
521 struct flag_info_list *n;
522 n = ((struct flag_info_list *) xmalloc (sizeof *n));
525 n->with = without_flags;
530 n->with = with_flags;
537 | sect_flag_list '&' NAME
539 struct flag_info_list *n;
540 n = ((struct flag_info_list *) xmalloc (sizeof *n));
543 n->with = without_flags;
548 n->with = with_flags;
558 INPUT_SECTION_FLAGS '(' sect_flag_list ')'
561 n = ((struct flag_info *) xmalloc (sizeof *n));
563 n->flags_initialized = FALSE;
564 n->not_with_flags = 0;
565 n->only_with_flags = 0;
571 exclude_name_list wildcard_name
573 struct name_list *tmp;
574 tmp = (struct name_list *) xmalloc (sizeof *tmp);
582 struct name_list *tmp;
583 tmp = (struct name_list *) xmalloc (sizeof *tmp);
591 file_NAME_list opt_comma wildcard_spec
593 struct wildcard_list *tmp;
594 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
602 struct wildcard_list *tmp;
603 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
610 input_section_spec_no_keep:
613 struct wildcard_spec tmp;
615 tmp.exclude_name_list = NULL;
617 tmp.section_flag_list = NULL;
618 lang_add_wild (&tmp, NULL, ldgram_had_keep);
622 struct wildcard_spec tmp;
624 tmp.exclude_name_list = NULL;
626 tmp.section_flag_list = $1;
627 lang_add_wild (&tmp, NULL, ldgram_had_keep);
629 | '[' file_NAME_list ']'
631 lang_add_wild (NULL, $2, ldgram_had_keep);
633 | sect_flags '[' file_NAME_list ']'
635 struct wildcard_spec tmp;
637 tmp.exclude_name_list = NULL;
639 tmp.section_flag_list = $1;
640 lang_add_wild (&tmp, $3, ldgram_had_keep);
642 | wildcard_spec '(' file_NAME_list ')'
644 lang_add_wild (&$1, $3, ldgram_had_keep);
646 | sect_flags wildcard_spec '(' file_NAME_list ')'
648 $2.section_flag_list = $1;
649 lang_add_wild (&$2, $4, ldgram_had_keep);
654 input_section_spec_no_keep
656 { ldgram_had_keep = TRUE; }
657 input_section_spec_no_keep ')'
658 { ldgram_had_keep = FALSE; }
663 | CREATE_OBJECT_SYMBOLS
665 lang_add_attribute(lang_object_symbols_statement_enum);
671 lang_add_attribute(lang_constructors_statement_enum);
673 | SORT_BY_NAME '(' CONSTRUCTORS ')'
675 constructors_sorted = TRUE;
676 lang_add_attribute (lang_constructors_statement_enum);
679 | length '(' mustbe_exp ')'
681 lang_add_data ((int) $1, $3);
684 | FILL '(' fill_exp ')'
688 | ASSERT_K {ldlex_expression ();} '(' exp ',' NAME ')' end
690 lang_add_assignment (exp_assert ($4, $6)); }
692 { ldlex_script (); ldfile_open_command_file($2); }
693 statement_list_opt END
694 { ldlex_popstate (); }
698 statement_list statement
723 $$ = exp_get_fill ($1, 0, "fill value");
730 | { $$ = (fill_type *) 0; }
760 lang_add_assignment (exp_assign ($1, $3, FALSE));
762 | NAME assign_op mustbe_exp
764 lang_add_assignment (exp_assign ($1,
770 | HIDDEN '(' NAME '=' mustbe_exp ')'
772 lang_add_assignment (exp_assign ($3, $5, TRUE));
774 | PROVIDE '(' NAME '=' mustbe_exp ')'
776 lang_add_assignment (exp_provide ($3, $5, FALSE));
778 | PROVIDE_HIDDEN '(' NAME '=' mustbe_exp ')'
780 lang_add_assignment (exp_provide ($3, $5, TRUE));
790 MEMORY '{' memory_spec_list_opt '}'
793 memory_spec_list_opt: memory_spec_list | ;
796 memory_spec_list opt_comma memory_spec
802 { region = lang_memory_region_lookup ($1, TRUE); }
804 origin_spec opt_comma length_spec
807 { ldlex_script (); ldfile_open_command_file($2); }
808 memory_spec_list_opt END
809 { ldlex_popstate (); }
813 ORIGIN '=' mustbe_exp
815 region->origin = exp_get_vma ($3, 0, "origin");
816 region->current = region->origin;
821 LENGTH '=' mustbe_exp
823 region->length = exp_get_vma ($3, -1, "length");
829 { /* dummy action to avoid bison 1.25 error message */ }
830 | '(' attributes_list ')'
835 | attributes_list attributes_string
840 { lang_set_flags (region, $1, 0); }
842 { lang_set_flags (region, $2, 1); }
846 STARTUP '(' filename ')'
847 { lang_startup($3); }
851 HLL '(' high_level_library_NAME_list ')'
853 { ldemul_hll((char *)NULL); }
856 high_level_library_NAME_list:
857 high_level_library_NAME_list opt_comma filename
865 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 mustbe_exp: { ldlex_expression (); }
906 { ldlex_popstate (); $$=$2;}
911 { $$ = exp_unop ('-', $2); }
914 | NEXT '(' exp ')' %prec UNARY
915 { $$ = exp_unop ((int) $1,$3); }
916 | '!' exp %prec UNARY
917 { $$ = exp_unop ('!', $2); }
918 | '+' exp %prec UNARY
920 | '~' exp %prec UNARY
921 { $$ = exp_unop ('~', $2);}
924 { $$ = exp_binop ('*', $1, $3); }
926 { $$ = exp_binop ('/', $1, $3); }
928 { $$ = exp_binop ('%', $1, $3); }
930 { $$ = exp_binop ('+', $1, $3); }
932 { $$ = exp_binop ('-' , $1, $3); }
934 { $$ = exp_binop (LSHIFT , $1, $3); }
936 { $$ = exp_binop (RSHIFT , $1, $3); }
938 { $$ = exp_binop (EQ , $1, $3); }
940 { $$ = exp_binop (NE , $1, $3); }
942 { $$ = exp_binop (LE , $1, $3); }
944 { $$ = exp_binop (GE , $1, $3); }
946 { $$ = exp_binop ('<' , $1, $3); }
948 { $$ = exp_binop ('>' , $1, $3); }
950 { $$ = exp_binop ('&' , $1, $3); }
952 { $$ = exp_binop ('^' , $1, $3); }
954 { $$ = exp_binop ('|' , $1, $3); }
955 | exp '?' exp ':' exp
956 { $$ = exp_trinop ('?' , $1, $3, $5); }
958 { $$ = exp_binop (ANDAND , $1, $3); }
960 { $$ = exp_binop (OROR , $1, $3); }
961 | DEFINED '(' NAME ')'
962 { $$ = exp_nameop (DEFINED, $3); }
964 { $$ = exp_bigintop ($1.integer, $1.str); }
966 { $$ = exp_nameop (SIZEOF_HEADERS,0); }
968 | ALIGNOF '(' NAME ')'
969 { $$ = exp_nameop (ALIGNOF,$3); }
970 | SIZEOF '(' NAME ')'
971 { $$ = exp_nameop (SIZEOF,$3); }
973 { $$ = exp_nameop (ADDR,$3); }
974 | LOADADDR '(' NAME ')'
975 { $$ = exp_nameop (LOADADDR,$3); }
976 | CONSTANT '(' NAME ')'
977 { $$ = exp_nameop (CONSTANT,$3); }
978 | ABSOLUTE '(' exp ')'
979 { $$ = exp_unop (ABSOLUTE, $3); }
980 | ALIGN_K '(' exp ')'
981 { $$ = exp_unop (ALIGN_K,$3); }
982 | ALIGN_K '(' exp ',' exp ')'
983 { $$ = exp_binop (ALIGN_K,$3,$5); }
984 | DATA_SEGMENT_ALIGN '(' exp ',' exp ')'
985 { $$ = exp_binop (DATA_SEGMENT_ALIGN, $3, $5); }
986 | DATA_SEGMENT_RELRO_END '(' exp ',' exp ')'
987 { $$ = exp_binop (DATA_SEGMENT_RELRO_END, $5, $3); }
988 | DATA_SEGMENT_END '(' exp ')'
989 { $$ = exp_unop (DATA_SEGMENT_END, $3); }
990 | SEGMENT_START '(' NAME ',' 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, $3)); }
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 '(' NAME ')'
1010 { $$ = exp_nameop (ORIGIN, $3); }
1011 | LENGTH '(' NAME ')'
1012 { $$ = exp_nameop (LENGTH, $3); }
1017 AT '>' NAME { $$ = $3; }
1022 AT '(' exp ')' { $$ = $3; }
1027 ALIGN_K '(' exp ')' { $$ = $3; }
1031 opt_align_with_input:
1032 ALIGN_WITH_INPUT { $$ = ALIGN_WITH_INPUT; }
1037 SUBALIGN '(' exp ')' { $$ = $3; }
1042 ONLY_IF_RO { $$ = ONLY_IF_RO; }
1043 | ONLY_IF_RW { $$ = ONLY_IF_RW; }
1044 | SPECIAL { $$ = SPECIAL; }
1048 section: NAME { ldlex_expression(); }
1052 opt_align_with_input
1053 opt_subalign { ldlex_popstate (); ldlex_script (); }
1057 lang_enter_output_section_statement($1, $3,
1059 $5, $7, $4, $9, $6);
1062 '}' { ldlex_popstate (); ldlex_expression (); }
1063 memspec_opt memspec_at_opt phdr_opt fill_opt
1066 lang_leave_output_section_statement ($18, $15, $17, $16);
1071 { ldlex_expression (); }
1072 opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
1073 { ldlex_popstate (); ldlex_script (); }
1076 lang_enter_overlay ($3, $6);
1080 { ldlex_popstate (); ldlex_expression (); }
1081 memspec_opt memspec_at_opt phdr_opt fill_opt
1084 lang_leave_overlay ($5, (int) $4,
1085 $16, $13, $15, $14);
1088 | /* The GROUP case is just enough to support the gcc
1089 svr3.ifile script. It is not intended to be full
1090 support. I'm not even sure what GROUP is supposed
1092 GROUP { ldlex_expression (); }
1096 lang_add_assignment (exp_assign (".", $3, FALSE));
1098 '{' sec_or_group_p1 '}'
1100 { ldlex_script (); ldfile_open_command_file($2); }
1102 { ldlex_popstate (); }
1106 NOLOAD { sectype = noload_section; }
1107 | DSECT { sectype = noalloc_section; }
1108 | COPY { sectype = noalloc_section; }
1109 | INFO { sectype = noalloc_section; }
1110 | OVERLAY { sectype = noalloc_section; }
1115 | /* EMPTY */ { sectype = normal_section; }
1116 | '(' ')' { sectype = normal_section; }
1120 exp atype ':' { $$ = $1; }
1121 | atype ':' { $$ = (etree_type *)NULL; }
1122 | /* The BIND cases are to support the gcc svr3.ifile
1123 script. They aren't intended to implement full
1124 support for the BIND keyword. I'm not even sure
1125 what BIND is supposed to mean. */
1126 BIND '(' exp ')' atype ':' { $$ = $3; }
1127 | BIND '(' exp ')' BLOCK '(' exp ')' atype ':'
1131 opt_exp_without_type:
1132 exp ':' { $$ = $1; }
1133 | ':' { $$ = (etree_type *) NULL; }
1146 | { $$ = DEFAULT_MEMORY_REGION; }
1156 struct lang_output_section_phdr_list *n;
1158 n = ((struct lang_output_section_phdr_list *)
1159 xmalloc (sizeof *n));
1173 lang_enter_overlay_section ($2);
1175 '{' statement_list_opt '}'
1176 { ldlex_popstate (); ldlex_expression (); }
1180 lang_leave_overlay_section ($9, $8);
1186 PHDRS '{' phdr_list '}'
1195 NAME { ldlex_expression (); }
1196 phdr_type phdr_qualifiers { ldlex_popstate (); }
1199 lang_new_phdr ($1, $3, $4.filehdr, $4.phdrs, $4.at,
1209 if ($1->type.node_class == etree_name
1210 && $1->type.node_code == NAME)
1214 static const char * const phdr_types[] =
1216 "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
1217 "PT_INTERP", "PT_NOTE", "PT_SHLIB",
1223 i < sizeof phdr_types / sizeof phdr_types[0];
1225 if (strcmp (s, phdr_types[i]) == 0)
1230 if (i == sizeof phdr_types / sizeof phdr_types[0])
1232 if (strcmp (s, "PT_GNU_EH_FRAME") == 0)
1233 $$ = exp_intop (0x6474e550);
1234 else if (strcmp (s, "PT_GNU_STACK") == 0)
1235 $$ = exp_intop (0x6474e551);
1239 %X%P:%S: unknown phdr type `%s' (try integer literal)\n"),
1251 memset (&$$, 0, sizeof (struct phdr_info));
1253 | NAME phdr_val phdr_qualifiers
1256 if (strcmp ($1, "FILEHDR") == 0 && $2 == NULL)
1258 else if (strcmp ($1, "PHDRS") == 0 && $2 == NULL)
1260 else if (strcmp ($1, "FLAGS") == 0 && $2 != NULL)
1263 einfo (_("%X%P:%S: PHDRS syntax error at `%s'\n"),
1266 | AT '(' exp ')' phdr_qualifiers
1286 ldlex_version_file ();
1287 PUSH_ERROR (_("dynamic list"));
1298 | dynamic_list_nodes dynamic_list_node
1302 '{' dynamic_list_tag '}' ';'
1308 lang_append_dynamic_list ($1);
1312 /* This syntax is used within an external version script file. */
1314 version_script_file:
1316 ldlex_version_file ();
1317 PUSH_ERROR (_("VERSION script"));
1326 /* This is used within a normal linker script file. */
1330 ldlex_version_script ();
1332 VERSIONK '{' vers_nodes '}'
1340 | vers_nodes vers_node
1344 '{' vers_tag '}' ';'
1346 lang_register_vers_node (NULL, $2, NULL);
1348 | VERS_TAG '{' vers_tag '}' ';'
1350 lang_register_vers_node ($1, $3, NULL);
1352 | VERS_TAG '{' vers_tag '}' verdep ';'
1354 lang_register_vers_node ($1, $3, $5);
1361 $$ = lang_add_vers_depend (NULL, $1);
1365 $$ = lang_add_vers_depend ($1, $2);
1372 $$ = lang_new_vers_node (NULL, NULL);
1376 $$ = lang_new_vers_node ($1, NULL);
1378 | GLOBAL ':' vers_defns ';'
1380 $$ = lang_new_vers_node ($3, NULL);
1382 | LOCAL ':' vers_defns ';'
1384 $$ = lang_new_vers_node (NULL, $3);
1386 | GLOBAL ':' vers_defns ';' LOCAL ':' vers_defns ';'
1388 $$ = lang_new_vers_node ($3, $7);
1395 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, FALSE);
1399 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, TRUE);
1401 | vers_defns ';' VERS_IDENTIFIER
1403 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, FALSE);
1405 | vers_defns ';' NAME
1407 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, TRUE);
1409 | vers_defns ';' EXTERN NAME '{'
1411 $<name>$ = ldgram_vers_current_lang;
1412 ldgram_vers_current_lang = $4;
1414 vers_defns opt_semicolon '}'
1416 struct bfd_elf_version_expr *pat;
1417 for (pat = $7; pat->next != NULL; pat = pat->next);
1420 ldgram_vers_current_lang = $<name>6;
1424 $<name>$ = ldgram_vers_current_lang;
1425 ldgram_vers_current_lang = $2;
1427 vers_defns opt_semicolon '}'
1430 ldgram_vers_current_lang = $<name>4;
1434 $$ = lang_new_vers_pattern (NULL, "global", ldgram_vers_current_lang, FALSE);
1436 | vers_defns ';' GLOBAL
1438 $$ = lang_new_vers_pattern ($1, "global", ldgram_vers_current_lang, FALSE);
1442 $$ = lang_new_vers_pattern (NULL, "local", ldgram_vers_current_lang, FALSE);
1444 | vers_defns ';' LOCAL
1446 $$ = lang_new_vers_pattern ($1, "local", ldgram_vers_current_lang, FALSE);
1450 $$ = lang_new_vers_pattern (NULL, "extern", ldgram_vers_current_lang, FALSE);
1452 | vers_defns ';' EXTERN
1454 $$ = lang_new_vers_pattern ($1, "extern", ldgram_vers_current_lang, FALSE);
1468 if (ldfile_assumed_script)
1469 einfo (_("%P:%s: file format not recognized; treating as linker script\n"),
1471 if (error_index > 0 && error_index < ERROR_NAME_MAX)
1472 einfo ("%P%F:%S: %s in %s\n", NULL, arg, error_names[error_index - 1]);
1474 einfo ("%P%F:%S: %s\n", NULL, arg);