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 casesymlist
100 %type <name> memspec_at_opt
101 %type <cname> wildcard_name
102 %type <wildcard> section_name_spec filename_spec wildcard_maybe_exclude
104 %token <name> NAME LNAME
105 %type <integer> length
106 %type <phdr> phdr_qualifiers
107 %type <nocrossref> nocrossref_list
108 %type <section_phdr> phdr_opt
109 %type <integer> opt_nocrossrefs
111 %right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
112 %right <token> '?' ':'
119 %left <token> '<' '>' LE GE
120 %left <token> LSHIFT RSHIFT
122 %left <token> '+' '-'
123 %left <token> '*' '/' '%'
128 %token <token> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE
129 %token SECTIONS PHDRS INSERT_K AFTER BEFORE
130 %token DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END
131 %token SORT_BY_NAME SORT_BY_ALIGNMENT SORT_NONE
132 %token SORT_BY_INIT_PRIORITY
134 %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
135 %token INHIBIT_COMMON_ALLOCATION FORCE_GROUP_ALLOCATION
141 %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 NOCROSSREFS_TO
148 %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS
149 %token ALIGNMOD AT SUBALIGN HIDDEN PROVIDE PROVIDE_HIDDEN AS_NEEDED
150 %type <token> assign_op atype attributes_opt sect_constraint opt_align_with_input
151 %type <name> filename
152 %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K
153 %token LOG2CEIL 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 ALIGN_WITH_INPUT
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
180 { ldlex_expression(); }
182 { ldlex_popstate(); }
185 /* SYNTAX WITHIN AN MRI SCRIPT FILE */
189 PUSH_ERROR (_("MRI style script"));
200 mri_script_lines mri_script_command NEWLINE
208 einfo(_("%F%P: unrecognised keyword in MRI style script '%s'\n"),$1);
211 config.map_filename = "-";
213 | ORDER ordernamelist
215 | PUBLIC NAME '=' exp
216 { mri_public($2, $4); }
217 | PUBLIC NAME ',' exp
218 { mri_public($2, $4); }
220 { mri_public($2, $3); }
224 { mri_output_section($2, $4);}
226 { mri_output_section($2, $3);}
228 { mri_output_section($2, $4);}
229 | ALIGN_K NAME '=' exp
230 { mri_align($2,$4); }
231 | ALIGN_K NAME ',' exp
232 { mri_align($2,$4); }
233 | ALIGNMOD NAME '=' exp
234 { mri_alignmod($2,$4); }
235 | ALIGNMOD NAME ',' exp
236 { mri_alignmod($2,$4); }
237 | ABSOLUTE mri_abs_name_list
238 | LOAD mri_load_name_list
241 | ALIAS NAME ',' NAME
242 { mri_alias($2,$4,0);}
244 { mri_alias ($2, 0, (int) $4.integer); }
248 { mri_truncate ((unsigned int) $2.integer); }
250 | EXTERN extern_name_list
252 { ldlex_script (); ldfile_open_command_file($2); }
254 { ldlex_popstate (); }
256 { lang_add_entry ($2, false); }
261 ordernamelist ',' NAME { mri_order($3); }
262 | ordernamelist NAME { mri_order($2); }
269 | mri_load_name_list ',' NAME { mri_load($3); }
274 { mri_only_load($1); }
275 | mri_abs_name_list ',' NAME
276 { mri_only_load($3); }
280 /* empty */ { $$ = NULL; }
282 | casesymlist ',' NAME
285 /* Parsed as expressions so that commas separate entries */
287 { ldlex_expression (); }
288 extern_name_list_body
289 { ldlex_popstate (); }
291 extern_name_list_body:
293 { ldlang_add_undef ($1, false); }
294 | extern_name_list_body NAME
295 { ldlang_add_undef ($2, false); }
296 | extern_name_list_body ',' NAME
297 { ldlang_add_undef ($3, false); }
303 { ldlex_popstate(); }
319 | floating_point_support
323 | TARGET_K '(' NAME ')'
324 { lang_add_target($3); }
325 | SEARCH_DIR '(' filename ')'
326 { ldfile_add_library_path ($3, false); }
327 | OUTPUT '(' filename ')'
328 { lang_add_output($3, 1); }
329 | OUTPUT_FORMAT '(' NAME ')'
330 { lang_add_output_format ($3, (char *) NULL,
332 | OUTPUT_FORMAT '(' NAME ',' NAME ',' NAME ')'
333 { lang_add_output_format ($3, $5, $7, 1); }
334 | OUTPUT_ARCH '(' NAME ')'
335 { ldfile_set_output_arch ($3, bfd_arch_unknown); }
336 | FORCE_COMMON_ALLOCATION
337 { command_line.force_common_definition = true ; }
338 | FORCE_GROUP_ALLOCATION
339 { command_line.force_group_allocation = true ; }
340 | INHIBIT_COMMON_ALLOCATION
341 { link_info.inhibit_common_definition = true ; }
342 | INPUT '(' input_list ')'
344 { lang_enter_group (); }
346 { lang_leave_group (); }
347 | MAP '(' filename ')'
348 { lang_add_map($3); }
350 { ldlex_script (); ldfile_open_command_file($2); }
352 { ldlex_popstate (); }
353 | NOCROSSREFS '(' nocrossref_list ')'
355 lang_add_nocrossref ($3);
357 | NOCROSSREFS_TO '(' nocrossref_list ')'
359 lang_add_nocrossref_to ($3);
361 | EXTERN '(' extern_name_list ')'
362 | INSERT_K AFTER NAME
363 { lang_add_insert ($3, 0); }
364 | INSERT_K BEFORE NAME
365 { lang_add_insert ($3, 1); }
366 | REGION_ALIAS '(' NAME ',' NAME ')'
367 { lang_memory_region_alias ($3, $5); }
368 | LD_FEATURE '(' NAME ')'
369 { lang_ld_feature ($3); }
373 { ldlex_inputlist(); }
375 { ldlex_popstate(); }
379 { lang_add_input_file($1,lang_input_file_is_search_file_enum,
381 | input_list1 ',' NAME
382 { lang_add_input_file($3,lang_input_file_is_search_file_enum,
385 { lang_add_input_file($2,lang_input_file_is_search_file_enum,
388 { lang_add_input_file($1,lang_input_file_is_l_enum,
390 | input_list1 ',' LNAME
391 { lang_add_input_file($3,lang_input_file_is_l_enum,
394 { lang_add_input_file($2,lang_input_file_is_l_enum,
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>3; }
401 | input_list1 ',' AS_NEEDED '('
402 { $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
403 input_flags.add_DT_NEEDED_for_regular = true; }
405 { input_flags.add_DT_NEEDED_for_regular = $<integer>5; }
406 | input_list1 AS_NEEDED '('
407 { $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
408 input_flags.add_DT_NEEDED_for_regular = true; }
410 { input_flags.add_DT_NEEDED_for_regular = $<integer>4; }
414 SECTIONS '{' sec_or_group_p1 '}'
418 sec_or_group_p1 section
419 | sec_or_group_p1 statement_anywhere
425 { lang_add_entry ($3, false); }
427 | ASSERT_K {ldlex_expression ();} '(' exp ',' NAME ')'
429 lang_add_assignment (exp_assert ($4, $6)); }
432 /* The '*' and '?' cases are there because the lexer returns them as
433 separate tokens rather than as NAME. */
449 wildcard_maybe_exclude:
454 $$.exclude_name_list = NULL;
455 $$.section_flag_list = NULL;
457 | EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name
461 $$.exclude_name_list = $3;
462 $$.section_flag_list = NULL;
467 wildcard_maybe_exclude
468 | SORT_BY_NAME '(' wildcard_maybe_exclude ')'
473 | SORT_NONE '(' wildcard_maybe_exclude ')'
481 wildcard_maybe_exclude
482 | SORT_BY_NAME '(' wildcard_maybe_exclude ')'
487 | SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')'
490 $$.sorted = by_alignment;
492 | SORT_NONE '(' wildcard_maybe_exclude ')'
497 | SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')' ')'
500 $$.sorted = by_name_alignment;
502 | SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_maybe_exclude ')' ')'
507 | SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_maybe_exclude ')' ')'
510 $$.sorted = by_alignment_name;
512 | SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')' ')'
515 $$.sorted = by_alignment;
517 | SORT_BY_INIT_PRIORITY '(' wildcard_maybe_exclude ')'
520 $$.sorted = by_init_priority;
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;
542 | sect_flag_list '&' NAME
544 struct flag_info_list *n;
545 n = ((struct flag_info_list *) xmalloc (sizeof *n));
548 n->with = without_flags;
553 n->with = with_flags;
563 INPUT_SECTION_FLAGS '(' sect_flag_list ')'
566 n = ((struct flag_info *) xmalloc (sizeof *n));
568 n->flags_initialized = false;
569 n->not_with_flags = 0;
570 n->only_with_flags = 0;
576 exclude_name_list wildcard_name
578 struct name_list *tmp;
579 tmp = (struct name_list *) xmalloc (sizeof *tmp);
587 struct name_list *tmp;
588 tmp = (struct name_list *) xmalloc (sizeof *tmp);
596 section_name_list opt_comma section_name_spec
598 struct wildcard_list *tmp;
599 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
607 struct wildcard_list *tmp;
608 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
615 input_section_spec_no_keep:
618 struct wildcard_spec tmp;
620 tmp.exclude_name_list = NULL;
622 tmp.section_flag_list = NULL;
623 lang_add_wild (&tmp, NULL, ldgram_had_keep);
627 struct wildcard_spec tmp;
629 tmp.exclude_name_list = NULL;
631 tmp.section_flag_list = $1;
632 lang_add_wild (&tmp, NULL, ldgram_had_keep);
634 | '[' section_name_list ']'
636 lang_add_wild (NULL, $2, ldgram_had_keep);
638 | sect_flags '[' section_name_list ']'
640 struct wildcard_spec tmp;
642 tmp.exclude_name_list = NULL;
644 tmp.section_flag_list = $1;
645 lang_add_wild (&tmp, $3, ldgram_had_keep);
647 | filename_spec '(' section_name_list ')'
649 lang_add_wild (&$1, $3, ldgram_had_keep);
651 | sect_flags filename_spec '(' section_name_list ')'
653 $2.section_flag_list = $1;
654 lang_add_wild (&$2, $4, ldgram_had_keep);
659 input_section_spec_no_keep
661 { ldgram_had_keep = true; }
662 input_section_spec_no_keep ')'
663 { ldgram_had_keep = false; }
668 | CREATE_OBJECT_SYMBOLS
670 lang_add_attribute(lang_object_symbols_statement_enum);
676 lang_add_attribute(lang_constructors_statement_enum);
678 | SORT_BY_NAME '(' CONSTRUCTORS ')'
680 constructors_sorted = true;
681 lang_add_attribute (lang_constructors_statement_enum);
684 | length '(' mustbe_exp ')'
686 lang_add_data ((int) $1, $3);
689 | FILL '(' fill_exp ')'
693 | ASSERT_K {ldlex_expression ();} '(' exp ',' NAME ')' end
695 lang_add_assignment (exp_assert ($4, $6)); }
697 { ldlex_script (); ldfile_open_command_file($2); }
698 statement_list_opt END
699 { ldlex_popstate (); }
703 statement_list statement
728 $$ = exp_get_fill ($1, 0, "fill value");
735 | { $$ = (fill_type *) 0; }
765 lang_add_assignment (exp_assign ($1, $3, false));
767 | NAME assign_op mustbe_exp
769 lang_add_assignment (exp_assign ($1,
775 | HIDDEN '(' NAME '=' mustbe_exp ')'
777 lang_add_assignment (exp_assign ($3, $5, true));
779 | PROVIDE '(' NAME '=' mustbe_exp ')'
781 lang_add_assignment (exp_provide ($3, $5, false));
783 | PROVIDE_HIDDEN '(' NAME '=' mustbe_exp ')'
785 lang_add_assignment (exp_provide ($3, $5, true));
795 MEMORY '{' memory_spec_list_opt '}'
798 memory_spec_list_opt: memory_spec_list | ;
801 memory_spec_list opt_comma memory_spec
807 { region = lang_memory_region_lookup ($1, true); }
809 origin_spec opt_comma length_spec
812 { ldlex_script (); ldfile_open_command_file($2); }
813 memory_spec_list_opt END
814 { ldlex_popstate (); }
818 ORIGIN '=' mustbe_exp
820 region->origin_exp = $3;
825 LENGTH '=' mustbe_exp
827 region->length_exp = $3;
833 { /* dummy action to avoid bison 1.25 error message */ }
834 | '(' attributes_list ')'
839 | attributes_list attributes_string
844 { lang_set_flags (region, $1, 0); }
846 { lang_set_flags (region, $2, 1); }
850 STARTUP '(' filename ')'
851 { lang_startup($3); }
855 HLL '(' high_level_library_NAME_list ')'
857 { ldemul_hll((char *)NULL); }
860 high_level_library_NAME_list:
861 high_level_library_NAME_list opt_comma filename
868 SYSLIB '(' low_level_library_NAME_list ')'
871 low_level_library_NAME_list:
872 low_level_library_NAME_list opt_comma filename
873 { ldemul_syslib($3); }
877 floating_point_support:
879 { lang_float(true); }
881 { lang_float(false); }
889 | NAME nocrossref_list
891 struct lang_nocrossref *n;
893 n = (struct lang_nocrossref *) xmalloc (sizeof *n);
898 | NAME ',' nocrossref_list
900 struct lang_nocrossref *n;
902 n = (struct lang_nocrossref *) xmalloc (sizeof *n);
909 mustbe_exp: { ldlex_expression (); }
911 { ldlex_popstate (); $$=$2;}
916 { $$ = exp_unop ('-', $2); }
919 | NEXT '(' exp ')' %prec UNARY
920 { $$ = exp_unop ((int) $1,$3); }
921 | '!' exp %prec UNARY
922 { $$ = exp_unop ('!', $2); }
923 | '+' exp %prec UNARY
925 | '~' exp %prec UNARY
926 { $$ = exp_unop ('~', $2);}
929 { $$ = exp_binop ('*', $1, $3); }
931 { $$ = exp_binop ('/', $1, $3); }
933 { $$ = exp_binop ('%', $1, $3); }
935 { $$ = exp_binop ('+', $1, $3); }
937 { $$ = exp_binop ('-' , $1, $3); }
939 { $$ = exp_binop (LSHIFT , $1, $3); }
941 { $$ = exp_binop (RSHIFT , $1, $3); }
943 { $$ = exp_binop (EQ , $1, $3); }
945 { $$ = exp_binop (NE , $1, $3); }
947 { $$ = exp_binop (LE , $1, $3); }
949 { $$ = exp_binop (GE , $1, $3); }
951 { $$ = exp_binop ('<' , $1, $3); }
953 { $$ = exp_binop ('>' , $1, $3); }
955 { $$ = exp_binop ('&' , $1, $3); }
957 { $$ = exp_binop ('^' , $1, $3); }
959 { $$ = exp_binop ('|' , $1, $3); }
960 | exp '?' exp ':' exp
961 { $$ = exp_trinop ('?' , $1, $3, $5); }
963 { $$ = exp_binop (ANDAND , $1, $3); }
965 { $$ = exp_binop (OROR , $1, $3); }
966 | DEFINED '(' NAME ')'
967 { $$ = exp_nameop (DEFINED, $3); }
969 { $$ = exp_bigintop ($1.integer, $1.str); }
971 { $$ = exp_nameop (SIZEOF_HEADERS,0); }
973 | ALIGNOF '(' NAME ')'
974 { $$ = exp_nameop (ALIGNOF,$3); }
975 | SIZEOF '(' NAME ')'
976 { $$ = exp_nameop (SIZEOF,$3); }
978 { $$ = exp_nameop (ADDR,$3); }
979 | LOADADDR '(' NAME ')'
980 { $$ = exp_nameop (LOADADDR,$3); }
981 | CONSTANT '(' NAME ')'
982 { $$ = exp_nameop (CONSTANT,$3); }
983 | ABSOLUTE '(' exp ')'
984 { $$ = exp_unop (ABSOLUTE, $3); }
985 | ALIGN_K '(' exp ')'
986 { $$ = exp_unop (ALIGN_K,$3); }
987 | ALIGN_K '(' exp ',' exp ')'
988 { $$ = exp_binop (ALIGN_K,$3,$5); }
989 | DATA_SEGMENT_ALIGN '(' exp ',' exp ')'
990 { $$ = exp_binop (DATA_SEGMENT_ALIGN, $3, $5); }
991 | DATA_SEGMENT_RELRO_END '(' exp ',' exp ')'
992 { $$ = exp_binop (DATA_SEGMENT_RELRO_END, $5, $3); }
993 | DATA_SEGMENT_END '(' exp ')'
994 { $$ = exp_unop (DATA_SEGMENT_END, $3); }
995 | SEGMENT_START '(' NAME ',' 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, $3)); }
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 '(' NAME ')'
1015 { $$ = exp_nameop (ORIGIN, $3); }
1016 | LENGTH '(' NAME ')'
1017 { $$ = exp_nameop (LENGTH, $3); }
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; }
1055 section: NAME { ldlex_expression(); }
1059 opt_align_with_input
1060 opt_subalign { ldlex_popstate (); ldlex_script (); }
1064 lang_enter_output_section_statement($1, $3,
1066 $5, $7, $4, $9, $6);
1069 '}' { ldlex_popstate (); ldlex_expression (); }
1070 memspec_opt memspec_at_opt phdr_opt fill_opt
1078 lang_leave_output_section_statement ($18, $15, $17, $16);
1082 { ldlex_expression (); }
1083 opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
1084 { ldlex_popstate (); ldlex_script (); }
1087 lang_enter_overlay ($3, $6);
1091 { ldlex_popstate (); ldlex_expression (); }
1092 memspec_opt memspec_at_opt phdr_opt fill_opt
1100 lang_leave_overlay ($5, (int) $4,
1101 $16, $13, $15, $14);
1104 | /* The GROUP case is just enough to support the gcc
1105 svr3.ifile script. It is not intended to be full
1106 support. I'm not even sure what GROUP is supposed
1108 GROUP { ldlex_expression (); }
1112 lang_add_assignment (exp_assign (".", $3, false));
1114 '{' sec_or_group_p1 '}'
1116 { ldlex_script (); ldfile_open_command_file($2); }
1118 { ldlex_popstate (); }
1122 NOLOAD { sectype = noload_section; }
1123 | DSECT { sectype = noalloc_section; }
1124 | COPY { sectype = noalloc_section; }
1125 | INFO { sectype = noalloc_section; }
1126 | OVERLAY { sectype = noalloc_section; }
1127 | READONLY { sectype = readonly_section; }
1132 | /* EMPTY */ { sectype = normal_section; }
1133 | '(' ')' { sectype = normal_section; }
1137 exp atype ':' { $$ = $1; }
1138 | atype ':' { $$ = (etree_type *)NULL; }
1139 | /* The BIND cases are to support the gcc svr3.ifile
1140 script. They aren't intended to implement full
1141 support for the BIND keyword. I'm not even sure
1142 what BIND is supposed to mean. */
1143 BIND '(' exp ')' atype ':' { $$ = $3; }
1144 | BIND '(' exp ')' BLOCK '(' exp ')' atype ':'
1148 opt_exp_without_type:
1149 exp ':' { $$ = $1; }
1150 | ':' { $$ = (etree_type *) NULL; }
1163 | { $$ = DEFAULT_MEMORY_REGION; }
1173 struct lang_output_section_phdr_list *n;
1175 n = ((struct lang_output_section_phdr_list *)
1176 xmalloc (sizeof *n));
1190 lang_enter_overlay_section ($2);
1192 '{' statement_list_opt '}'
1193 { ldlex_popstate (); ldlex_expression (); }
1197 lang_leave_overlay_section ($9, $8);
1203 PHDRS '{' phdr_list '}'
1212 NAME { ldlex_expression (); }
1213 phdr_type phdr_qualifiers { ldlex_popstate (); }
1216 lang_new_phdr ($1, $3, $4.filehdr, $4.phdrs, $4.at,
1226 if ($1->type.node_class == etree_name
1227 && $1->type.node_code == NAME)
1231 static const char * const phdr_types[] =
1233 "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
1234 "PT_INTERP", "PT_NOTE", "PT_SHLIB",
1240 i < sizeof phdr_types / sizeof phdr_types[0];
1242 if (strcmp (s, phdr_types[i]) == 0)
1247 if (i == sizeof phdr_types / sizeof phdr_types[0])
1249 if (strcmp (s, "PT_GNU_EH_FRAME") == 0)
1250 $$ = exp_intop (0x6474e550);
1251 else if (strcmp (s, "PT_GNU_STACK") == 0)
1252 $$ = exp_intop (0x6474e551);
1256 %X%P:%pS: unknown phdr type `%s' (try integer literal)\n"),
1268 memset (&$$, 0, sizeof (struct phdr_info));
1270 | NAME phdr_val phdr_qualifiers
1273 if (strcmp ($1, "FILEHDR") == 0 && $2 == NULL)
1275 else if (strcmp ($1, "PHDRS") == 0 && $2 == NULL)
1277 else if (strcmp ($1, "FLAGS") == 0 && $2 != NULL)
1280 einfo (_("%X%P:%pS: PHDRS syntax error at `%s'\n"),
1283 | AT '(' exp ')' phdr_qualifiers
1303 ldlex_version_file ();
1304 PUSH_ERROR (_("dynamic list"));
1315 | dynamic_list_nodes dynamic_list_node
1319 '{' dynamic_list_tag '}' ';'
1325 lang_append_dynamic_list (current_dynamic_list_p, $1);
1329 /* This syntax is used within an external version script file. */
1331 version_script_file:
1333 ldlex_version_file ();
1334 PUSH_ERROR (_("VERSION script"));
1343 /* This is used within a normal linker script file. */
1347 ldlex_version_script ();
1349 VERSIONK '{' vers_nodes '}'
1357 | vers_nodes vers_node
1361 '{' vers_tag '}' ';'
1363 lang_register_vers_node (NULL, $2, NULL);
1365 | VERS_TAG '{' vers_tag '}' ';'
1367 lang_register_vers_node ($1, $3, NULL);
1369 | VERS_TAG '{' vers_tag '}' verdep ';'
1371 lang_register_vers_node ($1, $3, $5);
1378 $$ = lang_add_vers_depend (NULL, $1);
1382 $$ = lang_add_vers_depend ($1, $2);
1389 $$ = lang_new_vers_node (NULL, NULL);
1393 $$ = lang_new_vers_node ($1, NULL);
1395 | GLOBAL ':' vers_defns ';'
1397 $$ = lang_new_vers_node ($3, NULL);
1399 | LOCAL ':' vers_defns ';'
1401 $$ = lang_new_vers_node (NULL, $3);
1403 | GLOBAL ':' vers_defns ';' LOCAL ':' vers_defns ';'
1405 $$ = lang_new_vers_node ($3, $7);
1412 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, false);
1416 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, true);
1418 | vers_defns ';' VERS_IDENTIFIER
1420 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, false);
1422 | vers_defns ';' NAME
1424 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, true);
1426 | vers_defns ';' EXTERN NAME '{'
1428 $<name>$ = ldgram_vers_current_lang;
1429 ldgram_vers_current_lang = $4;
1431 vers_defns opt_semicolon '}'
1433 struct bfd_elf_version_expr *pat;
1434 for (pat = $7; pat->next != NULL; pat = pat->next);
1437 ldgram_vers_current_lang = $<name>6;
1441 $<name>$ = ldgram_vers_current_lang;
1442 ldgram_vers_current_lang = $2;
1444 vers_defns opt_semicolon '}'
1447 ldgram_vers_current_lang = $<name>4;
1451 $$ = lang_new_vers_pattern (NULL, "global", ldgram_vers_current_lang, false);
1453 | vers_defns ';' GLOBAL
1455 $$ = lang_new_vers_pattern ($1, "global", ldgram_vers_current_lang, false);
1459 $$ = lang_new_vers_pattern (NULL, "local", ldgram_vers_current_lang, false);
1461 | vers_defns ';' LOCAL
1463 $$ = lang_new_vers_pattern ($1, "local", ldgram_vers_current_lang, false);
1467 $$ = lang_new_vers_pattern (NULL, "extern", ldgram_vers_current_lang, false);
1469 | vers_defns ';' EXTERN
1471 $$ = lang_new_vers_pattern ($1, "extern", ldgram_vers_current_lang, false);
1485 if (ldfile_assumed_script)
1486 einfo (_("%P:%s: file format not recognized; treating as linker script\n"),
1488 if (error_index > 0 && error_index < ERROR_NAME_MAX)
1489 einfo ("%F%P:%pS: %s in %s\n", NULL, arg, error_names[error_index - 1]);
1491 einfo ("%F%P:%pS: %s\n", NULL, arg);