OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [ld/] [ldgram.y] - Blame information for rev 248

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 khays
/* 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 166 khays
   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 145 khays
   Free Software Foundation, Inc.
5
   Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
6
 
7
   This file is part of the GNU Binutils.
8
 
9
   This program is free software; you can redistribute it and/or modify
10
   it under the terms of the GNU General Public License as published by
11
   the Free Software Foundation; either version 3 of the License, or
12
   (at your option) any later version.
13
 
14
   This program is distributed in the hope that it will be useful,
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
   GNU General Public License for more details.
18
 
19
   You should have received a copy of the GNU General Public License
20
   along with this program; if not, write to the Free Software
21
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22
   MA 02110-1301, USA.  */
23
 
24
%{
25
/*
26
 
27
 */
28
 
29
#define DONTDECLARE_MALLOC
30
 
31
#include "sysdep.h"
32
#include "bfd.h"
33
#include "bfdlink.h"
34
#include "ld.h"
35
#include "ldexp.h"
36
#include "ldver.h"
37
#include "ldlang.h"
38
#include "ldfile.h"
39
#include "ldemul.h"
40
#include "ldmisc.h"
41
#include "ldmain.h"
42
#include "mri.h"
43
#include "ldctor.h"
44
#include "ldlex.h"
45
 
46
#ifndef YYDEBUG
47
#define YYDEBUG 1
48
#endif
49
 
50
static enum section_type sectype;
51
static lang_memory_region_type *region;
52
 
53
bfd_boolean ldgram_had_keep = FALSE;
54
char *ldgram_vers_current_lang = NULL;
55
 
56
#define ERROR_NAME_MAX 20
57
static char *error_names[ERROR_NAME_MAX];
58
static int error_index;
59
#define PUSH_ERROR(x) if (error_index < ERROR_NAME_MAX) error_names[error_index] = x; error_index++;
60
#define POP_ERROR()   error_index--;
61
%}
62
%union {
63
  bfd_vma integer;
64
  struct big_int
65
    {
66
      bfd_vma integer;
67
      char *str;
68
    } bigint;
69
  fill_type *fill;
70
  char *name;
71
  const char *cname;
72
  struct wildcard_spec wildcard;
73
  struct wildcard_list *wildcard_list;
74
  struct name_list *name_list;
75 157 khays
  struct flag_info_list *flag_info_list;
76
  struct flag_info *flag_info;
77 145 khays
  int token;
78
  union etree_union *etree;
79
  struct phdr_info
80
    {
81
      bfd_boolean filehdr;
82
      bfd_boolean phdrs;
83
      union etree_union *at;
84
      union etree_union *flags;
85
    } phdr;
86
  struct lang_nocrossref *nocrossref;
87
  struct lang_output_section_phdr_list *section_phdr;
88
  struct bfd_elf_version_deps *deflist;
89
  struct bfd_elf_version_expr *versyms;
90
  struct bfd_elf_version_tree *versnode;
91
}
92
 
93
%type  exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val
94
%type  opt_exp_without_type opt_subalign opt_align
95
%type  fill_opt fill_exp
96
%type  exclude_name_list
97
%type  file_NAME_list
98 157 khays
%type  sect_flag_list
99
%type  sect_flags
100 145 khays
%type  memspec_opt casesymlist
101
%type  memspec_at_opt
102
%type  wildcard_name
103
%type  wildcard_spec
104
%token  INT
105
%token  NAME LNAME
106
%type  length
107
%type  phdr_qualifiers
108
%type  nocrossref_list
109
%type  phdr_opt
110
%type  opt_nocrossrefs
111
 
112
%right  PLUSEQ MINUSEQ MULTEQ DIVEQ  '=' LSHIFTEQ RSHIFTEQ   ANDEQ OREQ
113
%right  '?' ':'
114
%left  OROR
115
%left   ANDAND
116
%left  '|'
117
%left   '^'
118
%left   '&'
119
%left   EQ NE
120
%left   '<' '>' LE GE
121
%left   LSHIFT RSHIFT
122
 
123
%left   '+' '-'
124
%left   '*' '/' '%'
125
 
126
%right UNARY
127
%token END
128
%left  '('
129
%token  ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE
130
%token SECTIONS PHDRS INSERT_K AFTER BEFORE
131
%token DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END
132
%token SORT_BY_NAME SORT_BY_ALIGNMENT
133
%token SORT_BY_INIT_PRIORITY
134
%token '{' '}'
135
%token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
136
%token INHIBIT_COMMON_ALLOCATION
137
%token SEGMENT_START
138
%token INCLUDE
139
%token MEMORY
140
%token REGION_ALIAS
141
%token LD_FEATURE
142
%token NOLOAD DSECT COPY INFO OVERLAY
143
%token DEFINED TARGET_K SEARCH_DIR MAP ENTRY
144
%token  NEXT
145
%token SIZEOF ALIGNOF ADDR LOADADDR MAX_K MIN_K
146
%token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS
147
%token ORIGIN FILL
148
%token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS
149
%token ALIGNMOD AT SUBALIGN PROVIDE PROVIDE_HIDDEN AS_NEEDED
150
%type  assign_op atype attributes_opt sect_constraint
151
%type   filename
152
%token CHIP LIST SECT ABSOLUTE  LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K
153
%token FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL
154
%token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START
155
%token  VERS_TAG VERS_IDENTIFIER
156
%token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT
157 157 khays
%token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL INPUT_SECTION_FLAGS
158 145 khays
%token EXCLUDE_FILE
159
%token CONSTANT
160
%type  vers_defns
161
%type  vers_tag
162
%type  verdep
163
%token INPUT_DYNAMIC_LIST
164
 
165
%%
166
 
167
file:
168
                INPUT_SCRIPT script_file
169
        |       INPUT_MRI_SCRIPT mri_script_file
170
        |       INPUT_VERSION_SCRIPT version_script_file
171
        |       INPUT_DYNAMIC_LIST dynamic_list_file
172
        |       INPUT_DEFSYM defsym_expr
173
        ;
174
 
175
 
176
filename:  NAME;
177
 
178
 
179
defsym_expr:
180
                { ldlex_defsym(); }
181
                NAME '=' exp
182
                {
183
                  ldlex_popstate();
184
                  lang_add_assignment (exp_defsym ($2, $4));
185
                }
186
        ;
187
 
188
/* SYNTAX WITHIN AN MRI SCRIPT FILE */
189
mri_script_file:
190
                {
191
                  ldlex_mri_script ();
192
                  PUSH_ERROR (_("MRI style script"));
193
                }
