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, 2010, 2011
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
138 %token NOLOAD DSECT COPY INFO OVERLAY
139 %token DEFINED TARGET_K SEARCH_DIR MAP ENTRY
140 %token
<integer
> NEXT
141 %token SIZEOF ALIGNOF ADDR LOADADDR MAX_K MIN_K
142 %token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS
144 %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS
145 %token ALIGNMOD AT SUBALIGN PROVIDE PROVIDE_HIDDEN AS_NEEDED
146 %type
<token
> assign_op atype attributes_opt sect_constraint
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 ONLY_IF_RO ONLY_IF_RW SPECIAL
156 %type
<versyms
> vers_defns
157 %type
<versnode
> vers_tag
158 %type
<deflist
> verdep
159 %token INPUT_DYNAMIC_LIST
164 INPUT_SCRIPT script_file
165 | INPUT_MRI_SCRIPT mri_script_file
166 | INPUT_VERSION_SCRIPT version_script_file
167 | INPUT_DYNAMIC_LIST dynamic_list_file
168 | INPUT_DEFSYM defsym_expr
180 lang_add_assignment
(exp_defsym
($2, $4));
184 /* SYNTAX WITHIN AN MRI SCRIPT FILE */
188 PUSH_ERROR
(_
("MRI style script"));
199 mri_script_lines mri_script_command NEWLINE
207 einfo
(_
("%P%F: unrecognised keyword in MRI style script '%s'\n"),$1);
210 config.map_filename
= "-";
212 | ORDER ordernamelist
214 | PUBLIC NAME
'=' exp
215 { mri_public
($2, $4); }
216 | PUBLIC NAME
',' exp
217 { mri_public
($2, $4); }
219 { mri_public
($2, $3); }
223 { mri_output_section
($2, $4);}
225 { mri_output_section
($2, $3);}
227 { mri_output_section
($2, $4);}
228 | ALIGN_K NAME
'=' exp
229 { mri_align
($2,$4); }
230 | ALIGN_K NAME
',' exp
231 { mri_align
($2,$4); }
232 | ALIGNMOD NAME
'=' exp
233 { mri_alignmod
($2,$4); }
234 | ALIGNMOD NAME
',' exp
235 { mri_alignmod
($2,$4); }
236 | ABSOLUTE mri_abs_name_list
237 | LOAD mri_load_name_list
240 | ALIAS NAME
',' NAME
241 { mri_alias
($2,$4,0);}
243 { mri_alias
($2, 0, (int) $4.integer
); }
247 { mri_truncate
((unsigned int) $2.integer
); }
249 | EXTERN extern_name_list
251 { ldlex_script
(); ldfile_open_command_file
($2); }
253 { ldlex_popstate
(); }
255 { lang_add_entry
($2, FALSE
); }
260 ordernamelist
',' NAME
{ mri_order
($3); }
261 | ordernamelist NAME
{ mri_order
($2); }
268 | mri_load_name_list
',' NAME
{ mri_load
($3); }
273 { mri_only_load
($1); }
274 | mri_abs_name_list
',' NAME
275 { mri_only_load
($3); }
279 /* empty */ { $$
= NULL
; }
281 | casesymlist
',' NAME
284 /* Parsed as expressions so that commas separate entries */
286 { ldlex_expression
(); }
287 extern_name_list_body
288 { ldlex_popstate
(); }
290 extern_name_list_body:
292 { ldlang_add_undef
($1, FALSE
); }
293 | extern_name_list_body NAME
294 { ldlang_add_undef
($2, FALSE
); }
295 | extern_name_list_body
',' NAME
296 { ldlang_add_undef
($3, FALSE
); }
302 { ldlex_popstate
(); }
318 | floating_point_support
322 | TARGET_K
'(' NAME
')'
323 { lang_add_target
($3); }
324 | SEARCH_DIR
'(' filename
')'
325 { ldfile_add_library_path
($3, FALSE
); }
326 | OUTPUT
'(' filename
')'
327 { lang_add_output
($3, 1); }
328 | OUTPUT_FORMAT
'(' NAME
')'
329 { lang_add_output_format
($3, (char *) NULL
,
331 | OUTPUT_FORMAT
'(' NAME
',' NAME
',' NAME
')'
332 { lang_add_output_format
($3, $5, $7, 1); }
333 | OUTPUT_ARCH
'(' NAME
')'
334 { ldfile_set_output_arch
($3, bfd_arch_unknown
); }
335 | FORCE_COMMON_ALLOCATION
336 { command_line.force_common_definition
= TRUE
; }
337 | INHIBIT_COMMON_ALLOCATION
338 { command_line.inhibit_common_definition
= TRUE
; }
339 | INPUT
'(' input_list
')'
341 { lang_enter_group
(); }
343 { lang_leave_group
(); }
344 | MAP
'(' filename
')'
345 { lang_add_map
($3); }
347 { ldlex_script
(); ldfile_open_command_file
($2); }
349 { ldlex_popstate
(); }
350 | NOCROSSREFS
'(' nocrossref_list
')'
352 lang_add_nocrossref
($3);
354 | EXTERN
'(' extern_name_list
')'
355 | INSERT_K AFTER NAME
356 { lang_add_insert
($3, 0); }
357 | INSERT_K BEFORE NAME
358 { lang_add_insert
($3, 1); }
359 | REGION_ALIAS
'(' NAME
',' NAME
')'
360 { lang_memory_region_alias
($3, $5); }
361 | LD_FEATURE
'(' NAME
')'
362 { lang_ld_feature
($3); }
367 { lang_add_input_file
($1,lang_input_file_is_search_file_enum
,
369 | input_list
',' NAME
370 { lang_add_input_file
($3,lang_input_file_is_search_file_enum
,
373 { lang_add_input_file
($2,lang_input_file_is_search_file_enum
,
376 { lang_add_input_file
($1,lang_input_file_is_l_enum
,
378 | input_list
',' LNAME
379 { lang_add_input_file
($3,lang_input_file_is_l_enum
,
382 { lang_add_input_file
($2,lang_input_file_is_l_enum
,
385 { $
<integer
>$
= add_DT_NEEDED_for_regular
; add_DT_NEEDED_for_regular
= TRUE
; }
387 { add_DT_NEEDED_for_regular
= $
<integer
>3; }
388 | input_list
',' AS_NEEDED
'('
389 { $
<integer
>$
= add_DT_NEEDED_for_regular
; add_DT_NEEDED_for_regular
= TRUE
; }
391 { add_DT_NEEDED_for_regular
= $
<integer
>5; }
392 | input_list AS_NEEDED
'('
393 { $
<integer
>$
= add_DT_NEEDED_for_regular
; add_DT_NEEDED_for_regular
= TRUE
; }
395 { add_DT_NEEDED_for_regular
= $
<integer
>4; }
399 SECTIONS
'{' sec_or_group_p1
'}'
403 sec_or_group_p1 section
404 | sec_or_group_p1 statement_anywhere
410 { lang_add_entry
($3, FALSE
); }
412 | ASSERT_K
{ldlex_expression
();} '(' exp
',' NAME
')'
414 lang_add_assignment
(exp_assert
($4, $6)); }
417 /* The '*' and '?' cases are there because the lexer returns them as
418 separate tokens rather than as NAME. */
439 $$.exclude_name_list
= NULL
;
441 | EXCLUDE_FILE
'(' exclude_name_list
')' wildcard_name
445 $$.exclude_name_list
= $3;
447 | SORT_BY_NAME
'(' wildcard_name
')'
451 $$.exclude_name_list
= NULL
;
453 | SORT_BY_ALIGNMENT
'(' wildcard_name
')'
456 $$.sorted
= by_alignment
;
457 $$.exclude_name_list
= NULL
;
459 | SORT_BY_NAME
'(' SORT_BY_ALIGNMENT
'(' wildcard_name
')' ')'
462 $$.sorted
= by_name_alignment
;
463 $$.exclude_name_list
= NULL
;
465 | SORT_BY_NAME
'(' SORT_BY_NAME
'(' wildcard_name
')' ')'
469 $$.exclude_name_list
= NULL
;
471 | SORT_BY_ALIGNMENT
'(' SORT_BY_NAME
'(' wildcard_name
')' ')'
474 $$.sorted
= by_alignment_name
;
475 $$.exclude_name_list
= NULL
;
477 | SORT_BY_ALIGNMENT
'(' SORT_BY_ALIGNMENT
'(' wildcard_name
')' ')'
480 $$.sorted
= by_alignment
;
481 $$.exclude_name_list
= NULL
;
483 | SORT_BY_NAME
'(' EXCLUDE_FILE
'(' exclude_name_list
')' wildcard_name
')'
487 $$.exclude_name_list
= $5;
489 | SORT_BY_INIT_PRIORITY
'(' wildcard_name
')'
492 $$.sorted
= by_init_priority
;
493 $$.exclude_name_list
= NULL
;
498 exclude_name_list wildcard_name
500 struct name_list
*tmp
;
501 tmp
= (struct name_list
*) xmalloc
(sizeof
*tmp
);
509 struct name_list
*tmp
;
510 tmp
= (struct name_list
*) xmalloc
(sizeof
*tmp
);
518 file_NAME_list opt_comma wildcard_spec
520 struct wildcard_list
*tmp
;
521 tmp
= (struct wildcard_list
*) xmalloc
(sizeof
*tmp
);
529 struct wildcard_list
*tmp
;
530 tmp
= (struct wildcard_list
*) xmalloc
(sizeof
*tmp
);
537 input_section_spec_no_keep:
540 struct wildcard_spec tmp
;
542 tmp.exclude_name_list
= NULL
;
544 lang_add_wild
(&tmp
, NULL
, ldgram_had_keep
);
546 |
'[' file_NAME_list
']'
548 lang_add_wild
(NULL
, $2, ldgram_had_keep
);
550 | wildcard_spec
'(' file_NAME_list
')'
552 lang_add_wild
(&$1, $3, ldgram_had_keep
);
557 input_section_spec_no_keep
559 { ldgram_had_keep
= TRUE
; }
560 input_section_spec_no_keep
')'
561 { ldgram_had_keep
= FALSE
; }
566 | CREATE_OBJECT_SYMBOLS
568 lang_add_attribute
(lang_object_symbols_statement_enum
);
574 lang_add_attribute
(lang_constructors_statement_enum
);
576 | SORT_BY_NAME
'(' CONSTRUCTORS
')'
578 constructors_sorted
= TRUE
;
579 lang_add_attribute
(lang_constructors_statement_enum
);
582 | length
'(' mustbe_exp
')'
584 lang_add_data
((int) $1, $3);
587 | FILL
'(' fill_exp
')'
591 | ASSERT_K
{ldlex_expression
();} '(' exp
',' NAME
')' end
593 lang_add_assignment
(exp_assert
($4, $6)); }
595 { ldlex_script
(); ldfile_open_command_file
($2); }
596 statement_list_opt END
597 { ldlex_popstate
(); }
601 statement_list statement
626 $$
= exp_get_fill
($1, 0, "fill value");
633 |
{ $$
= (fill_type
*) 0; }
663 lang_add_assignment
(exp_assign
($1, $3));
665 | NAME assign_op mustbe_exp
667 lang_add_assignment
(exp_assign
($1,
673 | PROVIDE
'(' NAME
'=' mustbe_exp
')'
675 lang_add_assignment
(exp_provide
($3, $5, FALSE
));
677 | PROVIDE_HIDDEN
'(' NAME
'=' mustbe_exp
')'
679 lang_add_assignment
(exp_provide
($3, $5, TRUE
));
689 MEMORY
'{' memory_spec_list_opt
'}'
692 memory_spec_list_opt: memory_spec_list |
;
695 memory_spec_list opt_comma memory_spec
701 { region
= lang_memory_region_lookup
($1, TRUE
); }
703 origin_spec opt_comma length_spec
706 { ldlex_script
(); ldfile_open_command_file
($2); }
707 memory_spec_list_opt END
708 { ldlex_popstate
(); }
712 ORIGIN
'=' mustbe_exp
714 region
->origin
= exp_get_vma
($3, 0, "origin");
715 region
->current
= region
->origin
;
720 LENGTH
'=' mustbe_exp
722 region
->length
= exp_get_vma
($3, -1, "length");
728 { /* dummy action to avoid bison 1.25 error message */ }
729 |
'(' attributes_list
')'
734 | attributes_list attributes_string
739 { lang_set_flags
(region
, $1, 0); }
741 { lang_set_flags
(region
, $2, 1); }
745 STARTUP
'(' filename
')'
746 { lang_startup
($3); }
750 HLL
'(' high_level_library_NAME_list
')'
752 { ldemul_hll
((char *)NULL
); }
755 high_level_library_NAME_list:
756 high_level_library_NAME_list opt_comma filename
764 SYSLIB
'(' low_level_library_NAME_list
')'
765 ; low_level_library_NAME_list
:
766 low_level_library_NAME_list opt_comma filename
767 { ldemul_syslib
($3); }
771 floating_point_support:
773 { lang_float
(TRUE
); }
775 { lang_float
(FALSE
); }
783 | NAME nocrossref_list
785 struct lang_nocrossref
*n
;
787 n
= (struct lang_nocrossref
*) xmalloc
(sizeof
*n
);
792 | NAME
',' nocrossref_list
794 struct lang_nocrossref
*n
;
796 n
= (struct lang_nocrossref
*) xmalloc
(sizeof
*n
);
803 mustbe_exp: { ldlex_expression
(); }
805 { ldlex_popstate
(); $$
=$2;}
810 { $$
= exp_unop
('-', $2); }
813 | NEXT
'(' exp
')' %prec UNARY
814 { $$
= exp_unop
((int) $1,$3); }
815 |
'!' exp %prec UNARY
816 { $$
= exp_unop
('!', $2); }
817 |
'+' exp %prec UNARY
819 |
'~' exp %prec UNARY
820 { $$
= exp_unop
('~', $2);}
823 { $$
= exp_binop
('*', $1, $3); }
825 { $$
= exp_binop
('/', $1, $3); }
827 { $$
= exp_binop
('%', $1, $3); }
829 { $$
= exp_binop
('+', $1, $3); }
831 { $$
= exp_binop
('-' , $1, $3); }
833 { $$
= exp_binop
(LSHIFT
, $1, $3); }
835 { $$
= exp_binop
(RSHIFT
, $1, $3); }
837 { $$
= exp_binop
(EQ
, $1, $3); }
839 { $$
= exp_binop
(NE
, $1, $3); }
841 { $$
= exp_binop
(LE
, $1, $3); }
843 { $$
= exp_binop
(GE
, $1, $3); }
845 { $$
= exp_binop
('<' , $1, $3); }
847 { $$
= exp_binop
('>' , $1, $3); }
849 { $$
= exp_binop
('&' , $1, $3); }
851 { $$
= exp_binop
('^' , $1, $3); }
853 { $$
= exp_binop
('|' , $1, $3); }
854 | exp
'?' exp
':' exp
855 { $$
= exp_trinop
('?' , $1, $3, $5); }
857 { $$
= exp_binop
(ANDAND
, $1, $3); }
859 { $$
= exp_binop
(OROR
, $1, $3); }
860 | DEFINED
'(' NAME
')'
861 { $$
= exp_nameop
(DEFINED
, $3); }
863 { $$
= exp_bigintop
($1.integer
, $1.str
); }
865 { $$
= exp_nameop
(SIZEOF_HEADERS
,0); }
867 | ALIGNOF
'(' NAME
')'
868 { $$
= exp_nameop
(ALIGNOF
,$3); }
869 | SIZEOF
'(' NAME
')'
870 { $$
= exp_nameop
(SIZEOF
,$3); }
872 { $$
= exp_nameop
(ADDR
,$3); }
873 | LOADADDR
'(' NAME
')'
874 { $$
= exp_nameop
(LOADADDR
,$3); }
875 | CONSTANT
'(' NAME
')'
876 { $$
= exp_nameop
(CONSTANT
,$3); }
877 | ABSOLUTE
'(' exp
')'
878 { $$
= exp_unop
(ABSOLUTE
, $3); }
879 | ALIGN_K
'(' exp
')'
880 { $$
= exp_unop
(ALIGN_K
,$3); }
881 | ALIGN_K
'(' exp
',' exp
')'
882 { $$
= exp_binop
(ALIGN_K
,$3,$5); }
883 | DATA_SEGMENT_ALIGN
'(' exp
',' exp
')'
884 { $$
= exp_binop
(DATA_SEGMENT_ALIGN
, $3, $5); }
885 | DATA_SEGMENT_RELRO_END
'(' exp
',' exp
')'
886 { $$
= exp_binop
(DATA_SEGMENT_RELRO_END
, $5, $3); }
887 | DATA_SEGMENT_END
'(' exp
')'
888 { $$
= exp_unop
(DATA_SEGMENT_END
, $3); }
889 | SEGMENT_START
'(' NAME
',' exp
')'
890 { /* The operands to the expression node are
891 placed in the opposite order from the way
892 in which they appear in the script as
893 that allows us to reuse more code in
895 $$
= exp_binop
(SEGMENT_START
,
897 exp_nameop
(NAME
, $3)); }
899 { $$
= exp_unop
(ALIGN_K
,$3); }
901 { $$
= exp_nameop
(NAME
,$1); }
902 | MAX_K
'(' exp
',' exp
')'
903 { $$
= exp_binop
(MAX_K
, $3, $5 ); }
904 | MIN_K
'(' exp
',' exp
')'
905 { $$
= exp_binop
(MIN_K
, $3, $5 ); }
906 | ASSERT_K
'(' exp
',' NAME
')'
907 { $$
= exp_assert
($3, $5); }
908 | ORIGIN
'(' NAME
')'
909 { $$
= exp_nameop
(ORIGIN
, $3); }
910 | LENGTH
'(' NAME
')'
911 { $$
= exp_nameop
(LENGTH
, $3); }
916 AT
'>' NAME
{ $$
= $3; }
921 AT
'(' exp
')' { $$
= $3; }
926 ALIGN_K
'(' exp
')' { $$
= $3; }
931 SUBALIGN
'(' exp
')' { $$
= $3; }
936 ONLY_IF_RO
{ $$
= ONLY_IF_RO
; }
937 | ONLY_IF_RW
{ $$
= ONLY_IF_RW
; }
938 | SPECIAL
{ $$
= SPECIAL
; }
942 section: NAME
{ ldlex_expression
(); }
946 opt_subalign
{ ldlex_popstate
(); ldlex_script
(); }
950 lang_enter_output_section_statement
($1, $3,
955 '}' { ldlex_popstate
(); ldlex_expression
(); }
956 memspec_opt memspec_at_opt phdr_opt fill_opt
959 lang_leave_output_section_statement
($17, $14, $16, $15);
964 { ldlex_expression
(); }
965 opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
966 { ldlex_popstate
(); ldlex_script
(); }
969 lang_enter_overlay
($3, $6);
973 { ldlex_popstate
(); ldlex_expression
(); }
974 memspec_opt memspec_at_opt phdr_opt fill_opt
977 lang_leave_overlay
($5, (int) $4,
981 |
/* The GROUP case is just enough to support the gcc
982 svr3.ifile script. It is not intended to be full
983 support. I'm not even sure what GROUP is supposed
985 GROUP
{ ldlex_expression
(); }
989 lang_add_assignment
(exp_assign
(".", $3));
991 '{' sec_or_group_p1
'}'
993 { ldlex_script
(); ldfile_open_command_file
($2); }
995 { ldlex_popstate
(); }
999 NOLOAD
{ sectype
= noload_section
; }
1000 | DSECT
{ sectype
= noalloc_section
; }
1001 | COPY
{ sectype
= noalloc_section
; }
1002 | INFO
{ sectype
= noalloc_section
; }
1003 | OVERLAY
{ sectype
= noalloc_section
; }
1008 |
/* EMPTY */ { sectype
= normal_section
; }
1009 |
'(' ')' { sectype
= normal_section
; }
1013 exp atype
':' { $$
= $1; }
1014 | atype
':' { $$
= (etree_type
*)NULL
; }
1015 |
/* The BIND cases are to support the gcc svr3.ifile
1016 script. They aren't intended to implement full
1017 support for the BIND keyword. I'm not even sure
1018 what BIND is supposed to mean. */
1019 BIND
'(' exp
')' atype
':' { $$
= $3; }
1020 | BIND
'(' exp
')' BLOCK
'(' exp
')' atype
':'
1024 opt_exp_without_type:
1025 exp
':' { $$
= $1; }
1026 |
':' { $$
= (etree_type
*) NULL
; }
1039 |
{ $$
= DEFAULT_MEMORY_REGION
; }
1049 struct lang_output_section_phdr_list
*n
;
1051 n
= ((struct lang_output_section_phdr_list
*)
1052 xmalloc
(sizeof
*n
));
1066 lang_enter_overlay_section
($2);
1068 '{' statement_list_opt
'}'
1069 { ldlex_popstate
(); ldlex_expression
(); }
1073 lang_leave_overlay_section
($9, $8);
1079 PHDRS
'{' phdr_list
'}'
1088 NAME
{ ldlex_expression
(); }
1089 phdr_type phdr_qualifiers
{ ldlex_popstate
(); }
1092 lang_new_phdr
($1, $3, $4.filehdr
, $4.phdrs
, $4.at
,
1102 if
($1->type.node_class
== etree_name
1103 && $1->type.node_code
== NAME
)
1107 static const char * const phdr_types
[] =
1109 "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
1110 "PT_INTERP", "PT_NOTE", "PT_SHLIB",
1116 i
< sizeof phdr_types
/ sizeof phdr_types
[0];
1118 if
(strcmp
(s
, phdr_types
[i
]) == 0)
1123 if
(i
== sizeof phdr_types
/ sizeof phdr_types
[0])
1125 if
(strcmp
(s
, "PT_GNU_EH_FRAME") == 0)
1126 $$
= exp_intop
(0x6474e550);
1127 else if
(strcmp
(s
, "PT_GNU_STACK") == 0)
1128 $$
= exp_intop
(0x6474e551);
1132 %X%P:%S: unknown phdr type `%s' (try integer literal)\n"),
1144 memset
(&$$
, 0, sizeof
(struct phdr_info
));
1146 | NAME phdr_val phdr_qualifiers
1149 if
(strcmp
($1, "FILEHDR") == 0 && $2 == NULL
)
1151 else if
(strcmp
($1, "PHDRS") == 0 && $2 == NULL
)
1153 else if
(strcmp
($1, "FLAGS") == 0 && $2 != NULL
)
1156 einfo
(_
("%X%P:%S: PHDRS syntax error at `%s'\n"), $1);
1158 | AT
'(' exp
')' phdr_qualifiers
1178 ldlex_version_file
();
1179 PUSH_ERROR
(_
("dynamic list"));
1190 | dynamic_list_nodes dynamic_list_node
1194 '{' dynamic_list_tag
'}' ';'
1200 lang_append_dynamic_list
($1);
1204 /* This syntax is used within an external version script file. */
1206 version_script_file:
1208 ldlex_version_file
();
1209 PUSH_ERROR
(_
("VERSION script"));
1218 /* This is used within a normal linker script file. */
1222 ldlex_version_script
();
1224 VERSIONK
'{' vers_nodes
'}'
1232 | vers_nodes vers_node
1236 '{' vers_tag
'}' ';'
1238 lang_register_vers_node
(NULL
, $2, NULL
);
1240 | VERS_TAG
'{' vers_tag
'}' ';'
1242 lang_register_vers_node
($1, $3, NULL
);
1244 | VERS_TAG
'{' vers_tag
'}' verdep
';'
1246 lang_register_vers_node
($1, $3, $5);
1253 $$
= lang_add_vers_depend
(NULL
, $1);
1257 $$
= lang_add_vers_depend
($1, $2);
1264 $$
= lang_new_vers_node
(NULL
, NULL
);
1268 $$
= lang_new_vers_node
($1, NULL
);
1270 | GLOBAL
':' vers_defns
';'
1272 $$
= lang_new_vers_node
($3, NULL
);
1274 | LOCAL
':' vers_defns
';'
1276 $$
= lang_new_vers_node
(NULL
, $3);
1278 | GLOBAL
':' vers_defns
';' LOCAL
':' vers_defns
';'
1280 $$
= lang_new_vers_node
($3, $7);
1287 $$
= lang_new_vers_pattern
(NULL
, $1, ldgram_vers_current_lang
, FALSE
);
1291 $$
= lang_new_vers_pattern
(NULL
, $1, ldgram_vers_current_lang
, TRUE
);
1293 | vers_defns
';' VERS_IDENTIFIER
1295 $$
= lang_new_vers_pattern
($1, $3, ldgram_vers_current_lang
, FALSE
);
1297 | vers_defns
';' NAME
1299 $$
= lang_new_vers_pattern
($1, $3, ldgram_vers_current_lang
, TRUE
);
1301 | vers_defns
';' EXTERN NAME
'{'
1303 $
<name
>$
= ldgram_vers_current_lang
;
1304 ldgram_vers_current_lang
= $4;
1306 vers_defns opt_semicolon
'}'
1308 struct bfd_elf_version_expr
*pat
;
1309 for
(pat
= $7; pat
->next
!= NULL
; pat
= pat
->next
);
1312 ldgram_vers_current_lang
= $
<name
>6;
1316 $
<name
>$
= ldgram_vers_current_lang
;
1317 ldgram_vers_current_lang
= $2;
1319 vers_defns opt_semicolon
'}'
1322 ldgram_vers_current_lang
= $
<name
>4;
1326 $$
= lang_new_vers_pattern
(NULL
, "global", ldgram_vers_current_lang
, FALSE
);
1328 | vers_defns
';' GLOBAL
1330 $$
= lang_new_vers_pattern
($1, "global", ldgram_vers_current_lang
, FALSE
);
1334 $$
= lang_new_vers_pattern
(NULL
, "local", ldgram_vers_current_lang
, FALSE
);
1336 | vers_defns
';' LOCAL
1338 $$
= lang_new_vers_pattern
($1, "local", ldgram_vers_current_lang
, FALSE
);
1342 $$
= lang_new_vers_pattern
(NULL
, "extern", ldgram_vers_current_lang
, FALSE
);
1344 | vers_defns
';' EXTERN
1346 $$
= lang_new_vers_pattern
($1, "extern", ldgram_vers_current_lang
, FALSE
);
1360 if
(ldfile_assumed_script
)
1361 einfo
(_
("%P:%s: file format not recognized; treating as linker script\n"),
1362 ldfile_input_filename
);
1363 if
(error_index
> 0 && error_index
< ERROR_NAME_MAX
)
1364 einfo
("%P%F:%S: %s in %s\n", arg
, error_names
[error_index
-1]);
1366 einfo
("%P%F:%S: %s\n", arg
);