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 Free Software Foundation, Inc.
|
---|
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"
|
---|
32 | #include "ld.h"
|
---|
33 | #include "ldexp.h"
|
---|
34 | #include "ldver.h"
|
---|
35 | #include "ldlang.h"
|
---|
36 | #include "ldfile.h"
|
---|
37 | #include "ldemul.h"
|
---|
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 |
|
---|
52 | bfd_boolean ldgram_want_filename = TRUE;
|
---|
53 | FILE *saved_script_handle = NULL;
|
---|
54 | bfd_boolean force_make_executable = FALSE;
|
---|
55 |
|
---|
56 | bfd_boolean ldgram_in_script = FALSE;
|
---|
57 | bfd_boolean ldgram_had_equals = FALSE;
|
---|
58 | bfd_boolean ldgram_had_keep = FALSE;
|
---|
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;
|
---|
69 | struct big_int
|
---|
70 | {
|
---|
71 | bfd_vma integer;
|
---|
72 | char *str;
|
---|
73 | } bigint;
|
---|
74 | fill_type *fill;
|
---|
75 | char *name;
|
---|
76 | const char *cname;
|
---|
77 | struct wildcard_spec wildcard;
|
---|
78 | struct wildcard_list *wildcard_list;
|
---|
79 | struct name_list *name_list;
|
---|
80 | int token;
|
---|
81 | union etree_union *etree;
|
---|
82 | struct phdr_info
|
---|
83 | {
|
---|
84 | bfd_boolean filehdr;
|
---|
85 | bfd_boolean phdrs;
|
---|
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
|
---|
97 | %type <etree> opt_exp_without_type
|
---|
98 | %type <fill> fill_opt fill_exp
|
---|
99 | %type <name_list> exclude_name_list
|
---|
100 | %type <wildcard_list> file_NAME_list
|
---|
101 | %type <name> memspec_opt casesymlist
|
---|
102 | %type <name> memspec_at_opt
|
---|
103 | %type <cname> wildcard_name
|
---|
104 | %type <wildcard> wildcard_spec
|
---|
105 | %token <bigint> INT
|
---|
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 |
|
---|
113 | %right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
|
---|
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
|
---|
128 | %token END
|
---|
129 | %left <token> '('
|
---|
130 | %token <token> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE
|
---|
131 | %token SECTIONS PHDRS SORT DATA_SEGMENT_ALIGN DATA_SEGMENT_END
|
---|
132 | %token '{' '}'
|
---|
133 | %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
|
---|
134 | %token INHIBIT_COMMON_ALLOCATION
|
---|
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
|
---|
145 | %token ALIGNMOD AT PROVIDE
|
---|
146 | %type <token> assign_op atype attributes_opt
|
---|
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
|
---|
153 | %token KEEP
|
---|
154 | %token EXCLUDE_FILE
|
---|
155 | %type <versyms> vers_defns
|
---|
156 | %type <versnode> vers_tag
|
---|
157 | %type <deflist> verdep
|
---|
158 |
|
---|
159 | %%
|
---|
160 |
|
---|
161 | file:
|
---|
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 | }
|
---|
179 | ;
|
---|
180 |
|
---|
181 | /* SYNTAX WITHIN AN MRI SCRIPT FILE */
|
---|
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:
|
---|
201 | CHIP exp
|
---|
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
|
---|
210 | | ENDWORD
|
---|
211 | | PUBLIC NAME '=' exp
|
---|
212 | { mri_public($2, $4); }
|
---|
213 | | PUBLIC NAME ',' exp
|
---|
214 | { mri_public($2, $4); }
|
---|
215 | | PUBLIC NAME exp
|
---|
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
|
---|
235 | | NAMEWORD NAME
|
---|
236 | { mri_name($2); }
|
---|
237 | | ALIAS NAME ',' NAME
|
---|
238 | { mri_alias($2,$4,0);}
|
---|
239 | | ALIAS NAME ',' INT
|
---|
240 | { mri_alias ($2, 0, (int) $4.integer); }
|
---|
241 | | BASE exp
|
---|
242 | { mri_base($2); }
|
---|
243 | | TRUNCATE INT
|
---|
244 | { mri_truncate ((unsigned int) $2.integer); }
|
---|
245 | | CASE casesymlist
|
---|
246 | | EXTERN extern_name_list
|
---|
247 | | INCLUDE filename
|
---|
248 | { ldlex_script (); ldfile_open_command_file($2); }
|
---|
249 | mri_script_lines END
|
---|
250 | { ldlex_popstate (); }
|
---|
251 | | START NAME
|
---|
252 | { lang_add_entry ($2, FALSE); }
|
---|
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 ')'
|
---|
322 | { ldfile_add_library_path ($3, FALSE); }
|
---|
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 ')'
|
---|
331 | { ldfile_set_output_arch($3); }
|
---|
332 | | FORCE_COMMON_ALLOCATION
|
---|
333 | { command_line.force_common_definition = TRUE ; }
|
---|
334 | | INHIBIT_COMMON_ALLOCATION
|
---|
335 | { command_line.inhibit_common_definition = TRUE ; }
|
---|
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); }
|
---|
343 | | INCLUDE filename
|
---|
344 | { ldlex_script (); ldfile_open_command_file($2); }
|
---|
345 | ifile_list END
|
---|
346 | { ldlex_popstate (); }
|
---|
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 ')'
|
---|
387 | { lang_add_entry ($3, FALSE); }
|
---|
388 | | assignment end
|
---|
389 | ;
|
---|
390 |
|
---|
391 | /* The '*' and '?' cases are there because the lexer returns them as
|
---|
392 | separate tokens rather than as NAME. */
|
---|
393 | wildcard_name:
|
---|
394 | NAME
|
---|
395 | {
|
---|
396 | $$ = $1;
|
---|
397 | }
|
---|
398 | | '*'
|
---|
399 | {
|
---|
400 | $$ = "*";
|
---|
401 | }
|
---|
402 | | '?'
|
---|
403 | {
|
---|
404 | $$ = "?";
|
---|
405 | }
|
---|
406 | ;
|
---|
407 |
|
---|
408 | wildcard_spec:
|
---|
409 | wildcard_name
|
---|
410 | {
|
---|
411 | $$.name = $1;
|
---|
412 | $$.sorted = FALSE;
|
---|
413 | $$.exclude_name_list = NULL;
|
---|
414 | }
|
---|
415 | | EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name
|
---|
416 | {
|
---|
417 | $$.name = $5;
|
---|
418 | $$.sorted = FALSE;
|
---|
419 | $$.exclude_name_list = $3;
|
---|
420 | }
|
---|
421 | | SORT '(' wildcard_name ')'
|
---|
422 | {
|
---|
423 | $$.name = $3;
|
---|
424 | $$.sorted = TRUE;
|
---|
425 | $$.exclude_name_list = NULL;
|
---|
426 | }
|
---|
427 | | SORT '(' EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name ')'
|
---|
428 | {
|
---|
429 | $$.name = $7;
|
---|
430 | $$.sorted = TRUE;
|
---|
431 | $$.exclude_name_list = $5;
|
---|
432 | }
|
---|
433 | ;
|
---|
434 |
|
---|
435 | exclude_name_list:
|
---|
436 | exclude_name_list wildcard_name
|
---|
437 | {
|
---|
438 | struct name_list *tmp;
|
---|
439 | tmp = (struct name_list *) xmalloc (sizeof *tmp);
|
---|
440 | tmp->name = $2;
|
---|
441 | tmp->next = $1;
|
---|
442 | $$ = tmp;
|
---|
443 | }
|
---|
444 | |
|
---|
445 | wildcard_name
|
---|
446 | {
|
---|
447 | struct name_list *tmp;
|
---|
448 | tmp = (struct name_list *) xmalloc (sizeof *tmp);
|
---|
449 | tmp->name = $1;
|
---|
450 | tmp->next = NULL;
|
---|
451 | $$ = tmp;
|
---|
452 | }
|
---|
453 | ;
|
---|
454 |
|
---|
455 | file_NAME_list:
|
---|
456 | file_NAME_list opt_comma wildcard_spec
|
---|
457 | {
|
---|
458 | struct wildcard_list *tmp;
|
---|
459 | tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
|
---|
460 | tmp->next = $1;
|
---|
461 | tmp->spec = $3;
|
---|
462 | $$ = tmp;
|
---|
463 | }
|
---|
464 | |
|
---|
465 | wildcard_spec
|
---|
466 | {
|
---|
467 | struct wildcard_list *tmp;
|
---|
468 | tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
|
---|
469 | tmp->next = NULL;
|
---|
470 | tmp->spec = $1;
|
---|
471 | $$ = tmp;
|
---|
472 | }
|
---|
473 | ;
|
---|
474 |
|
---|
475 | input_section_spec_no_keep:
|
---|
476 | NAME
|
---|
477 | {
|
---|
478 | struct wildcard_spec tmp;
|
---|
479 | tmp.name = $1;
|
---|
480 | tmp.exclude_name_list = NULL;
|
---|
481 | tmp.sorted = FALSE;
|
---|
482 | lang_add_wild (&tmp, NULL, ldgram_had_keep);
|
---|
483 | }
|
---|
484 | | '[' file_NAME_list ']'
|
---|
485 | {
|
---|
486 | lang_add_wild (NULL, $2, ldgram_had_keep);
|
---|
487 | }
|
---|
488 | | wildcard_spec '(' file_NAME_list ')'
|
---|
489 | {
|
---|
490 | lang_add_wild (&$1, $3, ldgram_had_keep);
|
---|
491 | }
|
---|
492 | ;
|
---|
493 |
|
---|
494 | input_section_spec:
|
---|
495 | input_section_spec_no_keep
|
---|
496 | | KEEP '('
|
---|
497 | { ldgram_had_keep = TRUE; }
|
---|
498 | input_section_spec_no_keep ')'
|
---|
499 | { ldgram_had_keep = FALSE; }
|
---|
500 | ;
|
---|
501 |
|
---|
502 | statement:
|
---|
503 | assignment end
|
---|
504 | | CREATE_OBJECT_SYMBOLS
|
---|
505 | {
|
---|
506 | lang_add_attribute(lang_object_symbols_statement_enum);
|
---|
507 | }
|
---|
508 | | ';'
|
---|
509 | | CONSTRUCTORS
|
---|
510 | {
|
---|
511 |
|
---|
512 | lang_add_attribute(lang_constructors_statement_enum);
|
---|
513 | }
|
---|
514 | | SORT '(' CONSTRUCTORS ')'
|
---|
515 | {
|
---|
516 | constructors_sorted = TRUE;
|
---|
517 | lang_add_attribute (lang_constructors_statement_enum);
|
---|
518 | }
|
---|
519 | | input_section_spec
|
---|
520 | | length '(' mustbe_exp ')'
|
---|
521 | {
|
---|
522 | lang_add_data ((int) $1, $3);
|
---|
523 | }
|
---|
524 |
|
---|
525 | | FILL '(' fill_exp ')'
|
---|
526 | {
|
---|
527 | lang_add_fill ($3);
|
---|
528 | }
|
---|
529 | ;
|
---|
530 |
|
---|
531 | statement_list:
|
---|
532 | statement_list statement
|
---|
533 | | statement
|
---|
534 | ;
|
---|
535 |
|
---|
536 | statement_list_opt:
|
---|
537 | /* empty */
|
---|
538 | | statement_list
|
---|
539 | ;
|
---|
540 |
|
---|
541 | length:
|
---|
542 | QUAD
|
---|
543 | { $$ = $1; }
|
---|
544 | | SQUAD
|
---|
545 | { $$ = $1; }
|
---|
546 | | LONG
|
---|
547 | { $$ = $1; }
|
---|
548 | | SHORT
|
---|
549 | { $$ = $1; }
|
---|
550 | | BYTE
|
---|
551 | { $$ = $1; }
|
---|
552 | ;
|
---|
553 |
|
---|
554 | fill_exp:
|
---|
555 | mustbe_exp
|
---|
556 | {
|
---|
557 | $$ = exp_get_fill ($1,
|
---|
558 | 0,
|
---|
559 | "fill value",
|
---|
560 | lang_first_phase_enum);
|
---|
561 | }
|
---|
562 | ;
|
---|
563 |
|
---|
564 | fill_opt:
|
---|
565 | '=' fill_exp
|
---|
566 | { $$ = $2; }
|
---|
567 | | { $$ = (fill_type *) 0; }
|
---|
568 | ;
|
---|
569 |
|
---|
570 | assign_op:
|
---|
571 | PLUSEQ
|
---|
572 | { $$ = '+'; }
|
---|
573 | | MINUSEQ
|
---|
574 | { $$ = '-'; }
|
---|
575 | | MULTEQ
|
---|
576 | { $$ = '*'; }
|
---|
577 | | DIVEQ
|
---|
578 | { $$ = '/'; }
|
---|
579 | | LSHIFTEQ
|
---|
580 | { $$ = LSHIFT; }
|
---|
581 | | RSHIFTEQ
|
---|
582 | { $$ = RSHIFT; }
|
---|
583 | | ANDEQ
|
---|
584 | { $$ = '&'; }
|
---|
585 | | OREQ
|
---|
586 | { $$ = '|'; }
|
---|
587 |
|
---|
588 | ;
|
---|
589 |
|
---|
590 | end: ';' | ','
|
---|
591 | ;
|
---|
592 |
|
---|
593 |
|
---|
594 | assignment:
|
---|
595 | NAME '=' mustbe_exp
|
---|
596 | {
|
---|
597 | lang_add_assignment (exp_assop ($2, $1, $3));
|
---|
598 | }
|
---|
599 | | NAME assign_op mustbe_exp
|
---|
600 | {
|
---|
601 | lang_add_assignment (exp_assop ('=', $1,
|
---|
602 | exp_binop ($2,
|
---|
603 | exp_nameop (NAME,
|
---|
604 | $1),
|
---|
605 | $3)));
|
---|
606 | }
|
---|
607 | | PROVIDE '(' NAME '=' mustbe_exp ')'
|
---|
608 | {
|
---|
609 | lang_add_assignment (exp_provide ($3, $5));
|
---|
610 | }
|
---|
611 | ;
|
---|
612 |
|
---|
613 |
|
---|
614 | opt_comma:
|
---|
615 | ',' | ;
|
---|
616 |
|
---|
617 |
|
---|
618 | memory:
|
---|
619 | MEMORY '{' memory_spec memory_spec_list '}'
|
---|
620 | ;
|
---|
621 |
|
---|
622 | memory_spec_list:
|
---|
623 | memory_spec_list memory_spec
|
---|
624 | | memory_spec_list ',' memory_spec
|
---|
625 | |
|
---|
626 | ;
|
---|
627 |
|
---|
628 |
|
---|
629 | memory_spec: NAME
|
---|
630 | { region = lang_memory_region_lookup($1); }
|
---|
631 | attributes_opt ':'
|
---|
632 | origin_spec opt_comma length_spec
|
---|
633 | {}
|
---|
634 | ;
|
---|
635 |
|
---|
636 | origin_spec:
|
---|
637 | ORIGIN '=' mustbe_exp
|
---|
638 | { region->current =
|
---|
639 | region->origin =
|
---|
640 | exp_get_vma($3, 0L,"origin", lang_first_phase_enum);
|
---|
641 | }
|
---|
642 | ;
|
---|
643 |
|
---|
644 | length_spec:
|
---|
645 | LENGTH '=' mustbe_exp
|
---|
646 | { region->length = exp_get_vma($3,
|
---|
647 | ~((bfd_vma)0),
|
---|
648 | "length",
|
---|
649 | lang_first_phase_enum);
|
---|
650 | }
|
---|
651 | ;
|
---|
652 |
|
---|
653 | attributes_opt:
|
---|
654 | /* empty */
|
---|
655 | { /* dummy action to avoid bison 1.25 error message */ }
|
---|
656 | | '(' attributes_list ')'
|
---|
657 | ;
|
---|
658 |
|
---|
659 | attributes_list:
|
---|
660 | attributes_string
|
---|
661 | | attributes_list attributes_string
|
---|
662 | ;
|
---|
663 |
|
---|
664 | attributes_string:
|
---|
665 | NAME
|
---|
666 | { lang_set_flags (region, $1, 0); }
|
---|
667 | | '!' NAME
|
---|
668 | { lang_set_flags (region, $2, 1); }
|
---|
669 | ;
|
---|
670 |
|
---|
671 | startup:
|
---|
672 | STARTUP '(' filename ')'
|
---|
673 | { lang_startup($3); }
|
---|
674 | ;
|
---|
675 |
|
---|
676 | high_level_library:
|
---|
677 | HLL '(' high_level_library_NAME_list ')'
|
---|
678 | | HLL '(' ')'
|
---|
679 | { ldemul_hll((char *)NULL); }
|
---|
680 | ;
|
---|
681 |
|
---|
682 | high_level_library_NAME_list:
|
---|
683 | high_level_library_NAME_list opt_comma filename
|
---|
684 | { ldemul_hll($3); }
|
---|
685 | | filename
|
---|
686 | { ldemul_hll($1); }
|
---|
687 |
|
---|
688 | ;
|
---|
689 |
|
---|
690 | low_level_library:
|
---|
691 | SYSLIB '(' low_level_library_NAME_list ')'
|
---|
692 | ; low_level_library_NAME_list:
|
---|
693 | low_level_library_NAME_list opt_comma filename
|
---|
694 | { ldemul_syslib($3); }
|
---|
695 | |
|
---|
696 | ;
|
---|
697 |
|
---|
698 | floating_point_support:
|
---|
699 | FLOAT
|
---|
700 | { lang_float(TRUE); }
|
---|
701 | | NOFLOAT
|
---|
702 | { lang_float(FALSE); }
|
---|
703 | ;
|
---|
704 |
|
---|
705 | nocrossref_list:
|
---|
706 | /* empty */
|
---|
707 | {
|
---|
708 | $$ = NULL;
|
---|
709 | }
|
---|
710 | | NAME nocrossref_list
|
---|
711 | {
|
---|
712 | struct lang_nocrossref *n;
|
---|
713 |
|
---|
714 | n = (struct lang_nocrossref *) xmalloc (sizeof *n);
|
---|
715 | n->name = $1;
|
---|
716 | n->next = $2;
|
---|
717 | $$ = n;
|
---|
718 | }
|
---|
719 | | NAME ',' nocrossref_list
|
---|
720 | {
|
---|
721 | struct lang_nocrossref *n;
|
---|
722 |
|
---|
723 | n = (struct lang_nocrossref *) xmalloc (sizeof *n);
|
---|
724 | n->name = $1;
|
---|
725 | n->next = $3;
|
---|
726 | $$ = n;
|
---|
727 | }
|
---|
728 | ;
|
---|
729 |
|
---|
730 | mustbe_exp: { ldlex_expression(); }
|
---|
731 | exp
|
---|
732 | { ldlex_popstate(); $$=$2;}
|
---|
733 | ;
|
---|
734 |
|
---|
735 | exp :
|
---|
736 | '-' exp %prec UNARY
|
---|
737 | { $$ = exp_unop('-', $2); }
|
---|
738 | | '(' exp ')'
|
---|
739 | { $$ = $2; }
|
---|
740 | | NEXT '(' exp ')' %prec UNARY
|
---|
741 | { $$ = exp_unop((int) $1,$3); }
|
---|
742 | | '!' exp %prec UNARY
|
---|
743 | { $$ = exp_unop('!', $2); }
|
---|
744 | | '+' exp %prec UNARY
|
---|
745 | { $$ = $2; }
|
---|
746 | | '~' exp %prec UNARY
|
---|
747 | { $$ = exp_unop('~', $2);}
|
---|
748 |
|
---|
749 | | exp '*' exp
|
---|
750 | { $$ = exp_binop('*', $1, $3); }
|
---|
751 | | exp '/' exp
|
---|
752 | { $$ = exp_binop('/', $1, $3); }
|
---|
753 | | exp '%' exp
|
---|
754 | { $$ = exp_binop('%', $1, $3); }
|
---|
755 | | exp '+' exp
|
---|
756 | { $$ = exp_binop('+', $1, $3); }
|
---|
757 | | exp '-' exp
|
---|
758 | { $$ = exp_binop('-' , $1, $3); }
|
---|
759 | | exp LSHIFT exp
|
---|
760 | { $$ = exp_binop(LSHIFT , $1, $3); }
|
---|
761 | | exp RSHIFT exp
|
---|
762 | { $$ = exp_binop(RSHIFT , $1, $3); }
|
---|
763 | | exp EQ exp
|
---|
764 | { $$ = exp_binop(EQ , $1, $3); }
|
---|
765 | | exp NE exp
|
---|
766 | { $$ = exp_binop(NE , $1, $3); }
|
---|
767 | | exp LE exp
|
---|
768 | { $$ = exp_binop(LE , $1, $3); }
|
---|
769 | | exp GE exp
|
---|
770 | { $$ = exp_binop(GE , $1, $3); }
|
---|
771 | | exp '<' exp
|
---|
772 | { $$ = exp_binop('<' , $1, $3); }
|
---|
773 | | exp '>' exp
|
---|
774 | { $$ = exp_binop('>' , $1, $3); }
|
---|
775 | | exp '&' exp
|
---|
776 | { $$ = exp_binop('&' , $1, $3); }
|
---|
777 | | exp '^' exp
|
---|
778 | { $$ = exp_binop('^' , $1, $3); }
|
---|
779 | | exp '|' exp
|
---|
780 | { $$ = exp_binop('|' , $1, $3); }
|
---|
781 | | exp '?' exp ':' exp
|
---|
782 | { $$ = exp_trinop('?' , $1, $3, $5); }
|
---|
783 | | exp ANDAND exp
|
---|
784 | { $$ = exp_binop(ANDAND , $1, $3); }
|
---|
785 | | exp OROR exp
|
---|
786 | { $$ = exp_binop(OROR , $1, $3); }
|
---|
787 | | DEFINED '(' NAME ')'
|
---|
788 | { $$ = exp_nameop(DEFINED, $3); }
|
---|
789 | | INT
|
---|
790 | { $$ = exp_bigintop ($1.integer, $1.str); }
|
---|
791 | | SIZEOF_HEADERS
|
---|
792 | { $$ = exp_nameop(SIZEOF_HEADERS,0); }
|
---|
793 |
|
---|
794 | | SIZEOF '(' NAME ')'
|
---|
795 | { $$ = exp_nameop(SIZEOF,$3); }
|
---|
796 | | ADDR '(' NAME ')'
|
---|
797 | { $$ = exp_nameop(ADDR,$3); }
|
---|
798 | | LOADADDR '(' NAME ')'
|
---|
799 | { $$ = exp_nameop(LOADADDR,$3); }
|
---|
800 | | ABSOLUTE '(' exp ')'
|
---|
801 | { $$ = exp_unop(ABSOLUTE, $3); }
|
---|
802 | | ALIGN_K '(' exp ')'
|
---|
803 | { $$ = exp_unop(ALIGN_K,$3); }
|
---|
804 | | DATA_SEGMENT_ALIGN '(' exp ',' exp ')'
|
---|
805 | { $$ = exp_binop (DATA_SEGMENT_ALIGN, $3, $5); }
|
---|
806 | | DATA_SEGMENT_END '(' exp ')'
|
---|
807 | { $$ = exp_unop(DATA_SEGMENT_END, $3); }
|
---|
808 | | BLOCK '(' exp ')'
|
---|
809 | { $$ = exp_unop(ALIGN_K,$3); }
|
---|
810 | | NAME
|
---|
811 | { $$ = exp_nameop(NAME,$1); }
|
---|
812 | | MAX_K '(' exp ',' exp ')'
|
---|
813 | { $$ = exp_binop (MAX_K, $3, $5 ); }
|
---|
814 | | MIN_K '(' exp ',' exp ')'
|
---|
815 | { $$ = exp_binop (MIN_K, $3, $5 ); }
|
---|
816 | | ASSERT_K '(' exp ',' NAME ')'
|
---|
817 | { $$ = exp_assert ($3, $5); }
|
---|
818 | ;
|
---|
819 |
|
---|
820 |
|
---|
821 | memspec_at_opt:
|
---|
822 | AT '>' NAME { $$ = $3; }
|
---|
823 | | { $$ = 0; }
|
---|
824 | ;
|
---|
825 |
|
---|
826 | opt_at:
|
---|
827 | AT '(' exp ')' { $$ = $3; }
|
---|
828 | | { $$ = 0; }
|
---|
829 | ;
|
---|
830 |
|
---|
831 | section: NAME { ldlex_expression(); }
|
---|
832 | opt_exp_with_type
|
---|
833 | opt_at { ldlex_popstate (); ldlex_script (); }
|
---|
834 | '{'
|
---|
835 | {
|
---|
836 | lang_enter_output_section_statement($1, $3,
|
---|
837 | sectype,
|
---|
838 | 0, 0, 0, $4);
|
---|
839 | }
|
---|
840 | statement_list_opt
|
---|
841 | '}' { ldlex_popstate (); ldlex_expression (); }
|
---|
842 | memspec_opt memspec_at_opt phdr_opt fill_opt
|
---|
843 | {
|
---|
844 | ldlex_popstate ();
|
---|
845 | lang_leave_output_section_statement ($14, $11, $13, $12);
|
---|
846 | }
|
---|
847 | opt_comma
|
---|
848 | {}
|
---|
849 | | OVERLAY
|
---|
850 | { ldlex_expression (); }
|
---|
851 | opt_exp_without_type opt_nocrossrefs opt_at
|
---|
852 | { ldlex_popstate (); ldlex_script (); }
|
---|
853 | '{'
|
---|
854 | {
|
---|
855 | lang_enter_overlay ($3);
|
---|
856 | }
|
---|
857 | overlay_section
|
---|
858 | '}'
|
---|
859 | { ldlex_popstate (); ldlex_expression (); }
|
---|
860 | memspec_opt memspec_at_opt phdr_opt fill_opt
|
---|
861 | {
|
---|
862 | ldlex_popstate ();
|
---|
863 | lang_leave_overlay ($5, (int) $4,
|
---|
864 | $15, $12, $14, $13);
|
---|
865 | }
|
---|
866 | opt_comma
|
---|
867 | | /* The GROUP case is just enough to support the gcc
|
---|
868 | svr3.ifile script. It is not intended to be full
|
---|
869 | support. I'm not even sure what GROUP is supposed
|
---|
870 | to mean. */
|
---|
871 | GROUP { ldlex_expression (); }
|
---|
872 | opt_exp_with_type
|
---|
873 | {
|
---|
874 | ldlex_popstate ();
|
---|
875 | lang_add_assignment (exp_assop ('=', ".", $3));
|
---|
876 | }
|
---|
877 | '{' sec_or_group_p1 '}'
|
---|
878 | ;
|
---|
879 |
|
---|
880 | type:
|
---|
881 | NOLOAD { sectype = noload_section; }
|
---|
882 | | DSECT { sectype = dsect_section; }
|
---|
883 | | COPY { sectype = copy_section; }
|
---|
884 | | INFO { sectype = info_section; }
|
---|
885 | | OVERLAY { sectype = overlay_section; }
|
---|
886 | ;
|
---|
887 |
|
---|
888 | atype:
|
---|
889 | '(' type ')'
|
---|
890 | | /* EMPTY */ { sectype = normal_section; }
|
---|
891 | | '(' ')' { sectype = normal_section; }
|
---|
892 | ;
|
---|
893 |
|
---|
894 | opt_exp_with_type:
|
---|
895 | exp atype ':' { $$ = $1; }
|
---|
896 | | atype ':' { $$ = (etree_type *)NULL; }
|
---|
897 | | /* The BIND cases are to support the gcc svr3.ifile
|
---|
898 | script. They aren't intended to implement full
|
---|
899 | support for the BIND keyword. I'm not even sure
|
---|
900 | what BIND is supposed to mean. */
|
---|
901 | BIND '(' exp ')' atype ':' { $$ = $3; }
|
---|
902 | | BIND '(' exp ')' BLOCK '(' exp ')' atype ':'
|
---|
903 | { $$ = $3; }
|
---|
904 | ;
|
---|
905 |
|
---|
906 | opt_exp_without_type:
|
---|
907 | exp ':' { $$ = $1; }
|
---|
908 | | ':' { $$ = (etree_type *) NULL; }
|
---|
909 | ;
|
---|
910 |
|
---|
911 | opt_nocrossrefs:
|
---|
912 | /* empty */
|
---|
913 | { $$ = 0; }
|
---|
914 | | NOCROSSREFS
|
---|
915 | { $$ = 1; }
|
---|
916 | ;
|
---|
917 |
|
---|
918 | memspec_opt:
|
---|
919 | '>' NAME
|
---|
920 | { $$ = $2; }
|
---|
921 | | { $$ = "*default*"; }
|
---|
922 | ;
|
---|
923 |
|
---|
924 | phdr_opt:
|
---|
925 | /* empty */
|
---|
926 | {
|
---|
927 | $$ = NULL;
|
---|
928 | }
|
---|
929 | | phdr_opt ':' NAME
|
---|
930 | {
|
---|
931 | struct lang_output_section_phdr_list *n;
|
---|
932 |
|
---|
933 | n = ((struct lang_output_section_phdr_list *)
|
---|
934 | xmalloc (sizeof *n));
|
---|
935 | n->name = $3;
|
---|
936 | n->used = FALSE;
|
---|
937 | n->next = $1;
|
---|
938 | $$ = n;
|
---|
939 | }
|
---|
940 | ;
|
---|
941 |
|
---|
942 | overlay_section:
|
---|
943 | /* empty */
|
---|
944 | | overlay_section
|
---|
945 | NAME
|
---|
946 | {
|
---|
947 | ldlex_script ();
|
---|
948 | lang_enter_overlay_section ($2);
|
---|
949 | }
|
---|
950 | '{' statement_list_opt '}'
|
---|
951 | { ldlex_popstate (); ldlex_expression (); }
|
---|
952 | phdr_opt fill_opt
|
---|
953 | {
|
---|
954 | ldlex_popstate ();
|
---|
955 | lang_leave_overlay_section ($9, $8);
|
---|
956 | }
|
---|
957 | opt_comma
|
---|
958 | ;
|
---|
959 |
|
---|
960 | phdrs:
|
---|
961 | PHDRS '{' phdr_list '}'
|
---|
962 | ;
|
---|
963 |
|
---|
964 | phdr_list:
|
---|
965 | /* empty */
|
---|
966 | | phdr_list phdr
|
---|
967 | ;
|
---|
968 |
|
---|
969 | phdr:
|
---|
970 | NAME { ldlex_expression (); }
|
---|
971 | phdr_type phdr_qualifiers { ldlex_popstate (); }
|
---|
972 | ';'
|
---|
973 | {
|
---|
974 | lang_new_phdr ($1, $3, $4.filehdr, $4.phdrs, $4.at,
|
---|
975 | $4.flags);
|
---|
976 | }
|
---|
977 | ;
|
---|
978 |
|
---|
979 | phdr_type:
|
---|
980 | exp
|
---|
981 | {
|
---|
982 | $$ = $1;
|
---|
983 |
|
---|
984 | if ($1->type.node_class == etree_name
|
---|
985 | && $1->type.node_code == NAME)
|
---|
986 | {
|
---|
987 | const char *s;
|
---|
988 | unsigned int i;
|
---|
989 | static const char * const phdr_types[] =
|
---|
990 | {
|
---|
991 | "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
|
---|
992 | "PT_INTERP", "PT_NOTE", "PT_SHLIB",
|
---|
993 | "PT_PHDR", "PT_TLS"
|
---|
994 | };
|
---|
995 |
|
---|
996 | s = $1->name.name;
|
---|
997 | for (i = 0;
|
---|
998 | i < sizeof phdr_types / sizeof phdr_types[0];
|
---|
999 | i++)
|
---|
1000 | if (strcmp (s, phdr_types[i]) == 0)
|
---|
1001 | {
|
---|
1002 | $$ = exp_intop (i);
|
---|
1003 | break;
|
---|
1004 | }
|
---|
1005 | if (i == sizeof phdr_types / sizeof phdr_types[0])
|
---|
1006 | {
|
---|
1007 | if (strcmp (s, "PT_GNU_EH_FRAME") == 0)
|
---|
1008 | $$ = exp_intop (0x6474e550);
|
---|
1009 | else
|
---|
1010 | {
|
---|
1011 | einfo (_("\
|
---|
1012 | %X%P:%S: unknown phdr type `%s' (try integer literal)\n"),
|
---|
1013 | s);
|
---|
1014 | $$ = exp_intop (0);
|
---|
1015 | }
|
---|
1016 | }
|
---|
1017 | }
|
---|
1018 | }
|
---|
1019 | ;
|
---|
1020 |
|
---|
1021 | phdr_qualifiers:
|
---|
1022 | /* empty */
|
---|
1023 | {
|
---|
1024 | memset (&$$, 0, sizeof (struct phdr_info));
|
---|
1025 | }
|
---|
1026 | | NAME phdr_val phdr_qualifiers
|
---|
1027 | {
|
---|
1028 | $$ = $3;
|
---|
1029 | if (strcmp ($1, "FILEHDR") == 0 && $2 == NULL)
|
---|
1030 | $$.filehdr = TRUE;
|
---|
1031 | else if (strcmp ($1, "PHDRS") == 0 && $2 == NULL)
|
---|
1032 | $$.phdrs = TRUE;
|
---|
1033 | else if (strcmp ($1, "FLAGS") == 0 && $2 != NULL)
|
---|
1034 | $$.flags = $2;
|
---|
1035 | else
|
---|
1036 | einfo (_("%X%P:%S: PHDRS syntax error at `%s'\n"), $1);
|
---|
1037 | }
|
---|
1038 | | AT '(' exp ')' phdr_qualifiers
|
---|
1039 | {
|
---|
1040 | $$ = $5;
|
---|
1041 | $$.at = $3;
|
---|
1042 | }
|
---|
1043 | ;
|
---|
1044 |
|
---|
1045 | phdr_val:
|
---|
1046 | /* empty */
|
---|
1047 | {
|
---|
1048 | $$ = NULL;
|
---|
1049 | }
|
---|
1050 | | '(' exp ')'
|
---|
1051 | {
|
---|
1052 | $$ = $2;
|
---|
1053 | }
|
---|
1054 | ;
|
---|
1055 |
|
---|
1056 | /* This syntax is used within an external version script file. */
|
---|
1057 |
|
---|
1058 | version_script_file:
|
---|
1059 | {
|
---|
1060 | ldlex_version_file ();
|
---|
1061 | PUSH_ERROR (_("VERSION script"));
|
---|
1062 | }
|
---|
1063 | vers_nodes
|
---|
1064 | {
|
---|
1065 | ldlex_popstate ();
|
---|
1066 | POP_ERROR ();
|
---|
1067 | }
|
---|
1068 | ;
|
---|
1069 |
|
---|
1070 | /* This is used within a normal linker script file. */
|
---|
1071 |
|
---|
1072 | version:
|
---|
1073 | {
|
---|
1074 | ldlex_version_script ();
|
---|
1075 | }
|
---|
1076 | VERSIONK '{' vers_nodes '}'
|
---|
1077 | {
|
---|
1078 | ldlex_popstate ();
|
---|
1079 | }
|
---|
1080 | ;
|
---|
1081 |
|
---|
1082 | vers_nodes:
|
---|
1083 | vers_node
|
---|
1084 | | vers_nodes vers_node
|
---|
1085 | ;
|
---|
1086 |
|
---|
1087 | vers_node:
|
---|
1088 | '{' vers_tag '}' ';'
|
---|
1089 | {
|
---|
1090 | lang_register_vers_node (NULL, $2, NULL);
|
---|
1091 | }
|
---|
1092 | | VERS_TAG '{' vers_tag '}' ';'
|
---|
1093 | {
|
---|
1094 | lang_register_vers_node ($1, $3, NULL);
|
---|
1095 | }
|
---|
1096 | | VERS_TAG '{' vers_tag '}' verdep ';'
|
---|
1097 | {
|
---|
1098 | lang_register_vers_node ($1, $3, $5);
|
---|
1099 | }
|
---|
1100 | ;
|
---|
1101 |
|
---|
1102 | verdep:
|
---|
1103 | VERS_TAG
|
---|
1104 | {
|
---|
1105 | $$ = lang_add_vers_depend (NULL, $1);
|
---|
1106 | }
|
---|
1107 | | verdep VERS_TAG
|
---|
1108 | {
|
---|
1109 | $$ = lang_add_vers_depend ($1, $2);
|
---|
1110 | }
|
---|
1111 | ;
|
---|
1112 |
|
---|
1113 | vers_tag:
|
---|
1114 | /* empty */
|
---|
1115 | {
|
---|
1116 | $$ = lang_new_vers_node (NULL, NULL);
|
---|
1117 | }
|
---|
1118 | | vers_defns ';'
|
---|
1119 | {
|
---|
1120 | $$ = lang_new_vers_node ($1, NULL);
|
---|
1121 | }
|
---|
1122 | | GLOBAL ':' vers_defns ';'
|
---|
1123 | {
|
---|
1124 | $$ = lang_new_vers_node ($3, NULL);
|
---|
1125 | }
|
---|
1126 | | LOCAL ':' vers_defns ';'
|
---|
1127 | {
|
---|
1128 | $$ = lang_new_vers_node (NULL, $3);
|
---|
1129 | }
|
---|
1130 | | GLOBAL ':' vers_defns ';' LOCAL ':' vers_defns ';'
|
---|
1131 | {
|
---|
1132 | $$ = lang_new_vers_node ($3, $7);
|
---|
1133 | }
|
---|
1134 | ;
|
---|
1135 |
|
---|
1136 | vers_defns:
|
---|
1137 | VERS_IDENTIFIER
|
---|
1138 | {
|
---|
1139 | $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang);
|
---|
1140 | }
|
---|
1141 | | vers_defns ';' VERS_IDENTIFIER
|
---|
1142 | {
|
---|
1143 | $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang);
|
---|
1144 | }
|
---|
1145 | | vers_defns ';' EXTERN NAME '{'
|
---|
1146 | {
|
---|
1147 | $<name>$ = ldgram_vers_current_lang;
|
---|
1148 | ldgram_vers_current_lang = $4;
|
---|
1149 | }
|
---|
1150 | vers_defns opt_semicolon '}'
|
---|
1151 | {
|
---|
1152 | $$ = $7;
|
---|
1153 | ldgram_vers_current_lang = $<name>6;
|
---|
1154 | }
|
---|
1155 | | EXTERN NAME '{'
|
---|
1156 | {
|
---|
1157 | $<name>$ = ldgram_vers_current_lang;
|
---|
1158 | ldgram_vers_current_lang = $2;
|
---|
1159 | }
|
---|
1160 | vers_defns opt_semicolon '}'
|
---|
1161 | {
|
---|
1162 | $$ = $5;
|
---|
1163 | ldgram_vers_current_lang = $<name>4;
|
---|
1164 | }
|
---|
1165 | ;
|
---|
1166 |
|
---|
1167 | opt_semicolon:
|
---|
1168 | /* empty */
|
---|
1169 | | ';'
|
---|
1170 | ;
|
---|
1171 |
|
---|
1172 | %%
|
---|
1173 | void
|
---|
1174 | yyerror(arg)
|
---|
1175 | const char *arg;
|
---|
1176 | {
|
---|
1177 | if (ldfile_assumed_script)
|
---|
1178 | einfo (_("%P:%s: file format not recognized; treating as linker script\n"),
|
---|
1179 | ldfile_input_filename);
|
---|
1180 | if (error_index > 0 && error_index < ERROR_NAME_MAX)
|
---|
1181 | einfo ("%P%F:%S: %s in %s\n", arg, error_names[error_index-1]);
|
---|
1182 | else
|
---|
1183 | einfo ("%P%F:%S: %s\n", arg);
|
---|
1184 | }
|
---|