1 /* A YACC grammar to parse a superset of the AT&T linker scripting language.
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
4 Free Software Foundation, Inc.
5 Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
7 This file is part of the GNU Binutils.
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.
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.
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. */
29 #define DONTDECLARE_MALLOC
50 static enum section_type sectype
;
51 static lang_memory_region_type
*region
;
53 bfd_boolean ldgram_had_keep
= FALSE
;
54 char *ldgram_vers_current_lang
= NULL
;
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--;
72 struct wildcard_spec wildcard
;
73 struct wildcard_list
*wildcard_list
;
74 struct name_list
*name_list
;
76 union etree_union
*etree
;
81 union etree_union
*at
;
82 union etree_union
*flags
;
84 struct lang_nocrossref
*nocrossref
;
85 struct lang_output_section_phdr_list
*section_phdr
;
86 struct bfd_elf_version_deps
*deflist
;
87 struct bfd_elf_version_expr
*versyms
;
88 struct bfd_elf_version_tree
*versnode
;
91 %type
<etree
> exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val
92 %type
<etree
> opt_exp_without_type opt_subalign opt_align
93 %type
<fill
> fill_opt fill_exp
94 %type
<name_list
> exclude_name_list
95 %type
<wildcard_list
> file_NAME_list
96 %type
<name
> memspec_opt casesymlist
97 %type
<name
> memspec_at_opt
98 %type
<cname
> wildcard_name
99 %type
<wildcard
> wildcard_spec
101 %token
<name
> NAME LNAME
102 %type
<integer
> length
103 %type
<phdr
> phdr_qualifiers
104 %type
<nocrossref
> nocrossref_list
105 %type
<section_phdr
> phdr_opt
106 %type
<integer
> opt_nocrossrefs
108 %right
<token
> PLUSEQ MINUSEQ MULTEQ DIVEQ
'=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
109 %right
<token
> '?' ':'
116 %left
<token
> '<' '>' LE GE
117 %left
<token
> LSHIFT RSHIFT
119 %left
<token
> '+' '-'
120 %left
<token
> '*' '/' '%'
125 %token
<token
> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE
126 %token SECTIONS PHDRS INSERT_K AFTER BEFORE
127 %token DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END
128 %token SORT_BY_NAME SORT_BY_ALIGNMENT
129 %token SORT_BY_INIT_PRIORITY
131 %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
132 %token INHIBIT_COMMON_ALLOCATION
137 %token NOLOAD DSECT COPY INFO OVERLAY
138 %token DEFINED TARGET_K SEARCH_DIR MAP ENTRY
139 %token
<integer
> NEXT
140 %token SIZEOF ALIGNOF ADDR LOADADDR MAX_K MIN_K
141 %token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS
143 %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS
144 %token ALIGNMOD AT SUBALIGN PROVIDE PROVIDE_HIDDEN AS_NEEDED
145 %type
<token
> assign_op atype attributes_opt sect_constraint
146 %type
<name
> filename
147 %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K
148 %token FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL
149 %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START
150 %token
<name
> VERS_TAG VERS_IDENTIFIER
151 %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT
152 %token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL
155 %type
<versyms
> vers_defns
156 %type
<versnode
> vers_tag
157 %type
<deflist
> verdep
158 %token INPUT_DYNAMIC_LIST
163 INPUT_SCRIPT script_file
164 | INPUT_MRI_SCRIPT mri_script_file
165 | INPUT_VERSION_SCRIPT version_script_file
166 | INPUT_DYNAMIC_LIST dynamic_list_file
167 | INPUT_DEFSYM defsym_expr
179 lang_add_assignment
(exp_assop
($3,$2,$4));
183 /* SYNTAX WITHIN AN MRI SCRIPT FILE */
187 PUSH_ERROR
(_
("MRI style script"));
198 mri_script_lines mri_script_command NEWLINE
206 einfo
(_
("%P%F: unrecognised keyword in MRI style script '%s'\n"),$1);
209 config.map_filename
= "-";
211 | ORDER ordernamelist
213 | PUBLIC NAME
'=' exp
214 { mri_public
($2, $4); }
215 | PUBLIC NAME
',' exp
216 { mri_public
($2, $4); }
218 { mri_public
($2, $3); }
222 { mri_output_section
($2, $4);}
224 { mri_output_section
($2, $3);}
226 { mri_output_section
($2, $4);}
227 | ALIGN_K NAME
'=' exp
228 { mri_align
($2,$4); }
229 | ALIGN_K NAME
',' exp
230 { mri_align
($2,$4); }
231 | ALIGNMOD NAME
'=' exp
232 { mri_alignmod
($2,$4); }
233 | ALIGNMOD NAME
',' exp
234 { mri_alignmod
($2,$4); }
235 | ABSOLUTE mri_abs_name_list
236 | LOAD mri_load_name_list
239 | ALIAS NAME
',' NAME
240 { mri_alias
($2,$4,0);}
242 { mri_alias
($2, 0, (int) $4.integer
); }
246 { mri_truncate
((unsigned int) $2.integer
); }
248 | EXTERN extern_name_list
250 { ldlex_script
(); ldfile_open_command_file
($2); }
252 { ldlex_popstate
(); }
254 { lang_add_entry
($2, FALSE
); }
259 ordernamelist
',' NAME
{ mri_order
($3); }
260 | ordernamelist NAME
{ mri_order
($2); }
267 | mri_load_name_list
',' NAME
{ mri_load
($3); }
272 { mri_only_load
($1); }
273 | mri_abs_name_list
',' NAME
274 { mri_only_load
($3); }
278 /* empty */ { $$
= NULL
; }
280 | casesymlist
',' NAME
283 /* Parsed as expressions so that commas separate entries */
285 { ldlex_expression
(); }
286 extern_name_list_body
287 { ldlex_popstate
(); }
289 extern_name_list_body:
291 { ldlang_add_undef
($1, FALSE
); }
292 | extern_name_list_body NAME
293 { ldlang_add_undef
($2, FALSE
); }
294 | extern_name_list_body
',' NAME
295 { ldlang_add_undef
($3, FALSE
); }
301 { ldlex_popstate
(); }
317 | floating_point_support
321 | TARGET_K
'(' NAME
')'
322 { lang_add_target
($3); }
323 | SEARCH_DIR
'(' filename
')'
324 { ldfile_add_library_path
($3, FALSE
); }
325 | OUTPUT
'(' filename
')'
326 { lang_add_output
($3, 1); }
327 | OUTPUT_FORMAT
'(' NAME
')'
328 { lang_add_output_format
($3, (char *) NULL
,
330 | OUTPUT_FORMAT
'(' NAME
',' NAME
',' NAME
')'
331 { lang_add_output_format
($3, $5, $7, 1); }
332 | OUTPUT_ARCH
'(' NAME
')'
333 { ldfile_set_output_arch
($3, bfd_arch_unknown
); }
334 | FORCE_COMMON_ALLOCATION
335 { command_line.force_common_definition
= TRUE
; }
336 | INHIBIT_COMMON_ALLOCATION
337 { command_line.inhibit_common_definition
= TRUE
; }
338 | INPUT
'(' input_list
')'
340 { lang_enter_group
(); }
342 { lang_leave_group
(); }
343 | MAP
'(' filename
')'
344 { lang_add_map
($3); }
346 { ldlex_script
(); ldfile_open_command_file
($2); }
348 { ldlex_popstate
(); }
349 | NOCROSSREFS
'(' nocrossref_list
')'
351 lang_add_nocrossref
($3);
353 | EXTERN
'(' extern_name_list
')'
354 | INSERT_K AFTER NAME
355 { lang_add_insert
($3, 0); }
356 | INSERT_K BEFORE NAME
357 { lang_add_insert
($3, 1); }
358 | REGION_ALIAS
'(' NAME
',' NAME
')'
359 { lang_memory_region_alias
($3, $5); }
364 { lang_add_input_file
($1,lang_input_file_is_search_file_enum
,
366 | input_list
',' NAME
367 { lang_add_input_file
($3,lang_input_file_is_search_file_enum
,
370 { lang_add_input_file
($2,lang_input_file_is_search_file_enum
,
373 { lang_add_input_file
($1,lang_input_file_is_l_enum
,
375 | input_list
',' LNAME
376 { lang_add_input_file
($3,lang_input_file_is_l_enum
,
379 { lang_add_input_file
($2,lang_input_file_is_l_enum
,
382 { $
<integer
>$
= add_DT_NEEDED_for_regular
; add_DT_NEEDED_for_regular
= TRUE
; }
384 { add_DT_NEEDED_for_regular
= $
<integer
>3; }
385 | input_list
',' AS_NEEDED
'('
386 { $
<integer
>$
= add_DT_NEEDED_for_regular
; add_DT_NEEDED_for_regular
= TRUE
; }
388 { add_DT_NEEDED_for_regular
= $
<integer
>5; }
389 | input_list AS_NEEDED
'('
390 { $
<integer
>$
= add_DT_NEEDED_for_regular
; add_DT_NEEDED_for_regular
= TRUE
; }
392 { add_DT_NEEDED_for_regular
= $
<integer
>4; }
396 SECTIONS
'{' sec_or_group_p1
'}'
400 sec_or_group_p1 section
401 | sec_or_group_p1 statement_anywhere
407 { lang_add_entry
($3, FALSE
); }
409 | ASSERT_K
{ldlex_expression
();} '(' exp
',' NAME
')'
411 lang_add_assignment
(exp_assert
($4, $6)); }
414 /* The '*' and '?' cases are there because the lexer returns them as
415 separate tokens rather than as NAME. */
436 $$.exclude_name_list
= NULL
;
438 | EXCLUDE_FILE
'(' exclude_name_list
')' wildcard_name
442 $$.exclude_name_list
= $3;
444 | SORT_BY_NAME
'(' wildcard_name
')'
448 $$.exclude_name_list
= NULL
;
450 | SORT_BY_ALIGNMENT
'(' wildcard_name
')'
453 $$.sorted
= by_alignment
;
454 $$.exclude_name_list
= NULL
;
456 | SORT_BY_NAME
'(' SORT_BY_ALIGNMENT
'(' wildcard_name
')' ')'
459 $$.sorted
= by_name_alignment
;
460 $$.exclude_name_list
= NULL
;
462 | SORT_BY_NAME
'(' SORT_BY_NAME
'(' wildcard_name
')' ')'
466 $$.exclude_name_list
= NULL
;
468 | SORT_BY_ALIGNMENT
'(' SORT_BY_NAME
'(' wildcard_name
')' ')'
471 $$.sorted
= by_alignment_name
;
472 $$.exclude_name_list
= NULL
;
474 | SORT_BY_ALIGNMENT
'(' SORT_BY_ALIGNMENT
'(' wildcard_name
')' ')'
477 $$.sorted
= by_alignment
;
478 $$.exclude_name_list
= NULL
;
480 | SORT_BY_NAME
'(' EXCLUDE_FILE
'(' exclude_name_list
')' wildcard_name
')'
484 $$.exclude_name_list
= $5;
486 | SORT_BY_INIT_PRIORITY
'(' wildcard_name
')'
489 $$.sorted
= by_init_priority
;
490 $$.exclude_name_list
= NULL
;
495 exclude_name_list wildcard_name
497 struct name_list
*tmp
;
498 tmp
= (struct name_list
*) xmalloc
(sizeof
*tmp
);
506 struct name_list
*tmp
;
507 tmp
= (struct name_list
*) xmalloc
(sizeof
*tmp
);
515 file_NAME_list opt_comma wildcard_spec
517 struct wildcard_list
*tmp
;
518 tmp
= (struct wildcard_list
*) xmalloc
(sizeof
*tmp
);
526 struct wildcard_list
*tmp
;
527 tmp
= (struct wildcard_list
*) xmalloc
(sizeof
*tmp
);
534 input_section_spec_no_keep:
537 struct wildcard_spec tmp
;
539 tmp.exclude_name_list
= NULL
;
541 lang_add_wild
(&tmp
, NULL
, ldgram_had_keep
);
543 |
'[' file_NAME_list
']'
545 lang_add_wild
(NULL
, $2, ldgram_had_keep
);
547 | wildcard_spec
'(' file_NAME_list
')'
549 lang_add_wild
(&$1, $3, ldgram_had_keep
);
554 input_section_spec_no_keep
556 { ldgram_had_keep
= TRUE
; }
557 input_section_spec_no_keep
')'
558 { ldgram_had_keep
= FALSE
; }
563 | CREATE_OBJECT_SYMBOLS
565 lang_add_attribute
(lang_object_symbols_statement_enum
);
571 lang_add_attribute
(lang_constructors_statement_enum
);
573 | SORT_BY_NAME
'(' CONSTRUCTORS
')'
575 constructors_sorted
= TRUE
;
576 lang_add_attribute
(lang_constructors_statement_enum
);
579 | length
'(' mustbe_exp
')'
581 lang_add_data
((int) $1, $3);
584 | FILL
'(' fill_exp
')'
588 | ASSERT_K
{ldlex_expression
();} '(' exp
',' NAME
')' end
590 lang_add_assignment
(exp_assert
($4, $6)); }
592 { ldlex_script
(); ldfile_open_command_file
($2); }
593 statement_list_opt END
594 { ldlex_popstate
(); }
598 statement_list statement
623 $$
= exp_get_fill
($1, 0, "fill value");
630 |
{ $$
= (fill_type
*) 0; }
660 lang_add_assignment
(exp_assop
($2, $1, $3));
662 | NAME assign_op mustbe_exp
664 lang_add_assignment
(exp_assop
('=', $1,
670 | PROVIDE
'(' NAME
'=' mustbe_exp
')'
672 lang_add_assignment
(exp_provide
($3, $5, FALSE
));
674 | PROVIDE_HIDDEN
'(' NAME
'=' mustbe_exp
')'
676 lang_add_assignment
(exp_provide
($3, $5, TRUE
));
686 MEMORY
'{' memory_spec_list_opt
'}'
689 memory_spec_list_opt: memory_spec_list |
;
692 memory_spec_list opt_comma memory_spec
698 { region
= lang_memory_region_lookup
($1, TRUE
); }
700 origin_spec opt_comma length_spec
703 { ldlex_script
(); ldfile_open_command_file
($2); }
704 memory_spec_list_opt END
705 { ldlex_popstate
(); }
709 ORIGIN
'=' mustbe_exp
711 region
->origin
= exp_get_vma
($3, 0, "origin");
712 region
->current
= region
->origin
;
717 LENGTH
'=' mustbe_exp
719 region
->length
= exp_get_vma
($3, -1, "length");
725 { /* dummy action to avoid bison 1.25 error message */ }
726 |
'(' attributes_list
')'
731 | attributes_list attributes_string
736 { lang_set_flags
(region
, $1, 0); }
738 { lang_set_flags
(region
, $2, 1); }
742 STARTUP
'(' filename
')'
743 { lang_startup
($3); }
747 HLL
'(' high_level_library_NAME_list
')'
749 { ldemul_hll
((char *)NULL
); }
752 high_level_library_NAME_list:
753 high_level_library_NAME_list opt_comma filename
761 SYSLIB
'(' low_level_library_NAME_list
')'
762 ; low_level_library_NAME_list
:
763 low_level_library_NAME_list opt_comma filename
764 { ldemul_syslib
($3); }
768 floating_point_support:
770 { lang_float
(TRUE
); }
772 { lang_float
(FALSE
); }
780 | NAME nocrossref_list
782 struct lang_nocrossref
*n
;
784 n
= (struct lang_nocrossref
*) xmalloc
(sizeof
*n
);
789 | NAME
',' nocrossref_list
791 struct lang_nocrossref
*n
;
793 n
= (struct lang_nocrossref
*) xmalloc
(sizeof
*n
);
800 mustbe_exp: { ldlex_expression
(); }
802 { ldlex_popstate
(); $$
=$2;}
807 { $$
= exp_unop
('-', $2); }
810 | NEXT
'(' exp
')' %prec UNARY
811 { $$
= exp_unop
((int) $1,$3); }
812 |
'!' exp %prec UNARY
813 { $$
= exp_unop
('!', $2); }
814 |
'+' exp %prec UNARY
816 |
'~' exp %prec UNARY
817 { $$
= exp_unop
('~', $2);}
820 { $$
= exp_binop
('*', $1, $3); }
822 { $$
= exp_binop
('/', $1, $3); }
824 { $$
= exp_binop
('%', $1, $3); }
826 { $$
= exp_binop
('+', $1, $3); }
828 { $$
= exp_binop
('-' , $1, $3); }
830 { $$
= exp_binop
(LSHIFT
, $1, $3); }
832 { $$
= exp_binop
(RSHIFT
, $1, $3); }
834 { $$
= exp_binop
(EQ
, $1, $3); }
836 { $$
= exp_binop
(NE
, $1, $3); }
838 { $$
= exp_binop
(LE
, $1, $3); }
840 { $$
= exp_binop
(GE
, $1, $3); }
842 { $$
= exp_binop
('<' , $1, $3); }
844 { $$
= exp_binop
('>' , $1, $3); }
846 { $$
= exp_binop
('&' , $1, $3); }
848 { $$
= exp_binop
('^' , $1, $3); }
850 { $$
= exp_binop
('|' , $1, $3); }
851 | exp
'?' exp
':' exp
852 { $$
= exp_trinop
('?' , $1, $3, $5); }
854 { $$
= exp_binop
(ANDAND
, $1, $3); }
856 { $$
= exp_binop
(OROR
, $1, $3); }
857 | DEFINED
'(' NAME
')'
858 { $$
= exp_nameop
(DEFINED
, $3); }
860 { $$
= exp_bigintop
($1.integer
, $1.str
); }
862 { $$
= exp_nameop
(SIZEOF_HEADERS
,0); }
864 | ALIGNOF
'(' NAME
')'
865 { $$
= exp_nameop
(ALIGNOF
,$3); }
866 | SIZEOF
'(' NAME
')'
867 { $$
= exp_nameop
(SIZEOF
,$3); }
869 { $$
= exp_nameop
(ADDR
,$3); }
870 | LOADADDR
'(' NAME
')'
871 { $$
= exp_nameop
(LOADADDR
,$3); }
872 | CONSTANT
'(' NAME
')'
873 { $$
= exp_nameop
(CONSTANT
,$3); }
874 | ABSOLUTE
'(' exp
')'
875 { $$
= exp_unop
(ABSOLUTE
, $3); }
876 | ALIGN_K
'(' exp
')'
877 { $$
= exp_unop
(ALIGN_K
,$3); }
878 | ALIGN_K
'(' exp
',' exp
')'
879 { $$
= exp_binop
(ALIGN_K
,$3,$5); }
880 | DATA_SEGMENT_ALIGN
'(' exp
',' exp
')'
881 { $$
= exp_binop
(DATA_SEGMENT_ALIGN
, $3, $5); }
882 | DATA_SEGMENT_RELRO_END
'(' exp
',' exp
')'
883 { $$
= exp_binop
(DATA_SEGMENT_RELRO_END
, $5, $3); }
884 | DATA_SEGMENT_END
'(' exp
')'
885 { $$
= exp_unop
(DATA_SEGMENT_END
, $3); }
886 | SEGMENT_START
'(' NAME
',' exp
')'
887 { /* The operands to the expression node are
888 placed in the opposite order from the way
889 in which they appear in the script as
890 that allows us to reuse more code in
892 $$
= exp_binop
(SEGMENT_START
,
894 exp_nameop
(NAME
, $3)); }
896 { $$
= exp_unop
(ALIGN_K
,$3); }
898 { $$
= exp_nameop
(NAME
,$1); }
899 | MAX_K
'(' exp
',' exp
')'
900 { $$
= exp_binop
(MAX_K
, $3, $5 ); }
901 | MIN_K
'(' exp
',' exp
')'
902 { $$
= exp_binop
(MIN_K
, $3, $5 ); }
903 | ASSERT_K
'(' exp
',' NAME
')'
904 { $$
= exp_assert
($3, $5); }
905 | ORIGIN
'(' NAME
')'
906 { $$
= exp_nameop
(ORIGIN
, $3); }
907 | LENGTH
'(' NAME
')'
908 { $$
= exp_nameop
(LENGTH
, $3); }
913 AT
'>' NAME
{ $$
= $3; }
918 AT
'(' exp
')' { $$
= $3; }
923 ALIGN_K
'(' exp
')' { $$
= $3; }
928 SUBALIGN
'(' exp
')' { $$
= $3; }
933 ONLY_IF_RO
{ $$
= ONLY_IF_RO
; }
934 | ONLY_IF_RW
{ $$
= ONLY_IF_RW
; }
935 | SPECIAL
{ $$
= SPECIAL
; }
939 section: NAME
{ ldlex_expression
(); }
943 opt_subalign
{ ldlex_popstate
(); ldlex_script
(); }
947 lang_enter_output_section_statement
($1, $3,
952 '}' { ldlex_popstate
(); ldlex_expression
(); }
953 memspec_opt memspec_at_opt phdr_opt fill_opt
956 lang_leave_output_section_statement
($17, $14, $16, $15);
961 { ldlex_expression
(); }
962 opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
963 { ldlex_popstate
(); ldlex_script
(); }
966 lang_enter_overlay
($3, $6);
970 { ldlex_popstate
(); ldlex_expression
(); }
971 memspec_opt memspec_at_opt phdr_opt fill_opt
974 lang_leave_overlay
($5, (int) $4,
978 |
/* The GROUP case is just enough to support the gcc
979 svr3.ifile script. It is not intended to be full
980 support. I'm not even sure what GROUP is supposed
982 GROUP
{ ldlex_expression
(); }
986 lang_add_assignment
(exp_assop
('=', ".", $3));
988 '{' sec_or_group_p1
'}'
990 { ldlex_script
(); ldfile_open_command_file
($2); }
992 { ldlex_popstate
(); }
996 NOLOAD
{ sectype
= noload_section
; }
997 | DSECT
{ sectype
= noalloc_section
; }
998 | COPY
{ sectype
= noalloc_section
; }
999 | INFO
{ sectype
= noalloc_section
; }
1000 | OVERLAY
{ sectype
= noalloc_section
; }
1005 |
/* EMPTY */ { sectype
= normal_section
; }
1006 |
'(' ')' { sectype
= normal_section
; }
1010 exp atype
':' { $$
= $1; }
1011 | atype
':' { $$
= (etree_type
*)NULL
; }
1012 |
/* The BIND cases are to support the gcc svr3.ifile
1013 script. They aren't intended to implement full
1014 support for the BIND keyword. I'm not even sure
1015 what BIND is supposed to mean. */
1016 BIND
'(' exp
')' atype
':' { $$
= $3; }
1017 | BIND
'(' exp
')' BLOCK
'(' exp
')' atype
':'
1021 opt_exp_without_type:
1022 exp
':' { $$
= $1; }
1023 |
':' { $$
= (etree_type
*) NULL
; }
1036 |
{ $$
= DEFAULT_MEMORY_REGION
; }
1046 struct lang_output_section_phdr_list
*n
;
1048 n
= ((struct lang_output_section_phdr_list
*)
1049 xmalloc
(sizeof
*n
));
1063 lang_enter_overlay_section
($2);
1065 '{' statement_list_opt
'}'
1066 { ldlex_popstate
(); ldlex_expression
(); }
1070 lang_leave_overlay_section
($9, $8);
1076 PHDRS
'{' phdr_list
'}'
1085 NAME
{ ldlex_expression
(); }
1086 phdr_type phdr_qualifiers
{ ldlex_popstate
(); }
1089 lang_new_phdr
($1, $3, $4.filehdr
, $4.phdrs
, $4.at
,
1099 if
($1->type.node_class
== etree_name
1100 && $1->type.node_code
== NAME
)
1104 static const char * const phdr_types
[] =
1106 "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
1107 "PT_INTERP", "PT_NOTE", "PT_SHLIB",
1113 i
< sizeof phdr_types
/ sizeof phdr_types
[0];
1115 if
(strcmp
(s
, phdr_types
[i
]) == 0)
1120 if
(i
== sizeof phdr_types
/ sizeof phdr_types
[0])
1122 if
(strcmp
(s
, "PT_GNU_EH_FRAME") == 0)
1123 $$
= exp_intop
(0x6474e550);
1124 else if
(strcmp
(s
, "PT_GNU_STACK") == 0)
1125 $$
= exp_intop
(0x6474e551);
1129 %X%P:%S: unknown phdr type `%s' (try integer literal)\n"),
1141 memset
(&$$
, 0, sizeof
(struct phdr_info
));
1143 | NAME phdr_val phdr_qualifiers
1146 if
(strcmp
($1, "FILEHDR") == 0 && $2 == NULL
)
1148 else if
(strcmp
($1, "PHDRS") == 0 && $2 == NULL
)
1150 else if
(strcmp
($1, "FLAGS") == 0 && $2 != NULL
)
1153 einfo
(_
("%X%P:%S: PHDRS syntax error at `%s'\n"), $1);
1155 | AT
'(' exp
')' phdr_qualifiers
1175 ldlex_version_file
();
1176 PUSH_ERROR
(_
("dynamic list"));
1187 | dynamic_list_nodes dynamic_list_node
1191 '{' dynamic_list_tag
'}' ';'
1197 lang_append_dynamic_list
($1);
1201 /* This syntax is used within an external version script file. */
1203 version_script_file:
1205 ldlex_version_file
();
1206 PUSH_ERROR
(_
("VERSION script"));
1215 /* This is used within a normal linker script file. */
1219 ldlex_version_script
();
1221 VERSIONK
'{' vers_nodes
'}'
1229 | vers_nodes vers_node
1233 '{' vers_tag
'}' ';'
1235 lang_register_vers_node
(NULL
, $2, NULL
);
1237 | VERS_TAG
'{' vers_tag
'}' ';'
1239 lang_register_vers_node
($1, $3, NULL
);
1241 | VERS_TAG
'{' vers_tag
'}' verdep
';'
1243 lang_register_vers_node
($1, $3, $5);
1250 $$
= lang_add_vers_depend
(NULL
, $1);
1254 $$
= lang_add_vers_depend
($1, $2);
1261 $$
= lang_new_vers_node
(NULL
, NULL
);
1265 $$
= lang_new_vers_node
($1, NULL
);
1267 | GLOBAL
':' vers_defns
';'
1269 $$
= lang_new_vers_node
($3, NULL
);
1271 | LOCAL
':' vers_defns
';'
1273 $$
= lang_new_vers_node
(NULL
, $3);
1275 | GLOBAL
':' vers_defns
';' LOCAL
':' vers_defns
';'
1277 $$
= lang_new_vers_node
($3, $7);
1284 $$
= lang_new_vers_pattern
(NULL
, $1, ldgram_vers_current_lang
, FALSE
);
1288 $$
= lang_new_vers_pattern
(NULL
, $1, ldgram_vers_current_lang
, TRUE
);
1290 | vers_defns
';' VERS_IDENTIFIER
1292 $$
= lang_new_vers_pattern
($1, $3, ldgram_vers_current_lang
, FALSE
);
1294 | vers_defns
';' NAME
1296 $$
= lang_new_vers_pattern
($1, $3, ldgram_vers_current_lang
, TRUE
);
1298 | vers_defns
';' EXTERN NAME
'{'
1300 $
<name
>$
= ldgram_vers_current_lang
;
1301 ldgram_vers_current_lang
= $4;
1303 vers_defns opt_semicolon
'}'
1305 struct bfd_elf_version_expr
*pat
;
1306 for
(pat
= $7; pat
->next
!= NULL
; pat
= pat
->next
);
1309 ldgram_vers_current_lang
= $
<name
>6;
1313 $
<name
>$
= ldgram_vers_current_lang
;
1314 ldgram_vers_current_lang
= $2;
1316 vers_defns opt_semicolon
'}'
1319 ldgram_vers_current_lang
= $
<name
>4;
1323 $$
= lang_new_vers_pattern
(NULL
, "global", ldgram_vers_current_lang
, FALSE
);
1325 | vers_defns
';' GLOBAL
1327 $$
= lang_new_vers_pattern
($1, "global", ldgram_vers_current_lang
, FALSE
);
1331 $$
= lang_new_vers_pattern
(NULL
, "local", ldgram_vers_current_lang
, FALSE
);
1333 | vers_defns
';' LOCAL
1335 $$
= lang_new_vers_pattern
($1, "local", ldgram_vers_current_lang
, FALSE
);
1339 $$
= lang_new_vers_pattern
(NULL
, "extern", ldgram_vers_current_lang
, FALSE
);
1341 | vers_defns
';' EXTERN
1343 $$
= lang_new_vers_pattern
($1, "extern", ldgram_vers_current_lang
, FALSE
);
1357 if
(ldfile_assumed_script
)
1358 einfo
(_
("%P:%s: file format not recognized; treating as linker script\n"),
1359 ldfile_input_filename
);
1360 if
(error_index
> 0 && error_index
< ERROR_NAME_MAX
)
1361 einfo
("%P%F:%S: %s in %s\n", arg
, error_names
[error_index
-1]);
1363 einfo
("%P%F:%S: %s\n", arg
);