]>
Commit | Line | Data |
---|---|---|
8e5a525c AM |
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, | |
7e7d5768 | 3 | 2001, 2002, 2003 Free Software Foundation, Inc. |
252b5132 RH |
4 | Written by Steve Chamberlain of Cygnus Support ([email protected]). |
5 | ||
6 | This file is part of GNU ld. | |
7 | ||
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. | |
12 | ||
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. | |
17 | ||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | %{ | |
23 | /* | |
24 | ||
25 | */ | |
26 | ||
27 | #define DONTDECLARE_MALLOC | |
28 | ||
29 | #include "bfd.h" | |
30 | #include "sysdep.h" | |
31 | #include "bfdlink.h" | |
d038301c | 32 | #include "ld.h" |
252b5132 RH |
33 | #include "ldexp.h" |
34 | #include "ldver.h" | |
35 | #include "ldlang.h" | |
252b5132 | 36 | #include "ldfile.h" |
b71e2778 | 37 | #include "ldemul.h" |
252b5132 RH |
38 | #include "ldmisc.h" |
39 | #include "ldmain.h" | |
40 | #include "mri.h" | |
41 | #include "ldctor.h" | |
42 | #include "ldlex.h" | |
43 | ||
44 | #ifndef YYDEBUG | |
45 | #define YYDEBUG 1 | |
46 | #endif | |
47 | ||
48 | static enum section_type sectype; | |
49 | ||
50 | lang_memory_region_type *region; | |
51 | ||
b34976b6 AM |
52 | bfd_boolean ldgram_want_filename = TRUE; |
53 | FILE *saved_script_handle = NULL; | |
54 | bfd_boolean force_make_executable = FALSE; | |
252b5132 | 55 | |
b34976b6 AM |
56 | bfd_boolean ldgram_in_script = FALSE; |
57 | bfd_boolean ldgram_had_equals = FALSE; | |
58 | bfd_boolean ldgram_had_keep = FALSE; | |
252b5132 RH |
59 | char *ldgram_vers_current_lang = NULL; |
60 | ||
61 | #define ERROR_NAME_MAX 20 | |
62 | static char *error_names[ERROR_NAME_MAX]; | |
63 | static int error_index; | |
64 | #define PUSH_ERROR(x) if (error_index < ERROR_NAME_MAX) error_names[error_index] = x; error_index++; | |
65 | #define POP_ERROR() error_index--; | |
66 | %} | |
67 | %union { | |
68 | bfd_vma integer; | |
2c382fb6 AM |
69 | struct big_int |
70 | { | |
71 | bfd_vma integer; | |
72 | char *str; | |
73 | } bigint; | |
74 | fill_type *fill; | |
252b5132 RH |
75 | char *name; |
76 | const char *cname; | |
77 | struct wildcard_spec wildcard; | |
b6bf44ba | 78 | struct wildcard_list *wildcard_list; |
18625d54 | 79 | struct name_list *name_list; |
252b5132 RH |
80 | int token; |
81 | union etree_union *etree; | |
82 | struct phdr_info | |
83 | { | |
b34976b6 AM |
84 | bfd_boolean filehdr; |
85 | bfd_boolean phdrs; | |
252b5132 RH |
86 | union etree_union *at; |
87 | union etree_union *flags; | |
88 | } phdr; | |
89 | struct lang_nocrossref *nocrossref; | |
90 | struct lang_output_section_phdr_list *section_phdr; | |
91 | struct bfd_elf_version_deps *deflist; | |
92 | struct bfd_elf_version_expr *versyms; | |
93 | struct bfd_elf_version_tree *versnode; | |
94 | } | |
95 | ||
96 | %type <etree> exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val | |
7e7d5768 | 97 | %type <etree> opt_exp_without_type opt_subalign |
2c382fb6 | 98 | %type <fill> fill_opt fill_exp |
18625d54 | 99 | %type <name_list> exclude_name_list |
b6bf44ba | 100 | %type <wildcard_list> file_NAME_list |
252b5132 | 101 | %type <name> memspec_opt casesymlist |
562d3460 | 102 | %type <name> memspec_at_opt |
252b5132 RH |
103 | %type <cname> wildcard_name |
104 | %type <wildcard> wildcard_spec | |
d038301c | 105 | %token <bigint> INT |
252b5132 RH |
106 | %token <name> NAME LNAME |
107 | %type <integer> length | |
108 | %type <phdr> phdr_qualifiers | |
109 | %type <nocrossref> nocrossref_list | |
110 | %type <section_phdr> phdr_opt | |
111 | %type <integer> opt_nocrossrefs | |
112 | ||
d038301c | 113 | %right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ |
252b5132 RH |
114 | %right <token> '?' ':' |
115 | %left <token> OROR | |
116 | %left <token> ANDAND | |
117 | %left <token> '|' | |
118 | %left <token> '^' | |
119 | %left <token> '&' | |
120 | %left <token> EQ NE | |
121 | %left <token> '<' '>' LE GE | |
122 | %left <token> LSHIFT RSHIFT | |
123 | ||
124 | %left <token> '+' '-' | |
125 | %left <token> '*' '/' '%' | |
126 | ||
127 | %right UNARY | |
d038301c | 128 | %token END |
252b5132 RH |
129 | %left <token> '(' |
130 | %token <token> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE | |
8c37241b | 131 | %token SECTIONS PHDRS SORT DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END |
252b5132 RH |
132 | %token '{' '}' |
133 | %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH | |
4818e05f | 134 | %token INHIBIT_COMMON_ALLOCATION |
252b5132 RH |
135 | %token SIZEOF_HEADERS |
136 | %token INCLUDE | |
137 | %token MEMORY DEFSYMEND | |
138 | %token NOLOAD DSECT COPY INFO OVERLAY | |
139 | %token NAME LNAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY | |
140 | %token <integer> NEXT | |
141 | %token SIZEOF ADDR LOADADDR MAX_K MIN_K | |
142 | %token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS | |
143 | %token ORIGIN FILL | |
144 | %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS | |
7e7d5768 | 145 | %token ALIGNMOD AT SUBALIGN PROVIDE |
0841712e | 146 | %type <token> assign_op atype attributes_opt sect_constraint |
252b5132 RH |
147 | %type <name> filename |
148 | %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K | |
149 | %token FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL | |
150 | %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START | |
151 | %token <name> VERS_TAG VERS_IDENTIFIER | |
152 | %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT | |
0841712e | 153 | %token KEEP ONLY_IF_RO ONLY_IF_RW |
252b5132 RH |
154 | %token EXCLUDE_FILE |
155 | %type <versyms> vers_defns | |
156 | %type <versnode> vers_tag | |
157 | %type <deflist> verdep | |
158 | ||
159 | %% | |
160 | ||
d038301c | 161 | file: |
252b5132 RH |
162 | INPUT_SCRIPT script_file |
163 | | INPUT_MRI_SCRIPT mri_script_file | |
164 | | INPUT_VERSION_SCRIPT version_script_file | |
165 | | INPUT_DEFSYM defsym_expr | |
166 | ; | |
167 | ||
168 | ||
169 | filename: NAME; | |
170 | ||
171 | ||
172 | defsym_expr: | |
173 | { ldlex_defsym(); } | |
174 | NAME '=' exp | |
175 | { | |
176 | ldlex_popstate(); | |
177 | lang_add_assignment(exp_assop($3,$2,$4)); | |
178 | } | |
944cd72c | 179 | ; |
252b5132 | 180 | |
d038301c | 181 | /* SYNTAX WITHIN AN MRI SCRIPT FILE */ |
252b5132 RH |
182 | mri_script_file: |
183 | { | |
184 | ldlex_mri_script (); | |
185 | PUSH_ERROR (_("MRI style script")); | |
186 | } | |
187 | mri_script_lines | |
188 | { | |
189 | ldlex_popstate (); | |
190 | mri_draw_tree (); | |
191 | POP_ERROR (); | |
192 | } | |
193 | ; | |
194 | ||
195 | mri_script_lines: | |
196 | mri_script_lines mri_script_command NEWLINE | |
197 | | | |
198 | ; | |
199 | ||
200 | mri_script_command: | |
d038301c | 201 | CHIP exp |
252b5132 RH |
202 | | CHIP exp ',' exp |
203 | | NAME { | |
204 | einfo(_("%P%F: unrecognised keyword in MRI style script '%s'\n"),$1); | |
205 | } | |
206 | | LIST { | |
207 | config.map_filename = "-"; | |
208 | } | |
209 | | ORDER ordernamelist | |
d038301c | 210 | | ENDWORD |
252b5132 RH |
211 | | PUBLIC NAME '=' exp |
212 | { mri_public($2, $4); } | |
213 | | PUBLIC NAME ',' exp | |
214 | { mri_public($2, $4); } | |
d038301c | 215 | | PUBLIC NAME exp |
252b5132 RH |
216 | { mri_public($2, $3); } |
217 | | FORMAT NAME | |
218 | { mri_format($2); } | |
219 | | SECT NAME ',' exp | |
220 | { mri_output_section($2, $4);} | |
221 | | SECT NAME exp | |
222 | { mri_output_section($2, $3);} | |
223 | | SECT NAME '=' exp | |
224 | { mri_output_section($2, $4);} | |
225 | | ALIGN_K NAME '=' exp | |
226 | { mri_align($2,$4); } | |
227 | | ALIGN_K NAME ',' exp | |
228 | { mri_align($2,$4); } | |
229 | | ALIGNMOD NAME '=' exp | |
230 | { mri_alignmod($2,$4); } | |
231 | | ALIGNMOD NAME ',' exp | |
232 | { mri_alignmod($2,$4); } | |
233 | | ABSOLUTE mri_abs_name_list | |
234 | | LOAD mri_load_name_list | |
d038301c RM |
235 | | NAMEWORD NAME |
236 | { mri_name($2); } | |
252b5132 RH |
237 | | ALIAS NAME ',' NAME |
238 | { mri_alias($2,$4,0);} | |
239 | | ALIAS NAME ',' INT | |
2c382fb6 | 240 | { mri_alias ($2, 0, (int) $4.integer); } |
252b5132 RH |
241 | | BASE exp |
242 | { mri_base($2); } | |
2c382fb6 AM |
243 | | TRUNCATE INT |
244 | { mri_truncate ((unsigned int) $2.integer); } | |
252b5132 RH |
245 | | CASE casesymlist |
246 | | EXTERN extern_name_list | |
247 | | INCLUDE filename | |
b47c4208 AM |
248 | { ldlex_script (); ldfile_open_command_file($2); } |
249 | mri_script_lines END | |
250 | { ldlex_popstate (); } | |
252b5132 | 251 | | START NAME |
b34976b6 | 252 | { lang_add_entry ($2, FALSE); } |
252b5132 RH |
253 | | |
254 | ; | |
255 | ||
256 | ordernamelist: | |
257 | ordernamelist ',' NAME { mri_order($3); } | |
258 | | ordernamelist NAME { mri_order($2); } | |
259 | | | |
260 | ; | |
261 | ||
262 | mri_load_name_list: | |
263 | NAME | |
264 | { mri_load($1); } | |
265 | | mri_load_name_list ',' NAME { mri_load($3); } | |
266 | ; | |
267 | ||
268 | mri_abs_name_list: | |
269 | NAME | |
270 | { mri_only_load($1); } | |
271 | | mri_abs_name_list ',' NAME | |
272 | { mri_only_load($3); } | |
273 | ; | |
274 | ||
275 | casesymlist: | |
276 | /* empty */ { $$ = NULL; } | |
277 | | NAME | |
278 | | casesymlist ',' NAME | |
279 | ; | |
280 | ||
281 | extern_name_list: | |
282 | NAME | |
283 | { ldlang_add_undef ($1); } | |
284 | | extern_name_list NAME | |
285 | { ldlang_add_undef ($2); } | |
286 | | extern_name_list ',' NAME | |
287 | { ldlang_add_undef ($3); } | |
288 | ; | |
289 | ||
290 | script_file: | |
291 | { | |
292 | ldlex_both(); | |
293 | } | |
294 | ifile_list | |
295 | { | |
296 | ldlex_popstate(); | |
297 | } | |
298 | ; | |
299 | ||
300 | ||
301 | ifile_list: | |
302 | ifile_list ifile_p1 | |
303 | | | |
304 | ; | |
305 | ||
306 | ||
307 | ||
308 | ifile_p1: | |
309 | memory | |
310 | | sections | |
311 | | phdrs | |
312 | | startup | |
313 | | high_level_library | |
314 | | low_level_library | |
315 | | floating_point_support | |
316 | | statement_anywhere | |
317 | | version | |
318 | | ';' | |
319 | | TARGET_K '(' NAME ')' | |
320 | { lang_add_target($3); } | |
321 | | SEARCH_DIR '(' filename ')' | |
b34976b6 | 322 | { ldfile_add_library_path ($3, FALSE); } |
252b5132 RH |
323 | | OUTPUT '(' filename ')' |
324 | { lang_add_output($3, 1); } | |
325 | | OUTPUT_FORMAT '(' NAME ')' | |
326 | { lang_add_output_format ($3, (char *) NULL, | |
327 | (char *) NULL, 1); } | |
328 | | OUTPUT_FORMAT '(' NAME ',' NAME ',' NAME ')' | |
329 | { lang_add_output_format ($3, $5, $7, 1); } | |
330 | | OUTPUT_ARCH '(' NAME ')' | |
5e2f1575 | 331 | { ldfile_set_output_arch ($3, bfd_arch_unknown); } |
252b5132 | 332 | | FORCE_COMMON_ALLOCATION |
b34976b6 | 333 | { command_line.force_common_definition = TRUE ; } |
4818e05f | 334 | | INHIBIT_COMMON_ALLOCATION |
b34976b6 | 335 | { command_line.inhibit_common_definition = TRUE ; } |
252b5132 RH |
336 | | INPUT '(' input_list ')' |
337 | | GROUP | |
338 | { lang_enter_group (); } | |
339 | '(' input_list ')' | |
340 | { lang_leave_group (); } | |
341 | | MAP '(' filename ')' | |
342 | { lang_add_map($3); } | |
d038301c | 343 | | INCLUDE filename |
b47c4208 AM |
344 | { ldlex_script (); ldfile_open_command_file($2); } |
345 | ifile_list END | |
346 | { ldlex_popstate (); } | |
252b5132 RH |
347 | | NOCROSSREFS '(' nocrossref_list ')' |
348 | { | |
349 | lang_add_nocrossref ($3); | |
350 | } | |
351 | | EXTERN '(' extern_name_list ')' | |
352 | ; | |
353 | ||
354 | input_list: | |
355 | NAME | |
356 | { lang_add_input_file($1,lang_input_file_is_search_file_enum, | |
357 | (char *)NULL); } | |
358 | | input_list ',' NAME | |
359 | { lang_add_input_file($3,lang_input_file_is_search_file_enum, | |
360 | (char *)NULL); } | |
361 | | input_list NAME | |
362 | { lang_add_input_file($2,lang_input_file_is_search_file_enum, | |
363 | (char *)NULL); } | |
364 | | LNAME | |
365 | { lang_add_input_file($1,lang_input_file_is_l_enum, | |
366 | (char *)NULL); } | |
367 | | input_list ',' LNAME | |
368 | { lang_add_input_file($3,lang_input_file_is_l_enum, | |
369 | (char *)NULL); } | |
370 | | input_list LNAME | |
371 | { lang_add_input_file($2,lang_input_file_is_l_enum, | |
372 | (char *)NULL); } | |
373 | ; | |
374 | ||
375 | sections: | |
376 | SECTIONS '{' sec_or_group_p1 '}' | |
377 | ; | |
378 | ||
379 | sec_or_group_p1: | |
380 | sec_or_group_p1 section | |
381 | | sec_or_group_p1 statement_anywhere | |
382 | | | |
383 | ; | |
384 | ||
385 | statement_anywhere: | |
386 | ENTRY '(' NAME ')' | |
b34976b6 | 387 | { lang_add_entry ($3, FALSE); } |
252b5132 | 388 | | assignment end |
b6ca8815 NS |
389 | | ASSERT_K {ldlex_expression ();} '(' exp ',' NAME ')' |
390 | { ldlex_popstate (); | |
391 | lang_add_assignment (exp_assert ($4, $6)); } | |
252b5132 RH |
392 | ; |
393 | ||
394 | /* The '*' and '?' cases are there because the lexer returns them as | |
395 | separate tokens rather than as NAME. */ | |
396 | wildcard_name: | |
397 | NAME | |
398 | { | |
399 | $$ = $1; | |
400 | } | |
401 | | '*' | |
402 | { | |
403 | $$ = "*"; | |
404 | } | |
405 | | '?' | |
406 | { | |
407 | $$ = "?"; | |
408 | } | |
409 | ; | |
410 | ||
411 | wildcard_spec: | |
412 | wildcard_name | |
413 | { | |
414 | $$.name = $1; | |
b34976b6 | 415 | $$.sorted = FALSE; |
18625d54 | 416 | $$.exclude_name_list = NULL; |
252b5132 | 417 | } |
18625d54 | 418 | | EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name |
252b5132 RH |
419 | { |
420 | $$.name = $5; | |
b34976b6 | 421 | $$.sorted = FALSE; |
18625d54 | 422 | $$.exclude_name_list = $3; |
252b5132 RH |
423 | } |
424 | | SORT '(' wildcard_name ')' | |
425 | { | |
426 | $$.name = $3; | |
b34976b6 | 427 | $$.sorted = TRUE; |
18625d54 | 428 | $$.exclude_name_list = NULL; |
252b5132 | 429 | } |
18625d54 | 430 | | SORT '(' EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name ')' |
252b5132 RH |
431 | { |
432 | $$.name = $7; | |
b34976b6 | 433 | $$.sorted = TRUE; |
18625d54 | 434 | $$.exclude_name_list = $5; |
252b5132 RH |
435 | } |
436 | ; | |
437 | ||
18625d54 | 438 | exclude_name_list: |
765b7cbe | 439 | exclude_name_list wildcard_name |
18625d54 CM |
440 | { |
441 | struct name_list *tmp; | |
442 | tmp = (struct name_list *) xmalloc (sizeof *tmp); | |
765b7cbe | 443 | tmp->name = $2; |
18625d54 | 444 | tmp->next = $1; |
d038301c | 445 | $$ = tmp; |
18625d54 CM |
446 | } |
447 | | | |
448 | wildcard_name | |
449 | { | |
450 | struct name_list *tmp; | |
451 | tmp = (struct name_list *) xmalloc (sizeof *tmp); | |
452 | tmp->name = $1; | |
453 | tmp->next = NULL; | |
454 | $$ = tmp; | |
455 | } | |
456 | ; | |
457 | ||
252b5132 | 458 | file_NAME_list: |
b6bf44ba | 459 | file_NAME_list opt_comma wildcard_spec |
252b5132 | 460 | { |
b6bf44ba AM |
461 | struct wildcard_list *tmp; |
462 | tmp = (struct wildcard_list *) xmalloc (sizeof *tmp); | |
463 | tmp->next = $1; | |
464 | tmp->spec = $3; | |
465 | $$ = tmp; | |
252b5132 | 466 | } |
b6bf44ba AM |
467 | | |
468 | wildcard_spec | |
252b5132 | 469 | { |
b6bf44ba AM |
470 | struct wildcard_list *tmp; |
471 | tmp = (struct wildcard_list *) xmalloc (sizeof *tmp); | |
472 | tmp->next = NULL; | |
473 | tmp->spec = $1; | |
474 | $$ = tmp; | |
252b5132 RH |
475 | } |
476 | ; | |
477 | ||
478 | input_section_spec_no_keep: | |
479 | NAME | |
480 | { | |
b6bf44ba AM |
481 | struct wildcard_spec tmp; |
482 | tmp.name = $1; | |
483 | tmp.exclude_name_list = NULL; | |
b34976b6 | 484 | tmp.sorted = FALSE; |
b6bf44ba | 485 | lang_add_wild (&tmp, NULL, ldgram_had_keep); |
252b5132 | 486 | } |
b6bf44ba | 487 | | '[' file_NAME_list ']' |
252b5132 | 488 | { |
b6bf44ba | 489 | lang_add_wild (NULL, $2, ldgram_had_keep); |
252b5132 | 490 | } |
b6bf44ba | 491 | | wildcard_spec '(' file_NAME_list ')' |
252b5132 | 492 | { |
b6bf44ba | 493 | lang_add_wild (&$1, $3, ldgram_had_keep); |
252b5132 | 494 | } |
252b5132 RH |
495 | ; |
496 | ||
497 | input_section_spec: | |
498 | input_section_spec_no_keep | |
499 | | KEEP '(' | |
b34976b6 | 500 | { ldgram_had_keep = TRUE; } |
252b5132 | 501 | input_section_spec_no_keep ')' |
b34976b6 | 502 | { ldgram_had_keep = FALSE; } |
252b5132 RH |
503 | ; |
504 | ||
505 | statement: | |
506 | assignment end | |
507 | | CREATE_OBJECT_SYMBOLS | |
508 | { | |
d038301c | 509 | lang_add_attribute(lang_object_symbols_statement_enum); |
252b5132 RH |
510 | } |
511 | | ';' | |
512 | | CONSTRUCTORS | |
513 | { | |
d038301c RM |
514 | |
515 | lang_add_attribute(lang_constructors_statement_enum); | |
252b5132 RH |
516 | } |
517 | | SORT '(' CONSTRUCTORS ')' | |
518 | { | |
b34976b6 | 519 | constructors_sorted = TRUE; |
252b5132 RH |
520 | lang_add_attribute (lang_constructors_statement_enum); |
521 | } | |
522 | | input_section_spec | |
523 | | length '(' mustbe_exp ')' | |
524 | { | |
2c382fb6 | 525 | lang_add_data ((int) $1, $3); |
252b5132 | 526 | } |
d038301c | 527 | |
2c382fb6 | 528 | | FILL '(' fill_exp ')' |
252b5132 | 529 | { |
2c382fb6 | 530 | lang_add_fill ($3); |
252b5132 RH |
531 | } |
532 | ; | |
533 | ||
534 | statement_list: | |
535 | statement_list statement | |
536 | | statement | |
537 | ; | |
d038301c | 538 | |
252b5132 RH |
539 | statement_list_opt: |
540 | /* empty */ | |
541 | | statement_list | |
542 | ; | |
543 | ||
544 | length: | |
545 | QUAD | |
546 | { $$ = $1; } | |
547 | | SQUAD | |
548 | { $$ = $1; } | |
549 | | LONG | |
550 | { $$ = $1; } | |
551 | | SHORT | |
552 | { $$ = $1; } | |
553 | | BYTE | |
554 | { $$ = $1; } | |
555 | ; | |
556 | ||
2c382fb6 AM |
557 | fill_exp: |
558 | mustbe_exp | |
252b5132 | 559 | { |
2c382fb6 AM |
560 | $$ = exp_get_fill ($1, |
561 | 0, | |
562 | "fill value", | |
563 | lang_first_phase_enum); | |
252b5132 | 564 | } |
252b5132 RH |
565 | ; |
566 | ||
2c382fb6 AM |
567 | fill_opt: |
568 | '=' fill_exp | |
569 | { $$ = $2; } | |
570 | | { $$ = (fill_type *) 0; } | |
571 | ; | |
252b5132 RH |
572 | |
573 | assign_op: | |
574 | PLUSEQ | |
575 | { $$ = '+'; } | |
576 | | MINUSEQ | |
577 | { $$ = '-'; } | |
578 | | MULTEQ | |
579 | { $$ = '*'; } | |
580 | | DIVEQ | |
581 | { $$ = '/'; } | |
582 | | LSHIFTEQ | |
583 | { $$ = LSHIFT; } | |
584 | | RSHIFTEQ | |
585 | { $$ = RSHIFT; } | |
586 | | ANDEQ | |
587 | { $$ = '&'; } | |
588 | | OREQ | |
589 | { $$ = '|'; } | |
590 | ||
591 | ; | |
592 | ||
593 | end: ';' | ',' | |
594 | ; | |
595 | ||
596 | ||
597 | assignment: | |
598 | NAME '=' mustbe_exp | |
599 | { | |
600 | lang_add_assignment (exp_assop ($2, $1, $3)); | |
601 | } | |
602 | | NAME assign_op mustbe_exp | |
603 | { | |
604 | lang_add_assignment (exp_assop ('=', $1, | |
605 | exp_binop ($2, | |
606 | exp_nameop (NAME, | |
607 | $1), | |
608 | $3))); | |
609 | } | |
610 | | PROVIDE '(' NAME '=' mustbe_exp ')' | |
611 | { | |
612 | lang_add_assignment (exp_provide ($3, $5)); | |
613 | } | |
614 | ; | |
615 | ||
616 | ||
617 | opt_comma: | |
618 | ',' | ; | |
619 | ||
620 | ||
621 | memory: | |
622 | MEMORY '{' memory_spec memory_spec_list '}' | |
623 | ; | |
624 | ||
625 | memory_spec_list: | |
626 | memory_spec_list memory_spec | |
627 | | memory_spec_list ',' memory_spec | |
628 | | | |
629 | ; | |
630 | ||
631 | ||
2d801b0f | 632 | memory_spec: NAME |
a747ee4d | 633 | { region = lang_memory_region_lookup ($1, TRUE); } |
252b5132 RH |
634 | attributes_opt ':' |
635 | origin_spec opt_comma length_spec | |
2d801b0f | 636 | {} |
74459f0e TW |
637 | ; |
638 | ||
639 | origin_spec: | |
252b5132 RH |
640 | ORIGIN '=' mustbe_exp |
641 | { region->current = | |
642 | region->origin = | |
643 | exp_get_vma($3, 0L,"origin", lang_first_phase_enum); | |
644 | } | |
645 | ; | |
646 | ||
647 | length_spec: | |
648 | LENGTH '=' mustbe_exp | |
649 | { region->length = exp_get_vma($3, | |
650 | ~((bfd_vma)0), | |
651 | "length", | |
652 | lang_first_phase_enum); | |
653 | } | |
aa8804e4 | 654 | ; |
252b5132 RH |
655 | |
656 | attributes_opt: | |
aa8804e4 ILT |
657 | /* empty */ |
658 | { /* dummy action to avoid bison 1.25 error message */ } | |
659 | | '(' attributes_list ')' | |
660 | ; | |
661 | ||
662 | attributes_list: | |
663 | attributes_string | |
664 | | attributes_list attributes_string | |
665 | ; | |
666 | ||
667 | attributes_string: | |
668 | NAME | |
669 | { lang_set_flags (region, $1, 0); } | |
670 | | '!' NAME | |
671 | { lang_set_flags (region, $2, 1); } | |
252b5132 RH |
672 | ; |
673 | ||
674 | startup: | |
675 | STARTUP '(' filename ')' | |
676 | { lang_startup($3); } | |
677 | ; | |
678 | ||
679 | high_level_library: | |
680 | HLL '(' high_level_library_NAME_list ')' | |
681 | | HLL '(' ')' | |
682 | { ldemul_hll((char *)NULL); } | |
683 | ; | |
684 | ||
685 | high_level_library_NAME_list: | |
686 | high_level_library_NAME_list opt_comma filename | |
687 | { ldemul_hll($3); } | |
688 | | filename | |
689 | { ldemul_hll($1); } | |
690 | ||
691 | ; | |
692 | ||
693 | low_level_library: | |
694 | SYSLIB '(' low_level_library_NAME_list ')' | |
695 | ; low_level_library_NAME_list: | |
696 | low_level_library_NAME_list opt_comma filename | |
697 | { ldemul_syslib($3); } | |
698 | | | |
699 | ; | |
700 | ||
701 | floating_point_support: | |
702 | FLOAT | |
b34976b6 | 703 | { lang_float(TRUE); } |
252b5132 | 704 | | NOFLOAT |
b34976b6 | 705 | { lang_float(FALSE); } |
252b5132 | 706 | ; |
d038301c | 707 | |
252b5132 RH |
708 | nocrossref_list: |
709 | /* empty */ | |
710 | { | |
711 | $$ = NULL; | |
712 | } | |
713 | | NAME nocrossref_list | |
714 | { | |
715 | struct lang_nocrossref *n; | |
716 | ||
717 | n = (struct lang_nocrossref *) xmalloc (sizeof *n); | |
718 | n->name = $1; | |
719 | n->next = $2; | |
720 | $$ = n; | |
721 | } | |
722 | | NAME ',' nocrossref_list | |
723 | { | |
724 | struct lang_nocrossref *n; | |
725 | ||
726 | n = (struct lang_nocrossref *) xmalloc (sizeof *n); | |
727 | n->name = $1; | |
728 | n->next = $3; | |
729 | $$ = n; | |
730 | } | |
731 | ; | |
732 | ||
733 | mustbe_exp: { ldlex_expression(); } | |
734 | exp | |
735 | { ldlex_popstate(); $$=$2;} | |
736 | ; | |
737 | ||
738 | exp : | |
739 | '-' exp %prec UNARY | |
740 | { $$ = exp_unop('-', $2); } | |
741 | | '(' exp ')' | |
742 | { $$ = $2; } | |
743 | | NEXT '(' exp ')' %prec UNARY | |
744 | { $$ = exp_unop((int) $1,$3); } | |
745 | | '!' exp %prec UNARY | |
746 | { $$ = exp_unop('!', $2); } | |
747 | | '+' exp %prec UNARY | |
748 | { $$ = $2; } | |
749 | | '~' exp %prec UNARY | |
750 | { $$ = exp_unop('~', $2);} | |
751 | ||
752 | | exp '*' exp | |
753 | { $$ = exp_binop('*', $1, $3); } | |
754 | | exp '/' exp | |
755 | { $$ = exp_binop('/', $1, $3); } | |
756 | | exp '%' exp | |
757 | { $$ = exp_binop('%', $1, $3); } | |
758 | | exp '+' exp | |
759 | { $$ = exp_binop('+', $1, $3); } | |
760 | | exp '-' exp | |
761 | { $$ = exp_binop('-' , $1, $3); } | |
762 | | exp LSHIFT exp | |
763 | { $$ = exp_binop(LSHIFT , $1, $3); } | |
764 | | exp RSHIFT exp | |
765 | { $$ = exp_binop(RSHIFT , $1, $3); } | |
766 | | exp EQ exp | |
767 | { $$ = exp_binop(EQ , $1, $3); } | |
768 | | exp NE exp | |
769 | { $$ = exp_binop(NE , $1, $3); } | |
770 | | exp LE exp | |
771 | { $$ = exp_binop(LE , $1, $3); } | |
772 | | exp GE exp | |
773 | { $$ = exp_binop(GE , $1, $3); } | |
774 | | exp '<' exp | |
775 | { $$ = exp_binop('<' , $1, $3); } | |
776 | | exp '>' exp | |
777 | { $$ = exp_binop('>' , $1, $3); } | |
778 | | exp '&' exp | |
779 | { $$ = exp_binop('&' , $1, $3); } | |
780 | | exp '^' exp | |
781 | { $$ = exp_binop('^' , $1, $3); } | |
782 | | exp '|' exp | |
783 | { $$ = exp_binop('|' , $1, $3); } | |
784 | | exp '?' exp ':' exp | |
785 | { $$ = exp_trinop('?' , $1, $3, $5); } | |
786 | | exp ANDAND exp | |
787 | { $$ = exp_binop(ANDAND , $1, $3); } | |
788 | | exp OROR exp | |
789 | { $$ = exp_binop(OROR , $1, $3); } | |
790 | | DEFINED '(' NAME ')' | |
791 | { $$ = exp_nameop(DEFINED, $3); } | |
792 | | INT | |
2c382fb6 | 793 | { $$ = exp_bigintop ($1.integer, $1.str); } |
252b5132 RH |
794 | | SIZEOF_HEADERS |
795 | { $$ = exp_nameop(SIZEOF_HEADERS,0); } | |
796 | ||
797 | | SIZEOF '(' NAME ')' | |
798 | { $$ = exp_nameop(SIZEOF,$3); } | |
799 | | ADDR '(' NAME ')' | |
800 | { $$ = exp_nameop(ADDR,$3); } | |
801 | | LOADADDR '(' NAME ')' | |
802 | { $$ = exp_nameop(LOADADDR,$3); } | |
803 | | ABSOLUTE '(' exp ')' | |
804 | { $$ = exp_unop(ABSOLUTE, $3); } | |
805 | | ALIGN_K '(' exp ')' | |
806 | { $$ = exp_unop(ALIGN_K,$3); } | |
876f4090 NS |
807 | | ALIGN_K '(' exp ',' exp ')' |
808 | { $$ = exp_binop(ALIGN_K,$3,$5); } | |
2d20f7bf JJ |
809 | | DATA_SEGMENT_ALIGN '(' exp ',' exp ')' |
810 | { $$ = exp_binop (DATA_SEGMENT_ALIGN, $3, $5); } | |
8c37241b JJ |
811 | | DATA_SEGMENT_RELRO_END '(' exp ')' |
812 | { $$ = exp_unop(DATA_SEGMENT_RELRO_END, $3); } | |
2d20f7bf JJ |
813 | | DATA_SEGMENT_END '(' exp ')' |
814 | { $$ = exp_unop(DATA_SEGMENT_END, $3); } | |
252b5132 RH |
815 | | BLOCK '(' exp ')' |
816 | { $$ = exp_unop(ALIGN_K,$3); } | |
817 | | NAME | |
818 | { $$ = exp_nameop(NAME,$1); } | |
819 | | MAX_K '(' exp ',' exp ')' | |
820 | { $$ = exp_binop (MAX_K, $3, $5 ); } | |
821 | | MIN_K '(' exp ',' exp ')' | |
822 | { $$ = exp_binop (MIN_K, $3, $5 ); } | |
823 | | ASSERT_K '(' exp ',' NAME ')' | |
824 | { $$ = exp_assert ($3, $5); } | |
825 | ; | |
826 | ||
827 | ||
562d3460 TW |
828 | memspec_at_opt: |
829 | AT '>' NAME { $$ = $3; } | |
9f88b410 | 830 | | { $$ = 0; } |
562d3460 TW |
831 | ; |
832 | ||
252b5132 RH |
833 | opt_at: |
834 | AT '(' exp ')' { $$ = $3; } | |
835 | | { $$ = 0; } | |
836 | ; | |
837 | ||
7e7d5768 AM |
838 | opt_subalign: |
839 | SUBALIGN '(' exp ')' { $$ = $3; } | |
840 | | { $$ = 0; } | |
841 | ; | |
842 | ||
0841712e JJ |
843 | sect_constraint: |
844 | ONLY_IF_RO { $$ = ONLY_IF_RO; } | |
845 | | ONLY_IF_RW { $$ = ONLY_IF_RW; } | |
846 | | { $$ = 0; } | |
847 | ; | |
848 | ||
252b5132 | 849 | section: NAME { ldlex_expression(); } |
d038301c | 850 | opt_exp_with_type |
7e7d5768 AM |
851 | opt_at |
852 | opt_subalign { ldlex_popstate (); ldlex_script (); } | |
0841712e | 853 | sect_constraint |
252b5132 RH |
854 | '{' |
855 | { | |
856 | lang_enter_output_section_statement($1, $3, | |
857 | sectype, | |
0841712e | 858 | 0, $5, $4, $7); |
252b5132 | 859 | } |
d038301c | 860 | statement_list_opt |
252b5132 | 861 | '}' { ldlex_popstate (); ldlex_expression (); } |
562d3460 | 862 | memspec_opt memspec_at_opt phdr_opt fill_opt |
252b5132 RH |
863 | { |
864 | ldlex_popstate (); | |
0841712e | 865 | lang_leave_output_section_statement ($16, $13, $15, $14); |
252b5132 RH |
866 | } |
867 | opt_comma | |
2d801b0f | 868 | {} |
252b5132 RH |
869 | | OVERLAY |
870 | { ldlex_expression (); } | |
7e7d5768 | 871 | opt_exp_without_type opt_nocrossrefs opt_at opt_subalign |
252b5132 | 872 | { ldlex_popstate (); ldlex_script (); } |
d038301c | 873 | '{' |
252b5132 | 874 | { |
7e7d5768 | 875 | lang_enter_overlay ($3, $6); |
252b5132 RH |
876 | } |
877 | overlay_section | |
878 | '}' | |
879 | { ldlex_popstate (); ldlex_expression (); } | |
562d3460 | 880 | memspec_opt memspec_at_opt phdr_opt fill_opt |
252b5132 RH |
881 | { |
882 | ldlex_popstate (); | |
9f88b410 | 883 | lang_leave_overlay ($5, (int) $4, |
7e7d5768 | 884 | $16, $13, $15, $14); |
252b5132 RH |
885 | } |
886 | opt_comma | |
887 | | /* The GROUP case is just enough to support the gcc | |
888 | svr3.ifile script. It is not intended to be full | |
889 | support. I'm not even sure what GROUP is supposed | |
890 | to mean. */ | |
891 | GROUP { ldlex_expression (); } | |
892 | opt_exp_with_type | |
893 | { | |
894 | ldlex_popstate (); | |
895 | lang_add_assignment (exp_assop ('=', ".", $3)); | |
896 | } | |
897 | '{' sec_or_group_p1 '}' | |
898 | ; | |
899 | ||
900 | type: | |
901 | NOLOAD { sectype = noload_section; } | |
902 | | DSECT { sectype = dsect_section; } | |
903 | | COPY { sectype = copy_section; } | |
904 | | INFO { sectype = info_section; } | |
905 | | OVERLAY { sectype = overlay_section; } | |
906 | ; | |
907 | ||
908 | atype: | |
909 | '(' type ')' | |
910 | | /* EMPTY */ { sectype = normal_section; } | |
911 | | '(' ')' { sectype = normal_section; } | |
912 | ; | |
913 | ||
914 | opt_exp_with_type: | |
915 | exp atype ':' { $$ = $1; } | |
916 | | atype ':' { $$ = (etree_type *)NULL; } | |
917 | | /* The BIND cases are to support the gcc svr3.ifile | |
918 | script. They aren't intended to implement full | |
919 | support for the BIND keyword. I'm not even sure | |
920 | what BIND is supposed to mean. */ | |
921 | BIND '(' exp ')' atype ':' { $$ = $3; } | |
922 | | BIND '(' exp ')' BLOCK '(' exp ')' atype ':' | |
923 | { $$ = $3; } | |
924 | ; | |
925 | ||
926 | opt_exp_without_type: | |
927 | exp ':' { $$ = $1; } | |
928 | | ':' { $$ = (etree_type *) NULL; } | |
929 | ; | |
930 | ||
931 | opt_nocrossrefs: | |
932 | /* empty */ | |
933 | { $$ = 0; } | |
934 | | NOCROSSREFS | |
935 | { $$ = 1; } | |
936 | ; | |
937 | ||
938 | memspec_opt: | |
939 | '>' NAME | |
940 | { $$ = $2; } | |
a747ee4d | 941 | | { $$ = DEFAULT_MEMORY_REGION; } |
252b5132 RH |
942 | ; |
943 | ||
944 | phdr_opt: | |
945 | /* empty */ | |
946 | { | |
947 | $$ = NULL; | |
948 | } | |
949 | | phdr_opt ':' NAME | |
950 | { | |
951 | struct lang_output_section_phdr_list *n; | |
952 | ||
953 | n = ((struct lang_output_section_phdr_list *) | |
954 | xmalloc (sizeof *n)); | |
955 | n->name = $3; | |
b34976b6 | 956 | n->used = FALSE; |
252b5132 RH |
957 | n->next = $1; |
958 | $$ = n; | |
959 | } | |
960 | ; | |
961 | ||
962 | overlay_section: | |
963 | /* empty */ | |
964 | | overlay_section | |
965 | NAME | |
966 | { | |
967 | ldlex_script (); | |
968 | lang_enter_overlay_section ($2); | |
969 | } | |
970 | '{' statement_list_opt '}' | |
971 | { ldlex_popstate (); ldlex_expression (); } | |
972 | phdr_opt fill_opt | |
973 | { | |
974 | ldlex_popstate (); | |
975 | lang_leave_overlay_section ($9, $8); | |
976 | } | |
977 | opt_comma | |
978 | ; | |
979 | ||
980 | phdrs: | |
981 | PHDRS '{' phdr_list '}' | |
982 | ; | |
983 | ||
984 | phdr_list: | |
985 | /* empty */ | |
986 | | phdr_list phdr | |
987 | ; | |
988 | ||
989 | phdr: | |
990 | NAME { ldlex_expression (); } | |
991 | phdr_type phdr_qualifiers { ldlex_popstate (); } | |
992 | ';' | |
993 | { | |
994 | lang_new_phdr ($1, $3, $4.filehdr, $4.phdrs, $4.at, | |
995 | $4.flags); | |
996 | } | |
997 | ; | |
998 | ||
999 | phdr_type: | |
1000 | exp | |
1001 | { | |
1002 | $$ = $1; | |
1003 | ||
1004 | if ($1->type.node_class == etree_name | |
1005 | && $1->type.node_code == NAME) | |
1006 | { | |
1007 | const char *s; | |
1008 | unsigned int i; | |
1009 | static const char * const phdr_types[] = | |
1010 | { | |
1011 | "PT_NULL", "PT_LOAD", "PT_DYNAMIC", | |
1012 | "PT_INTERP", "PT_NOTE", "PT_SHLIB", | |
d038301c | 1013 | "PT_PHDR", "PT_TLS" |
252b5132 RH |
1014 | }; |
1015 | ||
1016 | s = $1->name.name; | |
1017 | for (i = 0; | |
1018 | i < sizeof phdr_types / sizeof phdr_types[0]; | |
1019 | i++) | |
1020 | if (strcmp (s, phdr_types[i]) == 0) | |
1021 | { | |
1022 | $$ = exp_intop (i); | |
1023 | break; | |
1024 | } | |
d038301c RM |
1025 | if (i == sizeof phdr_types / sizeof phdr_types[0]) |
1026 | { | |
1027 | if (strcmp (s, "PT_GNU_EH_FRAME") == 0) | |
1028 | $$ = exp_intop (0x6474e550); | |
9ee5e499 JJ |
1029 | else if (strcmp (s, "PT_GNU_STACK") == 0) |
1030 | $$ = exp_intop (0x6474e551); | |
d038301c RM |
1031 | else |
1032 | { | |
1033 | einfo (_("\ | |
1034 | %X%P:%S: unknown phdr type `%s' (try integer literal)\n"), | |
1035 | s); | |
1036 | $$ = exp_intop (0); | |
1037 | } | |
1038 | } | |
252b5132 RH |
1039 | } |
1040 | } | |
1041 | ; | |
1042 | ||
1043 | phdr_qualifiers: | |
1044 | /* empty */ | |
1045 | { | |
1046 | memset (&$$, 0, sizeof (struct phdr_info)); | |
1047 | } | |
1048 | | NAME phdr_val phdr_qualifiers | |
1049 | { | |
1050 | $$ = $3; | |
1051 | if (strcmp ($1, "FILEHDR") == 0 && $2 == NULL) | |
b34976b6 | 1052 | $$.filehdr = TRUE; |
252b5132 | 1053 | else if (strcmp ($1, "PHDRS") == 0 && $2 == NULL) |
b34976b6 | 1054 | $$.phdrs = TRUE; |
252b5132 RH |
1055 | else if (strcmp ($1, "FLAGS") == 0 && $2 != NULL) |
1056 | $$.flags = $2; | |
1057 | else | |
1058 | einfo (_("%X%P:%S: PHDRS syntax error at `%s'\n"), $1); | |
1059 | } | |
1060 | | AT '(' exp ')' phdr_qualifiers | |
1061 | { | |
1062 | $$ = $5; | |
1063 | $$.at = $3; | |
1064 | } | |
1065 | ; | |
1066 | ||
1067 | phdr_val: | |
1068 | /* empty */ | |
1069 | { | |
1070 | $$ = NULL; | |
1071 | } | |
1072 | | '(' exp ')' | |
1073 | { | |
1074 | $$ = $2; | |
1075 | } | |
1076 | ; | |
1077 | ||
1078 | /* This syntax is used within an external version script file. */ | |
1079 | ||
1080 | version_script_file: | |
1081 | { | |
1082 | ldlex_version_file (); | |
1083 | PUSH_ERROR (_("VERSION script")); | |
1084 | } | |
1085 | vers_nodes | |
1086 | { | |
1087 | ldlex_popstate (); | |
1088 | POP_ERROR (); | |
1089 | } | |
1090 | ; | |
1091 | ||
1092 | /* This is used within a normal linker script file. */ | |
1093 | ||
1094 | version: | |
1095 | { | |
1096 | ldlex_version_script (); | |
1097 | } | |
1098 | VERSIONK '{' vers_nodes '}' | |
1099 | { | |
1100 | ldlex_popstate (); | |
1101 | } | |
1102 | ; | |
1103 | ||
1104 | vers_nodes: | |
1105 | vers_node | |
1106 | | vers_nodes vers_node | |
1107 | ; | |
1108 | ||
1109 | vers_node: | |
6b9b879a JJ |
1110 | '{' vers_tag '}' ';' |
1111 | { | |
1112 | lang_register_vers_node (NULL, $2, NULL); | |
1113 | } | |
1114 | | VERS_TAG '{' vers_tag '}' ';' | |
252b5132 RH |
1115 | { |
1116 | lang_register_vers_node ($1, $3, NULL); | |
1117 | } | |
1118 | | VERS_TAG '{' vers_tag '}' verdep ';' | |
1119 | { | |
1120 | lang_register_vers_node ($1, $3, $5); | |
1121 | } | |
1122 | ; | |
1123 | ||
1124 | verdep: | |
1125 | VERS_TAG | |
1126 | { | |
1127 | $$ = lang_add_vers_depend (NULL, $1); | |
1128 | } | |
1129 | | verdep VERS_TAG | |
1130 | { | |
1131 | $$ = lang_add_vers_depend ($1, $2); | |
1132 | } | |
1133 | ; | |
1134 | ||
1135 | vers_tag: | |
1136 | /* empty */ | |
1137 | { | |
1138 | $$ = lang_new_vers_node (NULL, NULL); | |
1139 | } | |
1140 | | vers_defns ';' | |
1141 | { | |
1142 | $$ = lang_new_vers_node ($1, NULL); | |
1143 | } | |
1144 | | GLOBAL ':' vers_defns ';' | |
1145 | { | |
1146 | $$ = lang_new_vers_node ($3, NULL); | |
1147 | } | |
1148 | | LOCAL ':' vers_defns ';' | |
1149 | { | |
1150 | $$ = lang_new_vers_node (NULL, $3); | |
1151 | } | |
1152 | | GLOBAL ':' vers_defns ';' LOCAL ':' vers_defns ';' | |
1153 | { | |
1154 | $$ = lang_new_vers_node ($3, $7); | |
1155 | } | |
1156 | ; | |
1157 | ||
1158 | vers_defns: | |
1159 | VERS_IDENTIFIER | |
1160 | { | |
313e35ee | 1161 | $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang); |
252b5132 RH |
1162 | } |
1163 | | vers_defns ';' VERS_IDENTIFIER | |
1164 | { | |
313e35ee | 1165 | $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang); |
252b5132 | 1166 | } |
8e23b15d AM |
1167 | | vers_defns ';' EXTERN NAME '{' |
1168 | { | |
1169 | $<name>$ = ldgram_vers_current_lang; | |
1170 | ldgram_vers_current_lang = $4; | |
1171 | } | |
1172 | vers_defns opt_semicolon '}' | |
1173 | { | |
1174 | $$ = $7; | |
1175 | ldgram_vers_current_lang = $<name>6; | |
1176 | } | |
252b5132 RH |
1177 | | EXTERN NAME '{' |
1178 | { | |
1179 | $<name>$ = ldgram_vers_current_lang; | |
1180 | ldgram_vers_current_lang = $2; | |
1181 | } | |
8e23b15d | 1182 | vers_defns opt_semicolon '}' |
252b5132 | 1183 | { |
e06cae36 | 1184 | $$ = $5; |
252b5132 RH |
1185 | ldgram_vers_current_lang = $<name>4; |
1186 | } | |
1187 | ; | |
1188 | ||
8e23b15d AM |
1189 | opt_semicolon: |
1190 | /* empty */ | |
1191 | | ';' | |
1192 | ; | |
1193 | ||
252b5132 RH |
1194 | %% |
1195 | void | |
d038301c | 1196 | yyerror(arg) |
252b5132 | 1197 | const char *arg; |
d038301c | 1198 | { |
252b5132 RH |
1199 | if (ldfile_assumed_script) |
1200 | einfo (_("%P:%s: file format not recognized; treating as linker script\n"), | |
1201 | ldfile_input_filename); | |
1202 | if (error_index > 0 && error_index < ERROR_NAME_MAX) | |
1203 | einfo ("%P%F:%S: %s in %s\n", arg, error_names[error_index-1]); | |
1204 | else | |
1205 | einfo ("%P%F:%S: %s\n", arg); | |
1206 | } |