194
             mri_script_lines
195
                {
196
                  ldlex_popstate ();
197
                  mri_draw_tree ();
198
                  POP_ERROR ();
199
                }
200
        ;
201
 
202
mri_script_lines:
203
                mri_script_lines mri_script_command NEWLINE
204
          |
205
        ;
206
 
207
mri_script_command:
208
                CHIP  exp
209
        |       CHIP  exp ',' exp
210
        |       NAME    {
211
                        einfo(_("%P%F: unrecognised keyword in MRI style script '%s'\n"),$1);
212
                        }
213
        |       LIST    {
214
                        config.map_filename = "-";
215
                        }
216
        |       ORDER ordernamelist
217
        |       ENDWORD
218
        |       PUBLIC NAME '=' exp
219
                        { mri_public($2, $4); }
220
        |       PUBLIC NAME ',' exp
221
                        { mri_public($2, $4); }
222
        |       PUBLIC NAME  exp
223
                        { mri_public($2, $3); }
224
        |       FORMAT NAME
225
                        { mri_format($2); }
226
        |       SECT NAME ',' exp
227
                        { mri_output_section($2, $4);}
228
        |       SECT NAME  exp
229
                        { mri_output_section($2, $3);}
230
        |       SECT NAME '=' exp
231
                        { mri_output_section($2, $4);}
232
        |       ALIGN_K NAME '=' exp
233
                        { mri_align($2,$4); }
234
        |       ALIGN_K NAME ',' exp
235
                        { mri_align($2,$4); }
236
        |       ALIGNMOD NAME '=' exp
237
                        { mri_alignmod($2,$4); }
238
        |       ALIGNMOD NAME ',' exp
239
                        { mri_alignmod($2,$4); }
240
        |       ABSOLUTE mri_abs_name_list
241
        |       LOAD     mri_load_name_list
242
        |       NAMEWORD NAME
243
                        { mri_name($2); }
244
        |       ALIAS NAME ',' NAME
245
                        { mri_alias($2,$4,0);}
246
        |       ALIAS NAME ',' INT
247
                        { mri_alias ($2, 0, (int) $4.integer); }
248
        |       BASE     exp
249
                        { mri_base($2); }
250
        |       TRUNCATE INT
251
                { mri_truncate ((unsigned int) $2.integer); }
252
        |       CASE casesymlist
253
        |       EXTERN extern_name_list
254
        |       INCLUDE filename
255
                { ldlex_script (); ldfile_open_command_file($2); }
256
                mri_script_lines END
257
                { ldlex_popstate (); }
258
        |       START NAME
259
                { lang_add_entry ($2, FALSE); }
260
        |
261
        ;
262
 
263
ordernamelist:
264
              ordernamelist ',' NAME         { mri_order($3); }
265
        |     ordernamelist  NAME         { mri_order($2); }
266
        |
267
        ;
268
 
269
mri_load_name_list:
270
                NAME
271
                        { mri_load($1); }
272
        |       mri_load_name_list ',' NAME { mri_load($3); }
273
        ;
274
 
275
mri_abs_name_list:
276
                NAME
277
                        { mri_only_load($1); }
278
        |       mri_abs_name_list ','  NAME
279
                        { mri_only_load($3); }
280
        ;
281
 
282
casesymlist:
283
          /* empty */ { $$ = NULL; }
284
        | NAME
285
        | casesymlist ',' NAME
286
        ;
287
 
288
/* Parsed as expressions so that commas separate entries */
289
extern_name_list:
290
        { ldlex_expression (); }
291
        extern_name_list_body
292
        { ldlex_popstate (); }
293
 
294
extern_name_list_body:
295
          NAME
296
                        { ldlang_add_undef ($1, FALSE); }
297
        | extern_name_list_body NAME
298
                        { ldlang_add_undef ($2, FALSE); }
299
        | extern_name_list_body ',' NAME
300
                        { ldlang_add_undef ($3, FALSE); }
301
        ;
302
 
303
script_file:
304
        { ldlex_both(); }
305
        ifile_list
306
        { ldlex_popstate(); }
307
        ;
308
 
309
ifile_list:
310
        ifile_list ifile_p1
311
        |
312
        ;
313
 
314
 
315
ifile_p1:
316
                memory
317
        |       sections
318
        |       phdrs
319
        |       startup
320
        |       high_level_library
321
        |       low_level_library
322
        |       floating_point_support
323
        |       statement_anywhere
324
        |       version
325
        |        ';'
326
        |       TARGET_K '(' NAME ')'
327
                { lang_add_target($3); }
328
        |       SEARCH_DIR '(' filename ')'
329
                { ldfile_add_library_path ($3, FALSE); }
330
        |       OUTPUT '(' filename ')'
331
                { lang_add_output($3, 1); }
332
        |       OUTPUT_FORMAT '(' NAME ')'
333
                  { lang_add_output_format ($3, (char *) NULL,
334
                                            (char *) NULL, 1); }
335
        |       OUTPUT_FORMAT '(' NAME ',' NAME ',' NAME ')'
336
                  { lang_add_output_format ($3, $5, $7, 1); }
337
        |       OUTPUT_ARCH '(' NAME ')'
338
                  { ldfile_set_output_arch ($3, bfd_arch_unknown); }
339
        |       FORCE_COMMON_ALLOCATION
340
                { command_line.force_common_definition = TRUE ; }
341
        |       INHIBIT_COMMON_ALLOCATION
342
                { command_line.inhibit_common_definition = TRUE ; }
343
        |       INPUT '(' input_list ')'
344
        |       GROUP
345
                  { lang_enter_group (); }
346
                    '(' input_list ')'
347
                  { lang_leave_group (); }
348
        |       MAP '(' filename ')'
349
                { lang_add_map($3); }
350
        |       INCLUDE filename
351
                { ldlex_script (); ldfile_open_command_file($2); }
352
                ifile_list END
353
                { ldlex_popstate (); }
354
        |       NOCROSSREFS '(' nocrossref_list ')'
355
                {
356
                  lang_add_nocrossref ($3);
357
                }
358
        |       EXTERN '(' extern_name_list ')'
359
        |       INSERT_K AFTER NAME
360
                { lang_add_insert ($3, 0); }
361
        |       INSERT_K BEFORE NAME
362
                { lang_add_insert ($3, 1); }
363
        |       REGION_ALIAS '(' NAME ',' NAME ')'
364
                { lang_memory_region_alias ($3, $5); }
365
        |       LD_FEATURE '(' NAME ')'
366
                { lang_ld_feature ($3); }
367
        ;
368
 
369
input_list:
370
                NAME
