1 /* A YACC grammar to parse a superset of the AT&T linker scripting language.
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 Free Software Foundation, Inc.
5 Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
7 This file is part of the GNU Binutils.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
29 #define DONTDECLARE_MALLOC
50 static enum section_type sectype;
51 static lang_memory_region_type *region;
53 bfd_boolean ldgram_had_keep = FALSE;
54 char *ldgram_vers_current_lang = NULL;
56 #define ERROR_NAME_MAX 20
57 static char *error_names[ERROR_NAME_MAX];
58 static int error_index;
59 #define PUSH_ERROR(x) if (error_index < ERROR_NAME_MAX) error_names[error_index] = x; error_index++;
60 #define POP_ERROR() error_index--;
72 struct wildcard_spec wildcard;
73 struct wildcard_list *wildcard_list;
74 struct name_list *name_list;
75 struct flag_info_list *flag_info_list;
76 struct flag_info *flag_info;
78 union etree_union *etree;
83 union etree_union *at;
84 union etree_union *flags;
86 struct lang_nocrossref *nocrossref;
87 struct lang_output_section_phdr_list *section_phdr;
88 struct bfd_elf_version_deps *deflist;
89 struct bfd_elf_version_expr *versyms;
90 struct bfd_elf_version_tree *versnode;
93 %type <etree> exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val
94 %type <etree> opt_exp_without_type opt_subalign opt_align
95 %type <fill> fill_opt fill_exp
96 %type <name_list> exclude_name_list
97 %type <wildcard_list> file_NAME_list
98 %type <flag_info_list> sect_flag_list
99 %type <flag_info> sect_flags
100 %type <name> memspec_opt casesymlist
101 %type <name> memspec_at_opt
102 %type <cname> wildcard_name
103 %type <wildcard> wildcard_spec
105 %token <name> NAME LNAME
106 %type <integer> length
107 %type <phdr> phdr_qualifiers
108 %type <nocrossref> nocrossref_list
109 %type <section_phdr> phdr_opt
110 %type <integer> opt_nocrossrefs
112 %right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
113 %right <token> '?' ':'
120 %left <token> '<' '>' LE GE
121 %left <token> LSHIFT RSHIFT
123 %left <token> '+' '-'
124 %left <token> '*' '/' '%'
129 %token <token> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE
130 %token SECTIONS PHDRS INSERT_K AFTER BEFORE
131 %token DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END
132 %token SORT_BY_NAME SORT_BY_ALIGNMENT SORT_NONE
133 %token SORT_BY_INIT_PRIORITY
135 %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
136 %token INHIBIT_COMMON_ALLOCATION
142 %token NOLOAD DSECT COPY INFO OVERLAY
143 %token DEFINED TARGET_K SEARCH_DIR MAP ENTRY
144 %token <integer> NEXT
145 %token SIZEOF ALIGNOF ADDR LOADADDR MAX_K MIN_K
146 %token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS
148 %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS
149 %token ALIGNMOD AT SUBALIGN PROVIDE PROVIDE_HIDDEN AS_NEEDED
150 %type <token> assign_op atype attributes_opt sect_constraint
151 %type <name> filename
152 %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K
153 %token FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL
154 %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START
155 %token <name> VERS_TAG VERS_IDENTIFIER
156 %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT
157 %token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL INPUT_SECTION_FLAGS
160 %type <versyms> vers_defns
161 %type <versnode> vers_tag
162 %type <deflist> verdep
163 %token INPUT_DYNAMIC_LIST
168 INPUT_SCRIPT script_file
169 | INPUT_MRI_SCRIPT mri_script_file
170 | INPUT_VERSION_SCRIPT version_script_file
171 | INPUT_DYNAMIC_LIST dynamic_list_file
172 | INPUT_DEFSYM defsym_expr
184 lang_add_assignment (exp_defsym ($2, $4));
188 /* SYNTAX WITHIN AN MRI SCRIPT FILE */
192 PUSH_ERROR (_("MRI style script"));
203 mri_script_lines mri_script_command NEWLINE
211 einfo(_("%P%F: unrecognised keyword in MRI style script '%s'\n"),$1);
214 config.map_filename = "-";
216 | ORDER ordernamelist
218 | PUBLIC NAME '=' exp
219 { mri_public($2, $4); }
220 | PUBLIC NAME ',' exp
221 { mri_public($2, $4); }
223 { mri_public($2, $3); }
227 { mri_output_section($2, $4);}
229 { mri_output_section($2, $3);}
231 { mri_output_section($2, $4);}
232 | ALIGN_K NAME '=' exp
233 { mri_align($2,$4); }
234 | ALIGN_K NAME ',' exp
235 { mri_align($2,$4); }
236 | ALIGNMOD NAME '=' exp
237 { mri_alignmod($2,$4); }
238 | ALIGNMOD NAME ',' exp
239 { mri_alignmod($2,$4); }
240 | ABSOLUTE mri_abs_name_list
241 | LOAD mri_load_name_list
244 | ALIAS NAME ',' NAME
245 { mri_alias($2,$4,0);}
247 { mri_alias ($2, 0, (int) $4.integer); }
251 { mri_truncate ((unsigned int) $2.integer); }
253 | EXTERN extern_name_list
255 { ldlex_script (); ldfile_open_command_file($2); }
257 { ldlex_popstate (); }
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
288 /* Parsed as expressions so that commas separate entries */
290 { ldlex_expression (); }
291 extern_name_list_body
292 { ldlex_popstate (); }
294 extern_name_list_body:
296 { ldlang_add_undef ($1, FALSE); }
297 | extern_name_list_body NAME
298 { ldlang_add_undef ($2, FALSE); }
299 | extern_name_list_body ',' NAME
300 { ldlang_add_undef ($3, FALSE); }
306 { ldlex_popstate(); }
322 | floating_point_support
326 | TARGET_K '(' NAME ')'
327 { lang_add_target($3); }
328 | SEARCH_DIR '(' filename ')'
329 { ldfile_add_library_path ($3, FALSE); }
330 | OUTPUT '(' filename ')'
331 { lang_add_output($3, 1); }
332 | OUTPUT_FORMAT '(' NAME ')'
333 { lang_add_output_format ($3, (char *) NULL,
335 | OUTPUT_FORMAT '(' NAME ',' NAME ',' NAME ')'
336 { lang_add_output_format ($3, $5, $7, 1); }
337 | OUTPUT_ARCH '(' NAME ')'
338 { ldfile_set_output_arch ($3, bfd_arch_unknown); }
339 | FORCE_COMMON_ALLOCATION
340 { command_line.force_common_definition = TRUE ; }
341 | INHIBIT_COMMON_ALLOCATION
342 { command_line.inhibit_common_definition = TRUE ; }
343 | INPUT '(' input_list ')'
345 { lang_enter_group (); }
347 { lang_leave_group (); }
348 | MAP '(' filename ')'
349 { lang_add_map($3); }
351 { ldlex_script (); ldfile_open_command_file($2); }
353 { ldlex_popstate (); }
354 | NOCROSSREFS '(' nocrossref_list ')'
356 lang_add_nocrossref ($3);
358 | EXTERN '(' extern_name_list ')'
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); }
371 { lang_add_input_file($1,lang_input_file_is_search_file_enum,
373 | input_list ',' 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_list ',' 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_list ',' 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_list 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); }
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. */
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;
456 | SORT_BY_NAME '(' wildcard_name ')'
460 $$.exclude_name_list = NULL;
461 $$.section_flag_list = NULL;
463 | SORT_BY_ALIGNMENT '(' wildcard_name ')'
466 $$.sorted = by_alignment;
467 $$.exclude_name_list = NULL;
468 $$.section_flag_list = NULL;
470 | SORT_NONE '(' wildcard_name ')'
474 $$.exclude_name_list = NULL;
475 $$.section_flag_list = NULL;
477 | SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')'
480 $$.sorted = by_name_alignment;
481 $$.exclude_name_list = NULL;
482 $$.section_flag_list = NULL;
484 | SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_name ')' ')'
488 $$.exclude_name_list = NULL;
489 $$.section_flag_list = NULL;
491 | SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_name ')' ')'
494 $$.sorted = by_alignment_name;
495 $$.exclude_name_list = NULL;
496 $$.section_flag_list = NULL;
498 | SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')'
501 $$.sorted = by_alignment;
502 $$.exclude_name_list = NULL;
503 $$.section_flag_list = NULL;
505 | SORT_BY_NAME '(' EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name ')'
509 $$.exclude_name_list = $5;
510 $$.section_flag_list = NULL;
512 | SORT_BY_INIT_PRIORITY '(' wildcard_name ')'
515 $$.sorted = by_init_priority;
516 $$.exclude_name_list = NULL;
517 $$.section_flag_list = NULL;
523 struct flag_info_list *n;
524 n = ((struct flag_info_list *) xmalloc (sizeof *n));
527 n->with = without_flags;
532 n->with = with_flags;
539 | sect_flag_list '&' NAME
541 struct flag_info_list *n;
542 n = ((struct flag_info_list *) xmalloc (sizeof *n));
545 n->with = without_flags;
550 n->with = with_flags;
560 INPUT_SECTION_FLAGS '(' sect_flag_list ')'
563 n = ((struct flag_info *) xmalloc (sizeof *n));
565 n->flags_initialized = FALSE;
566 n->not_with_flags = 0;
567 n->only_with_flags = 0;
573 exclude_name_list wildcard_name
575 struct name_list *tmp;
576 tmp = (struct name_list *) xmalloc (sizeof *tmp);
584 struct name_list *tmp;
585 tmp = (struct name_list *) xmalloc (sizeof *tmp);
593 file_NAME_list opt_comma wildcard_spec
595 struct wildcard_list *tmp;
596 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
604 struct wildcard_list *tmp;
605 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
612 input_section_spec_no_keep:
615 struct wildcard_spec tmp;
617 tmp.exclude_name_list = NULL;
619 tmp.section_flag_list = NULL;
620 lang_add_wild (&tmp, NULL, ldgram_had_keep);
624 struct wildcard_spec tmp;
626 tmp.exclude_name_list = NULL;
628 tmp.section_flag_list = $1;
629 lang_add_wild (&tmp, NULL, ldgram_had_keep);
631 | '[' file_NAME_list ']'
633 lang_add_wild (NULL, $2, ldgram_had_keep);
635 | sect_flags '[' file_NAME_list ']'
637 struct wildcard_spec tmp;
639 tmp.exclude_name_list = NULL;
641 tmp.section_flag_list = $1;
642 lang_add_wild (&tmp, $3, ldgram_had_keep);
644 | wildcard_spec '(' file_NAME_list ')'
646 lang_add_wild (&$1, $3, ldgram_had_keep);
648 | sect_flags wildcard_spec '(' file_NAME_list ')'
650 $2.section_flag_list = $1;
651 lang_add_wild (&$2, $4, ldgram_had_keep);
656 input_section_spec_no_keep
658 { ldgram_had_keep = TRUE; }
659 input_section_spec_no_keep ')'
660 { ldgram_had_keep = FALSE; }
665 | CREATE_OBJECT_SYMBOLS
667 lang_add_attribute(lang_object_symbols_statement_enum);
673 lang_add_attribute(lang_constructors_statement_enum);
675 | SORT_BY_NAME '(' CONSTRUCTORS ')'
677 constructors_sorted = TRUE;
678 lang_add_attribute (lang_constructors_statement_enum);
681 | length '(' mustbe_exp ')'
683 lang_add_data ((int) $1, $3);
686 | FILL '(' fill_exp ')'
690 | ASSERT_K {ldlex_expression ();} '(' exp ',' NAME ')' end
692 lang_add_assignment (exp_assert ($4, $6)); }
694 { ldlex_script (); ldfile_open_command_file($2); }
695 statement_list_opt END
696 { ldlex_popstate (); }
700 statement_list statement
725 $$ = exp_get_fill ($1, 0, "fill value");
732 | { $$ = (fill_type *) 0; }
762 lang_add_assignment (exp_assign ($1, $3));
764 | NAME assign_op mustbe_exp
766 lang_add_assignment (exp_assign ($1,
772 | PROVIDE '(' NAME '=' mustbe_exp ')'
774 lang_add_assignment (exp_provide ($3, $5, FALSE));
776 | PROVIDE_HIDDEN '(' NAME '=' mustbe_exp ')'
778 lang_add_assignment (exp_provide ($3, $5, TRUE));
788 MEMORY '{' memory_spec_list_opt '}'
791 memory_spec_list_opt: memory_spec_list | ;
794 memory_spec_list opt_comma memory_spec
800 { region = lang_memory_region_lookup ($1, TRUE); }
802 origin_spec opt_comma length_spec
805 { ldlex_script (); ldfile_open_command_file($2); }
806 memory_spec_list_opt END
807 { ldlex_popstate (); }
811 ORIGIN '=' mustbe_exp
813 region->origin = exp_get_vma ($3, 0, "origin");
814 region->current = region->origin;
819 LENGTH '=' mustbe_exp
821 region->length = exp_get_vma ($3, -1, "length");
827 { /* dummy action to avoid bison 1.25 error message */ }
828 | '(' attributes_list ')'
833 | attributes_list attributes_string
838 { lang_set_flags (region, $1, 0); }
840 { lang_set_flags (region, $2, 1); }
844 STARTUP '(' filename ')'
845 { lang_startup($3); }
849 HLL '(' high_level_library_NAME_list ')'
851 { ldemul_hll((char *)NULL); }
854 high_level_library_NAME_list:
855 high_level_library_NAME_list opt_comma filename
863 SYSLIB '(' low_level_library_NAME_list ')'
864 ; low_level_library_NAME_list:
865 low_level_library_NAME_list opt_comma filename
866 { ldemul_syslib($3); }
870 floating_point_support:
872 { lang_float(TRUE); }
874 { lang_float(FALSE); }
882 | NAME nocrossref_list
884 struct lang_nocrossref *n;
886 n = (struct lang_nocrossref *) xmalloc (sizeof *n);
891 | NAME ',' nocrossref_list
893 struct lang_nocrossref *n;
895 n = (struct lang_nocrossref *) xmalloc (sizeof *n);
902 mustbe_exp: { ldlex_expression (); }
904 { ldlex_popstate (); $$=$2;}
909 { $$ = exp_unop ('-', $2); }
912 | NEXT '(' exp ')' %prec UNARY
913 { $$ = exp_unop ((int) $1,$3); }
914 | '!' exp %prec UNARY
915 { $$ = exp_unop ('!', $2); }
916 | '+' exp %prec UNARY
918 | '~' exp %prec UNARY
919 { $$ = exp_unop ('~', $2);}
922 { $$ = exp_binop ('*', $1, $3); }
924 { $$ = exp_binop ('/', $1, $3); }
926 { $$ = exp_binop ('%', $1, $3); }
928 { $$ = exp_binop ('+', $1, $3); }
930 { $$ = exp_binop ('-' , $1, $3); }
932 { $$ = exp_binop (LSHIFT , $1, $3); }
934 { $$ = exp_binop (RSHIFT , $1, $3); }
936 { $$ = exp_binop (EQ , $1, $3); }
938 { $$ = exp_binop (NE , $1, $3); }
940 { $$ = exp_binop (LE , $1, $3); }
942 { $$ = exp_binop (GE , $1, $3); }
944 { $$ = exp_binop ('<' , $1, $3); }
946 { $$ = exp_binop ('>' , $1, $3); }
948 { $$ = exp_binop ('&' , $1, $3); }
950 { $$ = exp_binop ('^' , $1, $3); }
952 { $$ = exp_binop ('|' , $1, $3); }
953 | exp '?' exp ':' exp
954 { $$ = exp_trinop ('?' , $1, $3, $5); }
956 { $$ = exp_binop (ANDAND , $1, $3); }
958 { $$ = exp_binop (OROR , $1, $3); }
959 | DEFINED '(' NAME ')'
960 { $$ = exp_nameop (DEFINED, $3); }
962 { $$ = exp_bigintop ($1.integer, $1.str); }
964 { $$ = exp_nameop (SIZEOF_HEADERS,0); }
966 | ALIGNOF '(' NAME ')'
967 { $$ = exp_nameop (ALIGNOF,$3); }
968 | SIZEOF '(' NAME ')'
969 { $$ = exp_nameop (SIZEOF,$3); }
971 { $$ = exp_nameop (ADDR,$3); }
972 | LOADADDR '(' NAME ')'
973 { $$ = exp_nameop (LOADADDR,$3); }
974 | CONSTANT '(' NAME ')'
975 { $$ = exp_nameop (CONSTANT,$3); }
976 | ABSOLUTE '(' exp ')'
977 { $$ = exp_unop (ABSOLUTE, $3); }
978 | ALIGN_K '(' exp ')'
979 { $$ = exp_unop (ALIGN_K,$3); }
980 | ALIGN_K '(' exp ',' exp ')'
981 { $$ = exp_binop (ALIGN_K,$3,$5); }
982 | DATA_SEGMENT_ALIGN '(' exp ',' exp ')'
983 { $$ = exp_binop (DATA_SEGMENT_ALIGN, $3, $5); }
984 | DATA_SEGMENT_RELRO_END '(' exp ',' exp ')'
985 { $$ = exp_binop (DATA_SEGMENT_RELRO_END, $5, $3); }
986 | DATA_SEGMENT_END '(' exp ')'
987 { $$ = exp_unop (DATA_SEGMENT_END, $3); }
988 | SEGMENT_START '(' NAME ',' exp ')'
989 { /* The operands to the expression node are
990 placed in the opposite order from the way
991 in which they appear in the script as
992 that allows us to reuse more code in
994 $$ = exp_binop (SEGMENT_START,
996 exp_nameop (NAME, $3)); }
998 { $$ = exp_unop (ALIGN_K,$3); }
1000 { $$ = exp_nameop (NAME,$1); }
1001 | MAX_K '(' exp ',' exp ')'
1002 { $$ = exp_binop (MAX_K, $3, $5 ); }
1003 | MIN_K '(' exp ',' exp ')'
1004 { $$ = exp_binop (MIN_K, $3, $5 ); }
1005 | ASSERT_K '(' exp ',' NAME ')'
1006 { $$ = exp_assert ($3, $5); }
1007 | ORIGIN '(' NAME ')'
1008 { $$ = exp_nameop (ORIGIN, $3); }
1009 | LENGTH '(' NAME ')'
1010 { $$ = exp_nameop (LENGTH, $3); }
1015 AT '>' NAME { $$ = $3; }
1020 AT '(' exp ')' { $$ = $3; }
1025 ALIGN_K '(' exp ')' { $$ = $3; }
1030 SUBALIGN '(' exp ')' { $$ = $3; }
1035 ONLY_IF_RO { $$ = ONLY_IF_RO; }
1036 | ONLY_IF_RW { $$ = ONLY_IF_RW; }
1037 | SPECIAL { $$ = SPECIAL; }
1041 section: NAME { ldlex_expression(); }
1045 opt_subalign { ldlex_popstate (); ldlex_script (); }
1049 lang_enter_output_section_statement($1, $3,
1054 '}' { ldlex_popstate (); ldlex_expression (); }
1055 memspec_opt memspec_at_opt phdr_opt fill_opt
1058 lang_leave_output_section_statement ($17, $14, $16, $15);
1063 { ldlex_expression (); }
1064 opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
1065 { ldlex_popstate (); ldlex_script (); }
1068 lang_enter_overlay ($3, $6);
1072 { ldlex_popstate (); ldlex_expression (); }
1073 memspec_opt memspec_at_opt phdr_opt fill_opt
1076 lang_leave_overlay ($5, (int) $4,
1077 $16, $13, $15, $14);
1080 | /* The GROUP case is just enough to support the gcc
1081 svr3.ifile script. It is not intended to be full
1082 support. I'm not even sure what GROUP is supposed
1084 GROUP { ldlex_expression (); }
1088 lang_add_assignment (exp_assign (".", $3));
1090 '{' sec_or_group_p1 '}'
1092 { ldlex_script (); ldfile_open_command_file($2); }
1094 { ldlex_popstate (); }
1098 NOLOAD { sectype = noload_section; }
1099 | DSECT { sectype = noalloc_section; }
1100 | COPY { sectype = noalloc_section; }
1101 | INFO { sectype = noalloc_section; }
1102 | OVERLAY { sectype = noalloc_section; }
1107 | /* EMPTY */ { sectype = normal_section; }
1108 | '(' ')' { sectype = normal_section; }
1112 exp atype ':' { $$ = $1; }
1113 | atype ':' { $$ = (etree_type *)NULL; }
1114 | /* The BIND cases are to support the gcc svr3.ifile
1115 script. They aren't intended to implement full
1116 support for the BIND keyword. I'm not even sure
1117 what BIND is supposed to mean. */
1118 BIND '(' exp ')' atype ':' { $$ = $3; }
1119 | BIND '(' exp ')' BLOCK '(' exp ')' atype ':'
1123 opt_exp_without_type:
1124 exp ':' { $$ = $1; }
1125 | ':' { $$ = (etree_type *) NULL; }
1138 | { $$ = DEFAULT_MEMORY_REGION; }
1148 struct lang_output_section_phdr_list *n;
1150 n = ((struct lang_output_section_phdr_list *)
1151 xmalloc (sizeof *n));
1165 lang_enter_overlay_section ($2);
1167 '{' statement_list_opt '}'
1168 { ldlex_popstate (); ldlex_expression (); }
1172 lang_leave_overlay_section ($9, $8);
1178 PHDRS '{' phdr_list '}'
1187 NAME { ldlex_expression (); }
1188 phdr_type phdr_qualifiers { ldlex_popstate (); }
1191 lang_new_phdr ($1, $3, $4.filehdr, $4.phdrs, $4.at,
1201 if ($1->type.node_class == etree_name
1202 && $1->type.node_code == NAME)
1206 static const char * const phdr_types[] =
1208 "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
1209 "PT_INTERP", "PT_NOTE", "PT_SHLIB",
1215 i < sizeof phdr_types / sizeof phdr_types[0];
1217 if (strcmp (s, phdr_types[i]) == 0)
1222 if (i == sizeof phdr_types / sizeof phdr_types[0])
1224 if (strcmp (s, "PT_GNU_EH_FRAME") == 0)
1225 $$ = exp_intop (0x6474e550);
1226 else if (strcmp (s, "PT_GNU_STACK") == 0)
1227 $$ = exp_intop (0x6474e551);
1231 %X%P:%S: unknown phdr type `%s' (try integer literal)\n"),
1243 memset (&$$, 0, sizeof (struct phdr_info));
1245 | NAME phdr_val phdr_qualifiers
1248 if (strcmp ($1, "FILEHDR") == 0 && $2 == NULL)
1250 else if (strcmp ($1, "PHDRS") == 0 && $2 == NULL)
1252 else if (strcmp ($1, "FLAGS") == 0 && $2 != NULL)
1255 einfo (_("%X%P:%S: PHDRS syntax error at `%s'\n"),
1258 | AT '(' exp ')' phdr_qualifiers
1278 ldlex_version_file ();
1279 PUSH_ERROR (_("dynamic list"));
1290 | dynamic_list_nodes dynamic_list_node
1294 '{' dynamic_list_tag '}' ';'
1300 lang_append_dynamic_list ($1);
1304 /* This syntax is used within an external version script file. */
1306 version_script_file:
1308 ldlex_version_file ();
1309 PUSH_ERROR (_("VERSION script"));
1318 /* This is used within a normal linker script file. */
1322 ldlex_version_script ();
1324 VERSIONK '{' vers_nodes '}'
1332 | vers_nodes vers_node
1336 '{' vers_tag '}' ';'
1338 lang_register_vers_node (NULL, $2, NULL);
1340 | VERS_TAG '{' vers_tag '}' ';'
1342 lang_register_vers_node ($1, $3, NULL);
1344 | VERS_TAG '{' vers_tag '}' verdep ';'
1346 lang_register_vers_node ($1, $3, $5);
1353 $$ = lang_add_vers_depend (NULL, $1);
1357 $$ = lang_add_vers_depend ($1, $2);
1364 $$ = lang_new_vers_node (NULL, NULL);
1368 $$ = lang_new_vers_node ($1, NULL);
1370 | GLOBAL ':' vers_defns ';'
1372 $$ = lang_new_vers_node ($3, NULL);
1374 | LOCAL ':' vers_defns ';'
1376 $$ = lang_new_vers_node (NULL, $3);
1378 | GLOBAL ':' vers_defns ';' LOCAL ':' vers_defns ';'
1380 $$ = lang_new_vers_node ($3, $7);
1387 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, FALSE);
1391 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, TRUE);
1393 | vers_defns ';' VERS_IDENTIFIER
1395 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, FALSE);
1397 | vers_defns ';' NAME
1399 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, TRUE);
1401 | vers_defns ';' EXTERN NAME '{'
1403 $<name>$ = ldgram_vers_current_lang;
1404 ldgram_vers_current_lang = $4;
1406 vers_defns opt_semicolon '}'
1408 struct bfd_elf_version_expr *pat;
1409 for (pat = $7; pat->next != NULL; pat = pat->next);
1412 ldgram_vers_current_lang = $<name>6;
1416 $<name>$ = ldgram_vers_current_lang;
1417 ldgram_vers_current_lang = $2;
1419 vers_defns opt_semicolon '}'
1422 ldgram_vers_current_lang = $<name>4;
1426 $$ = lang_new_vers_pattern (NULL, "global", ldgram_vers_current_lang, FALSE);
1428 | vers_defns ';' GLOBAL
1430 $$ = lang_new_vers_pattern ($1, "global", ldgram_vers_current_lang, FALSE);
1434 $$ = lang_new_vers_pattern (NULL, "local", ldgram_vers_current_lang, FALSE);
1436 | vers_defns ';' LOCAL
1438 $$ = lang_new_vers_pattern ($1, "local", ldgram_vers_current_lang, FALSE);
1442 $$ = lang_new_vers_pattern (NULL, "extern", ldgram_vers_current_lang, FALSE);
1444 | vers_defns ';' EXTERN
1446 $$ = lang_new_vers_pattern ($1, "extern", ldgram_vers_current_lang, FALSE);
1460 if (ldfile_assumed_script)
1461 einfo (_("%P:%s: file format not recognized; treating as linker script\n"),
1463 if (error_index > 0 && error_index < ERROR_NAME_MAX)
1464 einfo ("%P%F:%S: %s in %s\n", NULL, arg, error_names[error_index - 1]);
1466 einfo ("%P%F:%S: %s\n", NULL, arg);