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 Free Software Foundation, Inc.
6 This file is part of GNU ld.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
27 #define DONTDECLARE_MALLOC
48 static enum section_type sectype;
49 static lang_memory_region_type *region;
51 FILE *saved_script_handle = NULL;
52 bfd_boolean force_make_executable = FALSE;
54 bfd_boolean ldgram_in_script = FALSE;
55 bfd_boolean ldgram_had_equals = FALSE;
56 bfd_boolean ldgram_had_keep = FALSE;
57 char *ldgram_vers_current_lang = NULL;
59 #define ERROR_NAME_MAX 20
60 static char *error_names[ERROR_NAME_MAX];
61 static int error_index;
62 #define PUSH_ERROR(x) if (error_index < ERROR_NAME_MAX) error_names[error_index] = x; error_index++;
63 #define POP_ERROR() error_index--;
75 struct wildcard_spec wildcard;
76 struct wildcard_list *wildcard_list;
77 struct name_list *name_list;
79 union etree_union *etree;
84 union etree_union *at;
85 union etree_union *flags;
87 struct lang_nocrossref *nocrossref;
88 struct lang_output_section_phdr_list *section_phdr;
89 struct bfd_elf_version_deps *deflist;
90 struct bfd_elf_version_expr *versyms;
91 struct bfd_elf_version_tree *versnode;
94 %type <etree> exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val
95 %type <etree> opt_exp_without_type opt_subalign opt_align
96 %type <fill> fill_opt fill_exp
97 %type <name_list> exclude_name_list
98 %type <wildcard_list> file_NAME_list
99 %type <name> memspec_opt casesymlist
100 %type <name> memspec_at_opt
101 %type <cname> wildcard_name
102 %type <wildcard> wildcard_spec
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 DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END
130 %token SORT_BY_NAME SORT_BY_ALIGNMENT
132 %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
133 %token INHIBIT_COMMON_ALLOCATION
137 %token NOLOAD DSECT COPY INFO OVERLAY
138 %token DEFINED TARGET_K SEARCH_DIR MAP ENTRY
139 %token <integer> NEXT
140 %token SIZEOF ADDR LOADADDR MAX_K MIN_K
141 %token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS
143 %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS
144 %token ALIGNMOD AT SUBALIGN PROVIDE PROVIDE_HIDDEN AS_NEEDED
145 %type <token> assign_op atype attributes_opt sect_constraint
146 %type <name> filename
147 %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K
148 %token FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL
149 %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START
150 %token <name> VERS_TAG VERS_IDENTIFIER
151 %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT
152 %token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL
155 %type <versyms> vers_defns
156 %type <versnode> vers_tag
157 %type <deflist> verdep
158 %token INPUT_DYNAMIC_LIST
163 INPUT_SCRIPT script_file
164 | INPUT_MRI_SCRIPT mri_script_file
165 | INPUT_VERSION_SCRIPT version_script_file
166 | INPUT_DYNAMIC_LIST dynamic_list_file
167 | INPUT_DEFSYM defsym_expr
179 lang_add_assignment(exp_assop($3,$2,$4));
183 /* SYNTAX WITHIN AN MRI SCRIPT FILE */
187 PUSH_ERROR (_("MRI style script"));
198 mri_script_lines mri_script_command NEWLINE
206 einfo(_("%P%F: unrecognised keyword in MRI style script '%s'\n"),$1);
209 config.map_filename = "-";
211 | ORDER ordernamelist
213 | PUBLIC NAME '=' exp
214 { mri_public($2, $4); }
215 | PUBLIC NAME ',' exp
216 { mri_public($2, $4); }
218 { mri_public($2, $3); }
222 { mri_output_section($2, $4);}
224 { mri_output_section($2, $3);}
226 { mri_output_section($2, $4);}
227 | ALIGN_K NAME '=' exp
228 { mri_align($2,$4); }
229 | ALIGN_K NAME ',' exp
230 { mri_align($2,$4); }
231 | ALIGNMOD NAME '=' exp
232 { mri_alignmod($2,$4); }
233 | ALIGNMOD NAME ',' exp
234 { mri_alignmod($2,$4); }
235 | ABSOLUTE mri_abs_name_list
236 | LOAD mri_load_name_list
239 | ALIAS NAME ',' NAME
240 { mri_alias($2,$4,0);}
242 { mri_alias ($2, 0, (int) $4.integer); }
246 { mri_truncate ((unsigned int) $2.integer); }
248 | EXTERN extern_name_list
250 { ldlex_script (); ldfile_open_command_file($2); }
252 { ldlex_popstate (); }
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
283 /* Parsed as expressions so that commas separate entries */
285 { ldlex_expression (); }
286 extern_name_list_body
287 { ldlex_popstate (); }
289 extern_name_list_body:
291 { ldlang_add_undef ($1); }
292 | extern_name_list_body NAME
293 { ldlang_add_undef ($2); }
294 | extern_name_list_body ',' NAME
295 { ldlang_add_undef ($3); }
301 { ldlex_popstate(); }
317 | floating_point_support
321 | TARGET_K '(' NAME ')'
322 { lang_add_target($3); }
323 | SEARCH_DIR '(' filename ')'
324 { ldfile_add_library_path ($3, FALSE); }
325 | OUTPUT '(' filename ')'
326 { lang_add_output($3, 1); }
327 | OUTPUT_FORMAT '(' NAME ')'
328 { lang_add_output_format ($3, (char *) NULL,
330 | OUTPUT_FORMAT '(' NAME ',' NAME ',' NAME ')'
331 { lang_add_output_format ($3, $5, $7, 1); }
332 | OUTPUT_ARCH '(' NAME ')'
333 { ldfile_set_output_arch ($3, bfd_arch_unknown); }
334 | FORCE_COMMON_ALLOCATION
335 { command_line.force_common_definition = TRUE ; }
336 | INHIBIT_COMMON_ALLOCATION
337 { command_line.inhibit_common_definition = TRUE ; }
338 | INPUT '(' input_list ')'
340 { lang_enter_group (); }
342 { lang_leave_group (); }
343 | MAP '(' filename ')'
344 { lang_add_map($3); }
346 { ldlex_script (); ldfile_open_command_file($2); }
348 { ldlex_popstate (); }
349 | NOCROSSREFS '(' nocrossref_list ')'
351 lang_add_nocrossref ($3);
353 | EXTERN '(' extern_name_list ')'
358 { lang_add_input_file($1,lang_input_file_is_search_file_enum,
360 | input_list ',' NAME
361 { lang_add_input_file($3,lang_input_file_is_search_file_enum,
364 { lang_add_input_file($2,lang_input_file_is_search_file_enum,
367 { lang_add_input_file($1,lang_input_file_is_l_enum,
369 | input_list ',' LNAME
370 { lang_add_input_file($3,lang_input_file_is_l_enum,
373 { lang_add_input_file($2,lang_input_file_is_l_enum,
376 { $<integer>$ = as_needed; as_needed = TRUE; }
378 { as_needed = $<integer>3; }
379 | input_list ',' AS_NEEDED '('
380 { $<integer>$ = as_needed; as_needed = TRUE; }
382 { as_needed = $<integer>5; }
383 | input_list AS_NEEDED '('
384 { $<integer>$ = as_needed; as_needed = TRUE; }
386 { as_needed = $<integer>4; }
390 SECTIONS '{' sec_or_group_p1 '}'
394 sec_or_group_p1 section
395 | sec_or_group_p1 statement_anywhere
401 { lang_add_entry ($3, FALSE); }
403 | ASSERT_K {ldlex_expression ();} '(' exp ',' NAME ')'
405 lang_add_assignment (exp_assert ($4, $6)); }
408 /* The '*' and '?' cases are there because the lexer returns them as
409 separate tokens rather than as NAME. */
430 $$.exclude_name_list = NULL;
432 | EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name
436 $$.exclude_name_list = $3;
438 | SORT_BY_NAME '(' wildcard_name ')'
442 $$.exclude_name_list = NULL;
444 | SORT_BY_ALIGNMENT '(' wildcard_name ')'
447 $$.sorted = by_alignment;
448 $$.exclude_name_list = NULL;
450 | SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')'
453 $$.sorted = by_name_alignment;
454 $$.exclude_name_list = NULL;
456 | SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_name ')' ')'
460 $$.exclude_name_list = NULL;
462 | SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_name ')' ')'
465 $$.sorted = by_alignment_name;
466 $$.exclude_name_list = NULL;
468 | SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')'
471 $$.sorted = by_alignment;
472 $$.exclude_name_list = NULL;
474 | SORT_BY_NAME '(' EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name ')'
478 $$.exclude_name_list = $5;
483 exclude_name_list wildcard_name
485 struct name_list *tmp;
486 tmp = (struct name_list *) xmalloc (sizeof *tmp);
494 struct name_list *tmp;
495 tmp = (struct name_list *) xmalloc (sizeof *tmp);
503 file_NAME_list opt_comma wildcard_spec
505 struct wildcard_list *tmp;
506 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
514 struct wildcard_list *tmp;
515 tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
522 input_section_spec_no_keep:
525 struct wildcard_spec tmp;
527 tmp.exclude_name_list = NULL;
529 lang_add_wild (&tmp, NULL, ldgram_had_keep);
531 | '[' file_NAME_list ']'
533 lang_add_wild (NULL, $2, ldgram_had_keep);
535 | wildcard_spec '(' file_NAME_list ')'
537 lang_add_wild (&$1, $3, ldgram_had_keep);
542 input_section_spec_no_keep
544 { ldgram_had_keep = TRUE; }
545 input_section_spec_no_keep ')'
546 { ldgram_had_keep = FALSE; }
551 | CREATE_OBJECT_SYMBOLS
553 lang_add_attribute(lang_object_symbols_statement_enum);
559 lang_add_attribute(lang_constructors_statement_enum);
561 | SORT_BY_NAME '(' CONSTRUCTORS ')'
563 constructors_sorted = TRUE;
564 lang_add_attribute (lang_constructors_statement_enum);
567 | length '(' mustbe_exp ')'
569 lang_add_data ((int) $1, $3);
572 | FILL '(' fill_exp ')'
576 | ASSERT_K {ldlex_expression ();} '(' exp ',' NAME ')' end
578 lang_add_assignment (exp_assert ($4, $6)); }
582 statement_list statement
607 $$ = exp_get_fill ($1, 0, "fill value");
614 | { $$ = (fill_type *) 0; }
644 lang_add_assignment (exp_assop ($2, $1, $3));
646 | NAME assign_op mustbe_exp
648 lang_add_assignment (exp_assop ('=', $1,
654 | PROVIDE '(' NAME '=' mustbe_exp ')'
656 lang_add_assignment (exp_provide ($3, $5, FALSE));
658 | PROVIDE_HIDDEN '(' NAME '=' mustbe_exp ')'
660 lang_add_assignment (exp_provide ($3, $5, TRUE));
670 MEMORY '{' memory_spec memory_spec_list '}'
674 memory_spec_list memory_spec
675 | memory_spec_list ',' memory_spec
681 { region = lang_memory_region_lookup ($1, TRUE); }
683 origin_spec opt_comma length_spec
688 ORIGIN '=' mustbe_exp
690 region->origin = exp_get_vma ($3, 0, "origin");
691 region->current = region->origin;
696 LENGTH '=' mustbe_exp
698 region->length = exp_get_vma ($3, -1, "length");
704 { /* dummy action to avoid bison 1.25 error message */ }
705 | '(' attributes_list ')'
710 | attributes_list attributes_string
715 { lang_set_flags (region, $1, 0); }
717 { lang_set_flags (region, $2, 1); }
721 STARTUP '(' filename ')'
722 { lang_startup($3); }
726 HLL '(' high_level_library_NAME_list ')'
728 { ldemul_hll((char *)NULL); }
731 high_level_library_NAME_list:
732 high_level_library_NAME_list opt_comma filename
740 SYSLIB '(' low_level_library_NAME_list ')'
741 ; low_level_library_NAME_list:
742 low_level_library_NAME_list opt_comma filename
743 { ldemul_syslib($3); }
747 floating_point_support:
749 { lang_float(TRUE); }
751 { lang_float(FALSE); }
759 | NAME nocrossref_list
761 struct lang_nocrossref *n;
763 n = (struct lang_nocrossref *) xmalloc (sizeof *n);
768 | NAME ',' nocrossref_list
770 struct lang_nocrossref *n;
772 n = (struct lang_nocrossref *) xmalloc (sizeof *n);
779 mustbe_exp: { ldlex_expression (); }
781 { ldlex_popstate (); $$=$2;}
786 { $$ = exp_unop ('-', $2); }
789 | NEXT '(' exp ')' %prec UNARY
790 { $$ = exp_unop ((int) $1,$3); }
791 | '!' exp %prec UNARY
792 { $$ = exp_unop ('!', $2); }
793 | '+' exp %prec UNARY
795 | '~' exp %prec UNARY
796 { $$ = exp_unop ('~', $2);}
799 { $$ = exp_binop ('*', $1, $3); }
801 { $$ = exp_binop ('/', $1, $3); }
803 { $$ = exp_binop ('%', $1, $3); }
805 { $$ = exp_binop ('+', $1, $3); }
807 { $$ = exp_binop ('-' , $1, $3); }
809 { $$ = exp_binop (LSHIFT , $1, $3); }
811 { $$ = exp_binop (RSHIFT , $1, $3); }
813 { $$ = exp_binop (EQ , $1, $3); }
815 { $$ = exp_binop (NE , $1, $3); }
817 { $$ = exp_binop (LE , $1, $3); }
819 { $$ = exp_binop (GE , $1, $3); }
821 { $$ = exp_binop ('<' , $1, $3); }
823 { $$ = exp_binop ('>' , $1, $3); }
825 { $$ = exp_binop ('&' , $1, $3); }
827 { $$ = exp_binop ('^' , $1, $3); }
829 { $$ = exp_binop ('|' , $1, $3); }
830 | exp '?' exp ':' exp
831 { $$ = exp_trinop ('?' , $1, $3, $5); }
833 { $$ = exp_binop (ANDAND , $1, $3); }
835 { $$ = exp_binop (OROR , $1, $3); }
836 | DEFINED '(' NAME ')'
837 { $$ = exp_nameop (DEFINED, $3); }
839 { $$ = exp_bigintop ($1.integer, $1.str); }
841 { $$ = exp_nameop (SIZEOF_HEADERS,0); }
843 | SIZEOF '(' NAME ')'
844 { $$ = exp_nameop (SIZEOF,$3); }
846 { $$ = exp_nameop (ADDR,$3); }
847 | LOADADDR '(' NAME ')'
848 { $$ = exp_nameop (LOADADDR,$3); }
849 | CONSTANT '(' NAME ')'
850 { $$ = exp_nameop (CONSTANT,$3); }
851 | ABSOLUTE '(' exp ')'
852 { $$ = exp_unop (ABSOLUTE, $3); }
853 | ALIGN_K '(' exp ')'
854 { $$ = exp_unop (ALIGN_K,$3); }
855 | ALIGN_K '(' exp ',' exp ')'
856 { $$ = exp_binop (ALIGN_K,$3,$5); }
857 | DATA_SEGMENT_ALIGN '(' exp ',' exp ')'
858 { $$ = exp_binop (DATA_SEGMENT_ALIGN, $3, $5); }
859 | DATA_SEGMENT_RELRO_END '(' exp ',' exp ')'
860 { $$ = exp_binop (DATA_SEGMENT_RELRO_END, $5, $3); }
861 | DATA_SEGMENT_END '(' exp ')'
862 { $$ = exp_unop (DATA_SEGMENT_END, $3); }
863 | SEGMENT_START '(' NAME ',' exp ')'
864 { /* The operands to the expression node are
865 placed in the opposite order from the way
866 in which they appear in the script as
867 that allows us to reuse more code in
869 $$ = exp_binop (SEGMENT_START,
871 exp_nameop (NAME, $3)); }
873 { $$ = exp_unop (ALIGN_K,$3); }
875 { $$ = exp_nameop (NAME,$1); }
876 | MAX_K '(' exp ',' exp ')'
877 { $$ = exp_binop (MAX_K, $3, $5 ); }
878 | MIN_K '(' exp ',' exp ')'
879 { $$ = exp_binop (MIN_K, $3, $5 ); }
880 | ASSERT_K '(' exp ',' NAME ')'
881 { $$ = exp_assert ($3, $5); }
882 | ORIGIN '(' NAME ')'
883 { $$ = exp_nameop (ORIGIN, $3); }
884 | LENGTH '(' NAME ')'
885 { $$ = exp_nameop (LENGTH, $3); }
890 AT '>' NAME { $$ = $3; }
895 AT '(' exp ')' { $$ = $3; }
900 ALIGN_K '(' exp ')' { $$ = $3; }
905 SUBALIGN '(' exp ')' { $$ = $3; }
910 ONLY_IF_RO { $$ = ONLY_IF_RO; }
911 | ONLY_IF_RW { $$ = ONLY_IF_RW; }
912 | SPECIAL { $$ = SPECIAL; }
916 section: NAME { ldlex_expression(); }
920 opt_subalign { ldlex_popstate (); ldlex_script (); }
924 lang_enter_output_section_statement($1, $3,
929 '}' { ldlex_popstate (); ldlex_expression (); }
930 memspec_opt memspec_at_opt phdr_opt fill_opt
933 lang_leave_output_section_statement ($17, $14, $16, $15);
938 { ldlex_expression (); }
939 opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
940 { ldlex_popstate (); ldlex_script (); }
943 lang_enter_overlay ($3, $6);
947 { ldlex_popstate (); ldlex_expression (); }
948 memspec_opt memspec_at_opt phdr_opt fill_opt
951 lang_leave_overlay ($5, (int) $4,
955 | /* The GROUP case is just enough to support the gcc
956 svr3.ifile script. It is not intended to be full
957 support. I'm not even sure what GROUP is supposed
959 GROUP { ldlex_expression (); }
963 lang_add_assignment (exp_assop ('=', ".", $3));
965 '{' sec_or_group_p1 '}'
969 NOLOAD { sectype = noload_section; }
970 | DSECT { sectype = noalloc_section; }
971 | COPY { sectype = noalloc_section; }
972 | INFO { sectype = noalloc_section; }
973 | OVERLAY { sectype = noalloc_section; }
978 | /* EMPTY */ { sectype = normal_section; }
979 | '(' ')' { sectype = normal_section; }
983 exp atype ':' { $$ = $1; }
984 | atype ':' { $$ = (etree_type *)NULL; }
985 | /* The BIND cases are to support the gcc svr3.ifile
986 script. They aren't intended to implement full
987 support for the BIND keyword. I'm not even sure
988 what BIND is supposed to mean. */
989 BIND '(' exp ')' atype ':' { $$ = $3; }
990 | BIND '(' exp ')' BLOCK '(' exp ')' atype ':'
994 opt_exp_without_type:
996 | ':' { $$ = (etree_type *) NULL; }
1009 | { $$ = DEFAULT_MEMORY_REGION; }
1019 struct lang_output_section_phdr_list *n;
1021 n = ((struct lang_output_section_phdr_list *)
1022 xmalloc (sizeof *n));
1036 lang_enter_overlay_section ($2);
1038 '{' statement_list_opt '}'
1039 { ldlex_popstate (); ldlex_expression (); }
1043 lang_leave_overlay_section ($9, $8);
1049 PHDRS '{' phdr_list '}'
1058 NAME { ldlex_expression (); }
1059 phdr_type phdr_qualifiers { ldlex_popstate (); }
1062 lang_new_phdr ($1, $3, $4.filehdr, $4.phdrs, $4.at,
1072 if ($1->type.node_class == etree_name
1073 && $1->type.node_code == NAME)
1077 static const char * const phdr_types[] =
1079 "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
1080 "PT_INTERP", "PT_NOTE", "PT_SHLIB",
1086 i < sizeof phdr_types / sizeof phdr_types[0];
1088 if (strcmp (s, phdr_types[i]) == 0)
1093 if (i == sizeof phdr_types / sizeof phdr_types[0])
1095 if (strcmp (s, "PT_GNU_EH_FRAME") == 0)
1096 $$ = exp_intop (0x6474e550);
1097 else if (strcmp (s, "PT_GNU_STACK") == 0)
1098 $$ = exp_intop (0x6474e551);
1102 %X%P:%S: unknown phdr type `%s' (try integer literal)\n"),
1114 memset (&$$, 0, sizeof (struct phdr_info));
1116 | NAME phdr_val phdr_qualifiers
1119 if (strcmp ($1, "FILEHDR") == 0 && $2 == NULL)
1121 else if (strcmp ($1, "PHDRS") == 0 && $2 == NULL)
1123 else if (strcmp ($1, "FLAGS") == 0 && $2 != NULL)
1126 einfo (_("%X%P:%S: PHDRS syntax error at `%s'\n"), $1);
1128 | AT '(' exp ')' phdr_qualifiers
1148 ldlex_version_file ();
1149 PUSH_ERROR (_("dynamic list"));
1160 | dynamic_list_nodes dynamic_list_node
1164 '{' dynamic_list_tag '}' ';'
1170 lang_append_dynamic_list ($1);
1174 /* This syntax is used within an external version script file. */
1176 version_script_file:
1178 ldlex_version_file ();
1179 PUSH_ERROR (_("VERSION script"));
1188 /* This is used within a normal linker script file. */
1192 ldlex_version_script ();
1194 VERSIONK '{' vers_nodes '}'
1202 | vers_nodes vers_node
1206 '{' vers_tag '}' ';'
1208 lang_register_vers_node (NULL, $2, NULL);
1210 | VERS_TAG '{' vers_tag '}' ';'
1212 lang_register_vers_node ($1, $3, NULL);
1214 | VERS_TAG '{' vers_tag '}' verdep ';'
1216 lang_register_vers_node ($1, $3, $5);
1223 $$ = lang_add_vers_depend (NULL, $1);
1227 $$ = lang_add_vers_depend ($1, $2);
1234 $$ = lang_new_vers_node (NULL, NULL);
1238 $$ = lang_new_vers_node ($1, NULL);
1240 | GLOBAL ':' vers_defns ';'
1242 $$ = lang_new_vers_node ($3, NULL);
1244 | LOCAL ':' vers_defns ';'
1246 $$ = lang_new_vers_node (NULL, $3);
1248 | GLOBAL ':' vers_defns ';' LOCAL ':' vers_defns ';'
1250 $$ = lang_new_vers_node ($3, $7);
1257 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, FALSE);
1261 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, TRUE);
1263 | vers_defns ';' VERS_IDENTIFIER
1265 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, FALSE);
1267 | vers_defns ';' NAME
1269 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, TRUE);
1271 | vers_defns ';' EXTERN NAME '{'
1273 $<name>$ = ldgram_vers_current_lang;
1274 ldgram_vers_current_lang = $4;
1276 vers_defns opt_semicolon '}'
1278 struct bfd_elf_version_expr *pat;
1279 for (pat = $7; pat->next != NULL; pat = pat->next);
1282 ldgram_vers_current_lang = $<name>6;
1286 $<name>$ = ldgram_vers_current_lang;
1287 ldgram_vers_current_lang = $2;
1289 vers_defns opt_semicolon '}'
1292 ldgram_vers_current_lang = $<name>4;
1296 $$ = lang_new_vers_pattern (NULL, "global", ldgram_vers_current_lang, FALSE);
1298 | vers_defns ';' GLOBAL
1300 $$ = lang_new_vers_pattern ($1, "global", ldgram_vers_current_lang, FALSE);
1304 $$ = lang_new_vers_pattern (NULL, "local", ldgram_vers_current_lang, FALSE);
1306 | vers_defns ';' LOCAL
1308 $$ = lang_new_vers_pattern ($1, "local", ldgram_vers_current_lang, FALSE);
1312 $$ = lang_new_vers_pattern (NULL, "extern", ldgram_vers_current_lang, FALSE);
1314 | vers_defns ';' EXTERN
1316 $$ = lang_new_vers_pattern ($1, "extern", ldgram_vers_current_lang, FALSE);
1330 if (ldfile_assumed_script)
1331 einfo (_("%P:%s: file format not recognized; treating as linker script\n"),
1332 ldfile_input_filename);
1333 if (error_index > 0 && error_index < ERROR_NAME_MAX)
1334 einfo ("%P%F:%S: %s in %s\n", arg, error_names[error_index-1]);
1336 einfo ("%P%F:%S: %s\n", arg);