371
                { lang_add_input_file($1,lang_input_file_is_search_file_enum,
372
                                 (char *)NULL); }
373
        |       input_list ',' NAME
374
                { lang_add_input_file($3,lang_input_file_is_search_file_enum,
375
                                 (char *)NULL); }
376
        |       input_list NAME
377
                { lang_add_input_file($2,lang_input_file_is_search_file_enum,
378
                                 (char *)NULL); }
379
        |       LNAME
380
                { lang_add_input_file($1,lang_input_file_is_l_enum,
381
                                 (char *)NULL); }
382
        |       input_list ',' LNAME
383
                { lang_add_input_file($3,lang_input_file_is_l_enum,
384
                                 (char *)NULL); }
385
        |       input_list LNAME
386
                { lang_add_input_file($2,lang_input_file_is_l_enum,
387
                                 (char *)NULL); }
388
        |       AS_NEEDED '('
389
                  { $$ = add_DT_NEEDED_for_regular; add_DT_NEEDED_for_regular = TRUE; }
390
                     input_list ')'
391
                  { add_DT_NEEDED_for_regular = $3; }
392
        |       input_list ',' AS_NEEDED '('
393
                  { $$ = add_DT_NEEDED_for_regular; add_DT_NEEDED_for_regular = TRUE; }
394
                     input_list ')'
395
                  { add_DT_NEEDED_for_regular = $5; }
396
        |       input_list AS_NEEDED '('
397
                  { $$ = add_DT_NEEDED_for_regular; add_DT_NEEDED_for_regular = TRUE; }
398
                     input_list ')'
399
                  { add_DT_NEEDED_for_regular = $4; }
400
        ;
401
 
402
sections:
403
                SECTIONS '{' sec_or_group_p1 '}'
404
        ;
405
 
406
sec_or_group_p1:
407
                sec_or_group_p1 section
408
        |       sec_or_group_p1 statement_anywhere
409
        |
410
        ;
411
 
412
statement_anywhere:
413
                ENTRY '(' NAME ')'
414
                { lang_add_entry ($3, FALSE); }
415
        |       assignment end
416
        |       ASSERT_K  {ldlex_expression ();} '(' exp ',' NAME ')'
417
                { ldlex_popstate ();
418
                  lang_add_assignment (exp_assert ($4, $6)); }
419
        ;
420
 
421
/* The '*' and '?' cases are there because the lexer returns them as
422
   separate tokens rather than as NAME.  */
423
wildcard_name:
424
                NAME
425
                        {
426
                          $$ = $1;
427
                        }
428
        |       '*'
429
                        {
430
                          $$ = "*";
431
                        }
432
        |       '?'
433
                        {
434
                          $$ = "?";
435
                        }
436
        ;
437
 
438
wildcard_spec:
439
                wildcard_name
440
                        {
441
                          $$.name = $1;
442
                          $$.sorted = none;
443
                          $$.exclude_name_list = NULL;
444 157 khays
                          $$.section_flag_list = NULL;
445 145 khays
                        }
446
        |       EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name
447
                        {
448
                          $$.name = $5;
449
                          $$.sorted = none;
450
                          $$.exclude_name_list = $3;
451 157 khays
                          $$.section_flag_list = NULL;
452 145 khays
                        }
453
        |       SORT_BY_NAME '(' wildcard_name ')'
454
                        {
455
                          $$.name = $3;
456
                          $$.sorted = by_name;
457
                          $$.exclude_name_list = NULL;
458 157 khays
                          $$.section_flag_list = NULL;
459 145 khays
                        }
460
        |       SORT_BY_ALIGNMENT '(' wildcard_name ')'
461
                        {
462
                          $$.name = $3;
463
                          $$.sorted = by_alignment;
464
                          $$.exclude_name_list = NULL;
465 157 khays
                          $$.section_flag_list = NULL;
466 145 khays
                        }
467
        |       SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')'
468
                        {
469
                          $$.name = $5;
470
                          $$.sorted = by_name_alignment;
471
                          $$.exclude_name_list = NULL;
472 157 khays
                          $$.section_flag_list = NULL;
473 145 khays
                        }
474
        |       SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_name ')' ')'
475
                        {
476
                          $$.name = $5;
477
                          $$.sorted = by_name;
478
                          $$.exclude_name_list = NULL;
479 157 khays
                          $$.section_flag_list = NULL;
480 145 khays
                        }
481
        |       SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_name ')' ')'
482
                        {
483
                          $$.name = $5;
484
                          $$.sorted = by_alignment_name;
485
                          $$.exclude_name_list = NULL;
486 157 khays
                          $$.section_flag_list = NULL;
487 145 khays
                        }
488
        |       SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')'
489
                        {
490
                          $$.name = $5;
491
                          $$.sorted = by_alignment;
492
                          $$.exclude_name_list = NULL;
493 157 khays
                          $$.section_flag_list = NULL;
494 145 khays
                        }
495
        |       SORT_BY_NAME '(' EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name ')'
496
                        {
497
                          $$.name = $7;
498
                          $$.sorted = by_name;
499
                          $$.exclude_name_list = $5;
500 157 khays
                          $$.section_flag_list = NULL;
501 145 khays
                        }
502
        |       SORT_BY_INIT_PRIORITY '(' wildcard_name ')'
503
                        {
504
                          $$.name = $3;
505
                          $$.sorted = by_init_priority;
506
                          $$.exclude_name_list = NULL;
507 157 khays
                          $$.section_flag_list = NULL;
508 145 khays
                        }
509
        ;
510
 
511 157 khays
sect_flag_list: NAME
512
                        {
513
                          struct flag_info_list *n;
514
                          n = ((struct flag_info_list *) xmalloc (sizeof *n));
515
                          if ($1[0] == '!')
516
                            {
517
                              n->with = without_flags;
518
                              n->name = &$1[1];
519
                            }
520
                          else
521
                            {
522
                              n->with = with_flags;
523
                              n->name = $1;
524
                            }
525
                          n->valid = FALSE;
526
                          n->next = NULL;
527
                          $$ = n;
528
                        }
529
        |       sect_flag_list '&' NAME
530
                        {
531
                          struct flag_info_list *n;
532
                          n = ((struct flag_info_list *) xmalloc (sizeof *n));
533
                          if ($3[0] == '!')
534
                            {
535
                              n->with = without_flags;
536
                              n->name = &$3[1];
537
                            }
538
                          else
539
                            {
540
                              n->with = with_flags;
541
                              n->name = $3;
542
                            }
543
                          n->valid = FALSE;
544
                          n->next = $1;
545
                          $$ = n;
546
                        }
