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