547
        ;
548
 
549
sect_flags:
550
                INPUT_SECTION_FLAGS '(' sect_flag_list ')'
551
                        {
552
                          struct flag_info *n;
553
                          n = ((struct flag_info *) xmalloc (sizeof *n));
554
                          n->flag_list = $3;
555
                          n->flags_initialized = FALSE;
556
                          n->not_with_flags = 0;
557
                          n->only_with_flags = 0;
558
                          $$ = n;
559
                        }
560
        ;
561
 
562 145 khays
exclude_name_list:
563
                exclude_name_list wildcard_name
564
                        {
565
                          struct name_list *tmp;
566
                          tmp = (struct name_list *) xmalloc (sizeof *tmp);
567
                          tmp->name = $2;
568
                          tmp->next = $1;
569
                          $$ = tmp;
570
                        }
571
        |
572
                wildcard_name
573
                        {
574
                          struct name_list *tmp;
575
                          tmp = (struct name_list *) xmalloc (sizeof *tmp);
576
                          tmp->name = $1;
577
                          tmp->next = NULL;
578
                          $$ = tmp;
579
                        }
580
        ;
581
 
582
file_NAME_list:
583
                file_NAME_list opt_comma wildcard_spec
584
                        {
585
                          struct wildcard_list *tmp;
586
                          tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
587
                          tmp->next = $1;
588
                          tmp->spec = $3;
589
                          $$ = tmp;
590
                        }
591
        |
592
                wildcard_spec
593
                        {
594
                          struct wildcard_list *tmp;
595
                          tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
596
                          tmp->next = NULL;
597
                          tmp->spec = $1;
598
                          $$ = tmp;
599
                        }
600
        ;
601
 
602
input_section_spec_no_keep:
603
                NAME
604
                        {
605
                          struct wildcard_spec tmp;
606
                          tmp.name = $1;
607
                          tmp.exclude_name_list = NULL;
608
                          tmp.sorted = none;
609 157 khays
                          tmp.section_flag_list = NULL;
610 145 khays
                          lang_add_wild (&tmp, NULL, ldgram_had_keep);
611
                        }
612 157 khays
        |       sect_flags NAME
613
                        {
614
                          struct wildcard_spec tmp;
615
                          tmp.name = $2;
616
                          tmp.exclude_name_list = NULL;
617
                          tmp.sorted = none;
618
                          tmp.section_flag_list = $1;
619
                          lang_add_wild (&tmp, NULL, ldgram_had_keep);
620
                        }
621 145 khays
        |       '[' file_NAME_list ']'
622
                        {
623
                          lang_add_wild (NULL, $2, ldgram_had_keep);
624
                        }
625 157 khays
        |       sect_flags '[' file_NAME_list ']'
626
                        {
627
                          struct wildcard_spec tmp;
628
                          tmp.name = NULL;
629
                          tmp.exclude_name_list = NULL;
630
                          tmp.sorted = none;
631
                          tmp.section_flag_list = $1;
632 166 khays
                          lang_add_wild (&tmp, $3, ldgram_had_keep);
633 157 khays
                        }
634 145 khays
        |       wildcard_spec '(' file_NAME_list ')'
635
                        {
636
                          lang_add_wild (&$1, $3, ldgram_had_keep);
637
                        }
638 157 khays
        |       sect_flags wildcard_spec '(' file_NAME_list ')'
639
                        {
640
                          $2.section_flag_list = $1;
641
                          lang_add_wild (&$2, $4, ldgram_had_keep);
642
                        }
643 145 khays
        ;
644
 
645
input_section_spec:
646
                input_section_spec_no_keep
647
        |       KEEP '('
648
                        { ldgram_had_keep = TRUE; }
649
                input_section_spec_no_keep ')'
650
                        { ldgram_had_keep = FALSE; }
651
        ;
652
 
653
statement:
654
                assignment end
655
        |       CREATE_OBJECT_SYMBOLS
656
                {
657
                lang_add_attribute(lang_object_symbols_statement_enum);
658
                }
659
        |       ';'
660
        |       CONSTRUCTORS
661
                {
662
 
663
                  lang_add_attribute(lang_constructors_statement_enum);
664
                }
665
        | SORT_BY_NAME '(' CONSTRUCTORS ')'
666
                {
667
                  constructors_sorted = TRUE;
668
                  lang_add_attribute (lang_constructors_statement_enum);
669
                }
670
        | input_section_spec
671
        | length '(' mustbe_exp ')'
672
                        {
673
                          lang_add_data ((int) $1, $3);
674
                        }
675
 
676
        | FILL '(' fill_exp ')'
677
                        {
678
                          lang_add_fill ($3);
679
                        }
680
        | ASSERT_K  {ldlex_expression ();} '(' exp ',' NAME ')' end
681
                        { ldlex_popstate ();
682
                          lang_add_assignment (exp_assert ($4, $6)); }
683
        | INCLUDE filename
684
                { ldlex_script (); ldfile_open_command_file($2); }
685
                statement_list_opt END
686
                { ldlex_popstate (); }
687
        ;
688
 
689
statement_list:
690
                statement_list statement
691
        |       statement
692
        ;
693
 
694
statement_list_opt:
695
                /* empty */
696
        |       statement_list
697
        ;
698
 
699
length:
700
                QUAD
701
                        { $$ = $1; }
702
        |       SQUAD
703
                        { $$ = $1; }
704
        |       LONG
705
                        { $$ = $1; }
706
        |       SHORT
707
                        { $$ = $1; }
708
        |       BYTE
709
                        { $$ = $1; }
710
        ;
711
 
712
fill_exp:
713
        mustbe_exp
714
                {
715
                  $$ = exp_get_fill ($1, 0, "fill value");
716
                }
717
        ;
718
 
719
fill_opt:
720
          '=' fill_exp
721
                { $$ = $2; }
722
        |       { $$ = (fill_type *) 0; }
723
        ;
724
 
725
assign_op:
726
                PLUSEQ
727
                        { $$ = '+'; }
728
        |       MINUSEQ
729
                        { $$ = '-'; }
730
        |       MULTEQ
731
                        { $$ = '*'; }
732
        |       DIVEQ
733
                        { $$ = '/'; }
734
        |       LSHIFTEQ
735
                        { $$ = LSHIFT; }
736
        |       RSHIFTEQ
737
                        { $$ = RSHIFT; }
738
        |       ANDEQ
739
                        { $$ = '&'; }
740
        |       OREQ
741
                        { $$ = '|'; }
742
 
743
        ;
744
 
745
end:    ';' | ','
746
        ;
747
 
748
 
749
assignment:
750
                NAME '=' mustbe_exp
751
                {
752
                  lang_add_assignment (exp_assign ($1, $3));
753
                }
754
        |       NAME assign_op mustbe_exp
755
                {
756
                  lang_add_assignment (exp_assign ($1,
757
                                                   exp_binop ($2,
758
                                                              exp_nameop (NAME,
759
                                                                          $1),
760
                                                              $3)));
761
                }
762
        |       PROVIDE '(' NAME '=' mustbe_exp ')'
763
                {
764
                  lang_add_assignment (exp_provide ($3, $5, FALSE));
765
                }
766
        |       PROVIDE_HIDDEN '(' NAME '=' mustbe_exp ')'
767
                {
768
                  lang_add_assignment (exp_provide ($3, $5, TRUE));
769
                }
770
        ;
771
 
772
 
773
opt_comma:
774
                ','     |       ;
775
 
776
 
777
memory:
778
                MEMORY '{' memory_spec_list_opt '}'
779
        ;
780
 
781
memory_spec_list_opt: memory_spec_list | ;
782
 
783
memory_spec_list:
784
                memory_spec_list opt_comma memory_spec
785
        |       memory_spec
786
        ;
787
 
788
 
789
memory_spec:    NAME
790
                { region = lang_memory_region_lookup ($1, TRUE); }
791
                attributes_opt ':'
792
                origin_spec opt_comma length_spec
793
                {}
794
        |       INCLUDE filename
795
                { ldlex_script (); ldfile_open_command_file($2); }
796
                memory_spec_list_opt END
797
                { ldlex_popstate (); }
798
        ;
799
 
800
origin_spec:
801
        ORIGIN '=' mustbe_exp
802
                {
803
                  region->origin = exp_get_vma ($3, 0, "origin");
804
                  region->current = region->origin;
805
                }
806
        ;
807
 
808
length_spec:
809
             LENGTH '=' mustbe_exp
810
                {
811
                  region->length = exp_get_vma ($3, -1, "length");
812
                }
813
        ;
814
 
815
attributes_opt:
816
                /* empty */
817
                  { /* dummy action to avoid bison 1.25 error message */ }
818
        |       '(' attributes_list ')'
819
        ;
820
 
821
attributes_list:
822
                attributes_string
823
        |       attributes_list attributes_string
824
        ;
825
 
826
attributes_string:
827
                NAME
828
                  { lang_set_flags (region, $1, 0); }
829
        |       '!' NAME
830
                  { lang_set_flags (region, $2, 1); }
831
        ;
832
 
833
startup:
834
        STARTUP '(' filename ')'
835
                { lang_startup($3); }
836
        ;
837
 
838
high_level_library:
839
                HLL '(' high_level_library_NAME_list ')'
840
        |       HLL '(' ')'
841
                        { ldemul_hll((char *)NULL); }
842
        ;
843
 
844
high_level_library_NAME_list:
845
                high_level_library_NAME_list opt_comma filename
846
                        { ldemul_hll($3); }
847
        |       filename
848
                        { ldemul_hll($1); }
849
 
850
        ;
851
 
852
low_level_library:
853
        SYSLIB '(' low_level_library_NAME_list ')'
854
        ; low_level_library_NAME_list:
855
                low_level_library_NAME_list opt_comma filename
856
                        { ldemul_syslib($3); }
857
        |
858
        ;
859
 
860
floating_point_support:
861
                FLOAT
862
                        { lang_float(TRUE); }
863
        |       NOFLOAT
864
                        { lang_float(FALSE); }
865
        ;
866
 
867
nocrossref_list:
868
                /* empty */
869
                {
870
                  $$ = NULL;
871
                }
872
        |       NAME nocrossref_list
873
                {
874
                  struct lang_nocrossref *n;
875
 
876
                  n = (struct lang_nocrossref *) xmalloc (sizeof *n);
877
                  n->name = $1;
878
                  n->next = $2;
879
                  $$ = n;
880
                }
881
        |       NAME ',' nocrossref_list
882
                {
883
                  struct lang_nocrossref *n;
884
 
885
                  n = (struct lang_nocrossref *) xmalloc (sizeof *n);
886
                  n->name = $1;
887
                  n->next = $3;
888
                  $$ = n;
889
                }
890
        ;
891
 
892
mustbe_exp:              { ldlex_expression (); }
893
                exp
894
                         { ldlex_popstate (); $$=$2;}
895
        ;
896
 
897
exp     :
898
                '-' exp %prec UNARY
899
                        { $$ = exp_unop ('-', $2); }
900
        |       '(' exp ')'
901
                        { $$ = $2; }
902
        |       NEXT '(' exp ')' %prec UNARY
903
                        { $$ = exp_unop ((int) $1,$3); }
904
        |       '!' exp %prec UNARY
905
                        { $$ = exp_unop ('!', $2); }
906
        |       '+' exp %prec UNARY
907
                        { $$ = $2; }
908
        |       '~' exp %prec UNARY
909
                        { $$ = exp_unop ('~', $2);}
910
 
911
        |       exp '*' exp
912
                        { $$ = exp_binop ('*', $1, $3); }
913
        |       exp '/' exp
914
                        { $$ = exp_binop ('/', $1, $3); }
915
        |       exp '%' exp
916
                        { $$ = exp_binop ('%', $1, $3); }
917
        |       exp '+' exp
918
                        { $$ = exp_binop ('+', $1, $3); }
919
        |       exp '-' exp
920
                        { $$ = exp_binop ('-' , $1, $3); }
921
        |       exp LSHIFT exp
922
                        { $$ = exp_binop (LSHIFT , $1, $3); }
923
        |       exp RSHIFT exp
924
                        { $$ = exp_binop (RSHIFT , $1, $3); }
925
        |       exp EQ exp
926
                        { $$ = exp_binop (EQ , $1, $3); }
927
        |       exp NE exp
928
                        { $$ = exp_binop (NE , $1, $3); }
929
        |       exp LE exp
930
                        { $$ = exp_binop (LE , $1, $3); }
931
        |       exp GE exp
932
                        { $$ = exp_binop (GE , $1, $3); }
933
        |       exp '<' exp
934
                        { $$ = exp_binop ('<' , $1, $3); }
935
        |       exp '>' exp
936
                        { $$ = exp_binop ('>' , $1, $3); }
937
        |       exp '&' exp
938
                        { $$ = exp_binop ('&' , $1, $3); }
939
        |       exp '^' exp
940
                        { $$ = exp_binop ('^' , $1, $3); }
941
        |       exp '|' exp
942
                        { $$ = exp_binop ('|' , $1, $3); }
943
        |       exp '?' exp ':' exp
944
                        { $$ = exp_trinop ('?' , $1, $3, $5); }
945
        |       exp ANDAND exp
946
                        { $$ = exp_binop (ANDAND , $1, $3); }
947
        |       exp OROR exp
948
                        { $$ = exp_binop (OROR , $1, $3); }
949
        |       DEFINED '(' NAME ')'
950
                        { $$ = exp_nameop (DEFINED, $3); }
951
        |       INT
952
                        { $$ = exp_bigintop ($1.integer, $1.str); }
953
        |       SIZEOF_HEADERS
954
                        { $$ = exp_nameop (SIZEOF_HEADERS,0); }
955
 
956
        |       ALIGNOF '(' NAME ')'
957
                        { $$ = exp_nameop (ALIGNOF,$3); }
958
        |       SIZEOF '(' NAME ')'
959
                        { $$ = exp_nameop (SIZEOF,$3); }
960
        |       ADDR '(' NAME ')'
961
                        { $$ = exp_nameop (ADDR,$3); }
962
        |       LOADADDR '(' NAME ')'
963
                        { $$ = exp_nameop (LOADADDR,$3); }
964
        |       CONSTANT '(' NAME ')'
965
                        { $$ = exp_nameop (CONSTANT,$3); }
966
        |       ABSOLUTE '(' exp ')'
967
                        { $$ = exp_unop (ABSOLUTE, $3); }
968
        |       ALIGN_K '(' exp ')'
969
                        { $$ = exp_unop (ALIGN_K,$3); }
970
        |       ALIGN_K '(' exp ',' exp ')'
971
                        { $$ = exp_binop (ALIGN_K,$3,$5); }
972
        |       DATA_SEGMENT_ALIGN '(' exp ',' exp ')'
973
                        { $$ = exp_binop (DATA_SEGMENT_ALIGN, $3, $5); }
974
        |       DATA_SEGMENT_RELRO_END '(' exp ',' exp ')'
975
                        { $$ = exp_binop (DATA_SEGMENT_RELRO_END, $5, $3); }
976
        |       DATA_SEGMENT_END '(' exp ')'
977
                        { $$ = exp_unop (DATA_SEGMENT_END, $3); }
978
        |       SEGMENT_START '(' NAME ',' exp ')'
979
                        { /* The operands to the expression node are
980
                             placed in the opposite order from the way
981
                             in which they appear in the script as
982
                             that allows us to reuse more code in
983
                             fold_binary.  */
984
                          $$ = exp_binop (SEGMENT_START,
985
                                          $5,
986
                                          exp_nameop (NAME, $3)); }
987
        |       BLOCK '(' exp ')'
988
                        { $$ = exp_unop (ALIGN_K,$3); }
989
        |       NAME
990
                        { $$ = exp_nameop (NAME,$1); }
991
        |       MAX_K '(' exp ',' exp ')'
992
                        { $$ = exp_binop (MAX_K, $3, $5 ); }
993
        |       MIN_K '(' exp ',' exp ')'
994
                        { $$ = exp_binop (MIN_K, $3, $5 ); }
995
        |       ASSERT_K '(' exp ',' NAME ')'
996
                        { $$ = exp_assert ($3, $5); }
997
        |       ORIGIN '(' NAME ')'
998
                        { $$ = exp_nameop (ORIGIN, $3); }
999
        |       LENGTH '(' NAME ')'
1000
                        { $$ = exp_nameop (LENGTH, $3); }
1001
        ;
1002
 
1003
 
1004
memspec_at_opt:
1005
                AT '>' NAME { $$ = $3; }
1006
        |       { $$ = 0; }
1007
        ;
1008
 
1009
opt_at:
1010
                AT '(' exp ')' { $$ = $3; }
1011
        |       { $$ = 0; }
1012
        ;
1013
 
1014
opt_align:
1015
                ALIGN_K '(' exp ')' { $$ = $3; }
1016
        |       { $$ = 0; }
1017
        ;
1018
 
1019
opt_subalign:
1020
                SUBALIGN '(' exp ')' { $$ = $3; }
1021
        |       { $$ = 0; }
1022
        ;
1023
 
1024
sect_constraint:
1025
                ONLY_IF_RO { $$ = ONLY_IF_RO; }
1026
        |       ONLY_IF_RW { $$ = ONLY_IF_RW; }
1027
        |       SPECIAL { $$ = SPECIAL; }
1028
        |       { $$ = 0; }
1029
        ;
1030
 
1031
section:        NAME            { ldlex_expression(); }
1032
                opt_exp_with_type
1033
                opt_at
1034
                opt_align
1035
                opt_subalign    { ldlex_popstate (); ldlex_script (); }
1036
                sect_constraint
1037
                '{'
1038
                        {
1039
                          lang_enter_output_section_statement($1, $3,
1040
                                                              sectype,
1041
                                                              $5, $6, $4, $8);
1042
                        }
1043
                statement_list_opt
1044
                '}' { ldlex_popstate (); ldlex_expression (); }
1045
                memspec_opt memspec_at_opt phdr_opt fill_opt
1046
                {
1047
                  ldlex_popstate ();
1048
                  lang_leave_output_section_statement ($17, $14, $16, $15);
1049
                }
1050
                opt_comma
1051
                {}
1052
        |       OVERLAY
1053
                        { ldlex_expression (); }
1054
                opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
1055
                        { ldlex_popstate (); ldlex_script (); }
1056
                '{'
1057
                        {
1058
                          lang_enter_overlay ($3, $6);
1059
                        }
1060
                overlay_section
1061
                '}'
1062
                        { ldlex_popstate (); ldlex_expression (); }
1063
                memspec_opt memspec_at_opt phdr_opt fill_opt
1064
                        {
1065
                          ldlex_popstate ();
1066
                          lang_leave_overlay ($5, (int) $4,
1067
                                              $16, $13, $15, $14);
1068
                        }
1069
                opt_comma
1070
        |       /* The GROUP case is just enough to support the gcc
1071
                   svr3.ifile script.  It is not intended to be full
1072
                   support.  I'm not even sure what GROUP is supposed
1073
                   to mean.  */
1074
                GROUP { ldlex_expression (); }
1075
                opt_exp_with_type
1076
                {
1077
                  ldlex_popstate ();
1078
                  lang_add_assignment (exp_assign (".", $3));
1079
                }
1080
                '{' sec_or_group_p1 '}'
1081
        |       INCLUDE filename
1082
                { ldlex_script (); ldfile_open_command_file($2); }
1083
                sec_or_group_p1 END
1084
                { ldlex_popstate (); }
1085
        ;
1086
 
1087
type:
1088
           NOLOAD  { sectype = noload_section; }
1089
        |  DSECT   { sectype = noalloc_section; }
1090
        |  COPY    { sectype = noalloc_section; }
1091
        |  INFO    { sectype = noalloc_section; }
1092
        |  OVERLAY { sectype = noalloc_section; }
1093
        ;
1094
 
1095
atype:
1096
                '(' type ')'
1097
        |       /* EMPTY */ { sectype = normal_section; }
1098
        |       '(' ')' { sectype = normal_section; }
1099
        ;
1100
 
1101
opt_exp_with_type:
1102
                exp atype ':'           { $$ = $1; }
1103
        |       atype ':'               { $$ = (etree_type *)NULL;  }
1104
        |       /* The BIND cases are to support the gcc svr3.ifile
1105
                   script.  They aren't intended to implement full
1106
                   support for the BIND keyword.  I'm not even sure
1107
                   what BIND is supposed to mean.  */
1108
                BIND '(' exp ')' atype ':' { $$ = $3; }
1109
        |       BIND '(' exp ')' BLOCK '(' exp ')' atype ':'
1110
                { $$ = $3; }
1111
        ;
1112
 
1113
opt_exp_without_type:
1114
                exp ':'         { $$ = $1; }
1115
        |       ':'             { $$ = (etree_type *) NULL;  }
1116
        ;
1117
 
1118
opt_nocrossrefs:
1119
                /* empty */
1120
                        { $$ = 0; }
1121
        |       NOCROSSREFS
1122
                        { $$ = 1; }
1123
        ;
1124
 
1125
memspec_opt:
1126
                '>' NAME
1127
                { $$ = $2; }
1128
        |       { $$ = DEFAULT_MEMORY_REGION; }
1129
        ;
1130
 
1131
phdr_opt:
1132
                /* empty */
1133
                {
1134
                  $$ = NULL;
1135
                }
1136
        |       phdr_opt ':' NAME
1137
                {
1138
                  struct lang_output_section_phdr_list *n;
1139
 
1140
                  n = ((struct lang_output_section_phdr_list *)
1141
                       xmalloc (sizeof *n));
1142
                  n->name = $3;
1143
                  n->used = FALSE;
1144
                  n->next = $1;
1145
                  $$ = n;
1146
                }
1147
        ;
1148
 
1149
overlay_section:
1150
                /* empty */
1151
        |       overlay_section
1152
                NAME
1153
                        {
1154
                          ldlex_script ();
1155
                          lang_enter_overlay_section ($2);
1156
                        }
1157
                '{' statement_list_opt '}'
1158
                        { ldlex_popstate (); ldlex_expression (); }
1159
                phdr_opt fill_opt
1160
                        {
1161
                          ldlex_popstate ();
1162
                          lang_leave_overlay_section ($9, $8);
1163
                        }
1164
                opt_comma
1165
        ;
1166
 
1167
phdrs:
1168
                PHDRS '{' phdr_list '}'
1169
        ;
1170
 
1171
phdr_list:
1172
                /* empty */
1173
        |       phdr_list phdr
1174
        ;
1175
 
1176
phdr:
1177
                NAME { ldlex_expression (); }
1178
                  phdr_type phdr_qualifiers { ldlex_popstate (); }
1179
                  ';'
1180
                {
1181
                  lang_new_phdr ($1, $3, $4.filehdr, $4.phdrs, $4.at,
1182
                                 $4.flags);
1183
                }
1184
        ;
1185
 
1186
phdr_type:
1187
                exp
1188
                {
1189
                  $$ = $1;
1190
 
1191
                  if ($1->type.node_class == etree_name
1192
                      && $1->type.node_code == NAME)
1193
                    {
1194
                      const char *s;
1195
                      unsigned int i;
1196
                      static const char * const phdr_types[] =
1197
                        {
1198
                          "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
1199
                          "PT_INTERP", "PT_NOTE", "PT_SHLIB",
1200
                          "PT_PHDR", "PT_TLS"
1201
                        };
1202
 
1203
                      s = $1->name.name;
1204
                      for (i = 0;
1205
                           i < sizeof phdr_types / sizeof phdr_types[0];
1206
                           i++)
1207
                        if (strcmp (s, phdr_types[i]) == 0)
1208
                          {
1209
                            $$ = exp_intop (i);
1210
                            break;
1211
                          }
1212
                      if (i == sizeof phdr_types / sizeof phdr_types[0])
1213
                        {
1214
                          if (strcmp (s, "PT_GNU_EH_FRAME") == 0)
1215
                            $$ = exp_intop (0x6474e550);
1216
                          else if (strcmp (s, "PT_GNU_STACK") == 0)
1217
                            $$ = exp_intop (0x6474e551);
1218
                          else
1219
                            {
1220
                              einfo (_("\
1221
%X%P:%S: unknown phdr type `%s' (try integer literal)\n"),
1222 166 khays
                                     NULL, s);
1223 145 khays
                              $$ = exp_intop (0);
1224
                            }
1225
                        }
1226
                    }
1227
                }
1228
        ;
1229
 
1230
phdr_qualifiers:
1231
                /* empty */
1232
                {
1233
                  memset (&$$, 0, sizeof (struct phdr_info));
1234
                }
1235
        |       NAME phdr_val phdr_qualifiers
1236
                {
1237
                  $$ = $3;
1238
                  if (strcmp ($1, "FILEHDR") == 0 && $2 == NULL)
1239
                    $$.filehdr = TRUE;
1240
                  else if (strcmp ($1, "PHDRS") == 0 && $2 == NULL)
1241
                    $$.phdrs = TRUE;
1242
                  else if (strcmp ($1, "FLAGS") == 0 && $2 != NULL)
1243
                    $$.flags = $2;
1244
                  else
1245 166 khays
                    einfo (_("%X%P:%S: PHDRS syntax error at `%s'\n"),
1246
                           NULL, $1);
1247 145 khays
                }
1248
        |       AT '(' exp ')' phdr_qualifiers
1249
                {
1250
                  $$ = $5;
1251
                  $$.at = $3;
1252
                }
1253
        ;
1254
 
1255
phdr_val:
1256
                /* empty */
1257
                {
1258
                  $$ = NULL;
1259
                }
1260
        | '(' exp ')'
1261
                {
1262
                  $$ = $2;
1263
                }
1264
        ;
1265
 
1266
dynamic_list_file:
1267
                {
1268
                  ldlex_version_file ();
1269
                  PUSH_ERROR (_("dynamic list"));
1270
                }
1271
                dynamic_list_nodes
1272
                {
1273
                  ldlex_popstate ();
1274
                  POP_ERROR ();
1275
                }
1276
        ;
1277
 
1278
dynamic_list_nodes:
1279
                dynamic_list_node
1280
        |       dynamic_list_nodes dynamic_list_node
1281
        ;
1282
 
1283
dynamic_list_node:
1284
                '{' dynamic_list_tag '}' ';'
1285
        ;
1286
 
1287
dynamic_list_tag:
1288
                vers_defns ';'
1289
                {
1290
                  lang_append_dynamic_list ($1);
1291
                }
1292
        ;
1293
 
1294
/* This syntax is used within an external version script file.  */
1295
 
1296
version_script_file:
1297
                {
1298
                  ldlex_version_file ();
1299
                  PUSH_ERROR (_("VERSION script"));
1300
                }
1301
                vers_nodes
1302
                {
1303
                  ldlex_popstate ();
1304
                  POP_ERROR ();
1305
                }
1306
        ;
1307
 
1308
/* This is used within a normal linker script file.  */
1309
 
1310
version:
1311
                {
1312
                  ldlex_version_script ();
1313
                }
1314
                VERSIONK '{' vers_nodes '}'
1315
                {
1316
                  ldlex_popstate ();
1317
                }
1318
        ;
1319
 
1320
vers_nodes:
1321
                vers_node
1322
        |       vers_nodes vers_node
1323
        ;
1324
 
1325
vers_node:
1326
                '{' vers_tag '}' ';'
1327
                {
1328
                  lang_register_vers_node (NULL, $2, NULL);
1329
                }
1330
        |       VERS_TAG '{' vers_tag '}' ';'
1331
                {
1332
                  lang_register_vers_node ($1, $3, NULL);
1333
                }
1334
        |       VERS_TAG '{' vers_tag '}' verdep ';'
1335
                {
1336
                  lang_register_vers_node ($1, $3, $5);
1337
                }
1338
        ;
1339
 
1340
verdep:
1341
                VERS_TAG
1342
                {
1343
                  $$ = lang_add_vers_depend (NULL, $1);
1344
                }
1345
        |       verdep VERS_TAG
1346
                {
1347
                  $$ = lang_add_vers_depend ($1, $2);
1348
                }
1349
        ;
1350
 
1351
vers_tag:
1352
                /* empty */
1353
                {
1354
                  $$ = lang_new_vers_node (NULL, NULL);
1355
                }
1356
        |       vers_defns ';'
1357
                {
1358
                  $$ = lang_new_vers_node ($1, NULL);
1359
                }
1360
        |       GLOBAL ':' vers_defns ';'
1361
                {
1362
                  $$ = lang_new_vers_node ($3, NULL);
1363
                }
1364
        |       LOCAL ':' vers_defns ';'
1365
                {
1366
                  $$ = lang_new_vers_node (NULL, $3);
1367
                }
1368
        |       GLOBAL ':' vers_defns ';' LOCAL ':' vers_defns ';'
1369
                {
1370
                  $$ = lang_new_vers_node ($3, $7);
1371
                }
1372
        ;
1373
 
1374
vers_defns:
1375
                VERS_IDENTIFIER
1376
                {
1377
                  $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, FALSE);
1378
                }
1379
        |       NAME
1380
                {
1381
                  $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, TRUE);
1382
                }
1383
        |       vers_defns ';' VERS_IDENTIFIER
1384
                {
1385
                  $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, FALSE);
1386
                }
1387
        |       vers_defns ';' NAME
1388
                {
1389
                  $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, TRUE);
1390
                }
1391
        |       vers_defns ';' EXTERN NAME '{'
1392
                        {
1393
                          $$ = ldgram_vers_current_lang;
1394
                          ldgram_vers_current_lang = $4;
1395
                        }
1396
                vers_defns opt_semicolon '}'
1397
                        {
1398
                          struct bfd_elf_version_expr *pat;
1399
                          for (pat = $7; pat->next != NULL; pat = pat->next);
1400
                          pat->next = $1;
1401
                          $$ = $7;
1402
                          ldgram_vers_current_lang = $6;
1403
                        }
1404
        |       EXTERN NAME '{'
1405
                        {
1406
                          $$ = ldgram_vers_current_lang;
1407
                          ldgram_vers_current_lang = $2;
1408
                        }
1409
                vers_defns opt_semicolon '}'
1410
                        {
1411
                          $$ = $5;
1412
                          ldgram_vers_current_lang = $4;
1413
                        }
1414
        |       GLOBAL
1415
                {
1416
                  $$ = lang_new_vers_pattern (NULL, "global", ldgram_vers_current_lang, FALSE);
1417
                }
1418
        |       vers_defns ';' GLOBAL
1419
                {
1420
                  $$ = lang_new_vers_pattern ($1, "global", ldgram_vers_current_lang, FALSE);
1421
                }
1422
        |       LOCAL
1423
                {
1424
                  $$ = lang_new_vers_pattern (NULL, "local", ldgram_vers_current_lang, FALSE);
1425
                }
1426
        |       vers_defns ';' LOCAL
1427
                {
1428
                  $$ = lang_new_vers_pattern ($1, "local", ldgram_vers_current_lang, FALSE);
1429
                }
1430
        |       EXTERN
1431
                {
1432
                  $$ = lang_new_vers_pattern (NULL, "extern", ldgram_vers_current_lang, FALSE);
1433
                }
1434
        |       vers_defns ';' EXTERN
1435
                {
1436
                  $$ = lang_new_vers_pattern ($1, "extern", ldgram_vers_current_lang, FALSE);
1437
                }
1438
        ;
1439
 
1440
opt_semicolon:
1441
                /* empty */
1442
        |       ';'
1443
        ;
1444
 
1445
%%
1446
void
1447
yyerror(arg)
1448
     const char *arg;
1449
{
1450
  if (ldfile_assumed_script)
1451
    einfo (_("%P:%s: file format not recognized; treating as linker script\n"),
1452 166 khays
           ldlex_filename ());
1453 145 khays
  if (error_index > 0 && error_index < ERROR_NAME_MAX)
1454 166 khays
    einfo ("%P%F:%S: %s in %s\n", NULL, arg, error_names[error_index - 1]);
1455 145 khays
  else
1456 166 khays
    einfo ("%P%F:%S: %s\n", NULL, arg);
1457 145 khays
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.