1 /* A YACC grammar to parse a superset of the AT&T linker scripting language.
2 Copyright (C) 1991-2020 Free Software Foundation, Inc.
3 Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
5 This file is part of the GNU Binutils.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
27 #define DONTDECLARE_MALLOC
49 static enum section_type sectype
;
50 static lang_memory_region_type
*region
;
52 static bfd_boolean ldgram_had_keep
= FALSE
;
53 static char *ldgram_vers_current_lang
= NULL
;
55 #define ERROR_NAME_MAX 20
56 static char *error_names
[ERROR_NAME_MAX
];
57 static int error_index
;
58 #define PUSH_ERROR(x) if (error_index < ERROR_NAME_MAX) error_names[error_index] = x; error_index++;
59 #define POP_ERROR() error_index--;
71 struct wildcard_spec wildcard
;
72 struct wildcard_list
*wildcard_list
;
73 struct name_list
*name_list
;
74 struct flag_info_list
*flag_info_list
;
75 struct flag_info
*flag_info
;
77 union etree_union
*etree
;
82 union etree_union
*at
;
83 union etree_union
*flags
;
85 struct lang_nocrossref
*nocrossref
;
86 struct lang_output_section_phdr_list
*section_phdr
;
87 struct bfd_elf_version_deps
*deflist
;
88 struct bfd_elf_version_expr
*versyms
;
89 struct bfd_elf_version_tree
*versnode
;
92 %type
<etree
> exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val
93 %type
<etree
> opt_exp_without_type opt_subalign opt_align
94 %type
<fill
> fill_opt fill_exp
95 %type
<name_list
> exclude_name_list
96 %type
<wildcard_list
> section_name_list
97 %type
<flag_info_list
> sect_flag_list
98 %type
<flag_info
> sect_flags
99 %type
<name
> memspec_opt casesymlist
100 %type
<name
> memspec_at_opt
101 %type
<cname
> wildcard_name
102 %type
<wildcard
> section_name_spec filename_spec wildcard_maybe_exclude
104 %token
<name
> NAME LNAME
105 %type
<integer
> length
106 %type
<phdr
> phdr_qualifiers
107 %type
<nocrossref
> nocrossref_list
108 %type
<section_phdr
> phdr_opt
109 %type
<integer
> opt_nocrossrefs
111 %right
<token
> PLUSEQ MINUSEQ MULTEQ DIVEQ
'=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
112 %right
<token
> '?' ':'
119 %left
<token
> '<' '>' LE GE
120 %left
<token
> LSHIFT RSHIFT
122 %left
<token
> '+' '-'
123 %left
<token
> '*' '/' '%'
128 %token
<token
> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE
129 %token SECTIONS PHDRS INSERT_K AFTER BEFORE
130 %token DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END
131 %token SORT_BY_NAME SORT_BY_ALIGNMENT SORT_NONE
132 %token SORT_BY_INIT_PRIORITY
134 %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
135 %token INHIBIT_COMMON_ALLOCATION FORCE_GROUP_ALLOCATION
141 %token NOLOAD DSECT COPY INFO OVERLAY
142 %token DEFINED TARGET_K SEARCH_DIR MAP ENTRY
143 %token
<integer
> NEXT
144 %token SIZEOF ALIGNOF ADDR LOADADDR MAX_K MIN_K
145 %token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS NOCROSSREFS_TO
147 %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS
148 %token ALIGNMOD AT SUBALIGN HIDDEN PROVIDE PROVIDE_HIDDEN AS_NEEDED
149 %type
<token
> assign_op atype attributes_opt sect_constraint opt_align_with_input
150 %type
<name
> filename
151 %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K
152 %token LOG2CEIL FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL
153 %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START
154 %token
<name
> VERS_TAG VERS_IDENTIFIER
155 %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT
156 %token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL INPUT_SECTION_FLAGS ALIGN_WITH_INPUT
159 %type
<versyms
> vers_defns
160 %type
<versnode
> vers_tag
161 %type
<deflist
> verdep
162 %token INPUT_DYNAMIC_LIST
167 INPUT_SCRIPT script_file
168 | INPUT_MRI_SCRIPT mri_script_file
169 | INPUT_VERSION_SCRIPT version_script_file
170 | INPUT_DYNAMIC_LIST dynamic_list_file
171 | INPUT_DEFSYM defsym_expr
183 lang_add_assignment
(exp_defsym
($2, $4));
187 /* SYNTAX WITHIN AN MRI SCRIPT FILE */
191 PUSH_ERROR
(_
("MRI style script"));
202 mri_script_lines mri_script_command NEWLINE
210 einfo
(_
("%F%P: unrecognised keyword in MRI style script '%s'\n"),$1);
213 config.map_filename
= "-";
215 | ORDER ordernamelist
217 | PUBLIC NAME
'=' exp
218 { mri_public
($2, $4); }
219 | PUBLIC NAME
',' exp
220 { mri_public
($2, $4); }
222 { mri_public
($2, $3); }
226 { mri_output_section
($2, $4);}
228 { mri_output_section
($2, $3);}
230 { mri_output_section
($2, $4);}
231 | ALIGN_K NAME
'=' exp
232 { mri_align
($2,$4); }
233 | ALIGN_K NAME
',' exp
234 { mri_align
($2,$4); }
235 | ALIGNMOD NAME
'=' exp
236 { mri_alignmod
($2,$4); }
237 | ALIGNMOD NAME
',' exp
238 { mri_alignmod
($2,$4); }
239 | ABSOLUTE mri_abs_name_list
240 | LOAD mri_load_name_list
243 | ALIAS NAME
',' NAME
244 { mri_alias
($2,$4,0);}
246 { mri_alias
($2, 0, (int) $4.integer
); }
250 { mri_truncate
((unsigned int) $2.integer
); }
252 | EXTERN extern_name_list
254 { ldlex_script
(); ldfile_open_command_file
($2); }
256 { ldlex_popstate
(); }
258 { lang_add_entry
($2, FALSE
); }
263 ordernamelist
',' NAME
{ mri_order
($3); }
264 | ordernamelist NAME
{ mri_order
($2); }
271 | mri_load_name_list
',' NAME
{ mri_load
($3); }
276 { mri_only_load
($1); }
277 | mri_abs_name_list
',' NAME
278 { mri_only_load
($3); }
282 /* empty */ { $$
= NULL
; }
284 | casesymlist
',' NAME
287 /* Parsed as expressions so that commas separate entries */
289 { ldlex_expression
(); }
290 extern_name_list_body
291 { ldlex_popstate
(); }
293 extern_name_list_body:
295 { ldlang_add_undef
($1, FALSE
); }
296 | extern_name_list_body NAME
297 { ldlang_add_undef
($2, FALSE
); }
298 | extern_name_list_body
',' NAME
299 { ldlang_add_undef
($3, FALSE
); }
305 { ldlex_popstate
(); }
321 | floating_point_support
325 | TARGET_K
'(' NAME
')'
326 { lang_add_target
($3); }
327 | SEARCH_DIR
'(' filename
')'
328 { ldfile_add_library_path
($3, FALSE
); }
329 | OUTPUT
'(' filename
')'
330 { lang_add_output
($3, 1); }
331 | OUTPUT_FORMAT
'(' NAME
')'
332 { lang_add_output_format
($3, (char *) NULL
,
334 | OUTPUT_FORMAT
'(' NAME
',' NAME
',' NAME
')'
335 { lang_add_output_format
($3, $5, $7, 1); }
336 | OUTPUT_ARCH
'(' NAME
')'
337 { ldfile_set_output_arch
($3, bfd_arch_unknown
); }
338 | FORCE_COMMON_ALLOCATION
339 { command_line.force_common_definition
= TRUE
; }
340 | FORCE_GROUP_ALLOCATION
341 { command_line.force_group_allocation
= TRUE
; }
342 | INHIBIT_COMMON_ALLOCATION
343 { link_info.inhibit_common_definition
= TRUE
; }
344 | INPUT
'(' input_list
')'
346 { lang_enter_group
(); }
348 { lang_leave_group
(); }
349 | MAP
'(' filename
')'
350 { lang_add_map
($3); }
352 { ldlex_script
(); ldfile_open_command_file
($2); }
354 { ldlex_popstate
(); }
355 | NOCROSSREFS
'(' nocrossref_list
')'
357 lang_add_nocrossref
($3);
359 | NOCROSSREFS_TO
'(' nocrossref_list
')'
361 lang_add_nocrossref_to
($3);
363 | EXTERN
'(' extern_name_list
')'
364 | INSERT_K AFTER NAME
365 { lang_add_insert
($3, 0); }
366 | INSERT_K BEFORE NAME
367 { lang_add_insert
($3, 1); }
368 | REGION_ALIAS
'(' NAME
',' NAME
')'
369 { lang_memory_region_alias
($3, $5); }
370 | LD_FEATURE
'(' NAME
')'
371 { lang_ld_feature
($3); }
375 { ldlex_inputlist
(); }
377 { ldlex_popstate
(); }
381 { lang_add_input_file
($1,lang_input_file_is_search_file_enum
,
383 | input_list1
',' NAME
384 { lang_add_input_file
($3,lang_input_file_is_search_file_enum
,
387 { lang_add_input_file
($2,lang_input_file_is_search_file_enum
,
390 { lang_add_input_file
($1,lang_input_file_is_l_enum
,
392 | input_list1
',' LNAME
393 { lang_add_input_file
($3,lang_input_file_is_l_enum
,
396 { lang_add_input_file
($2,lang_input_file_is_l_enum
,
399 { $
<integer
>$
= input_flags.add_DT_NEEDED_for_regular
;
400 input_flags.add_DT_NEEDED_for_regular
= TRUE
; }
402 { input_flags.add_DT_NEEDED_for_regular
= $
<integer
>3; }
403 | input_list1
',' AS_NEEDED
'('
404 { $
<integer
>$
= input_flags.add_DT_NEEDED_for_regular
;
405 input_flags.add_DT_NEEDED_for_regular
= TRUE
; }
407 { input_flags.add_DT_NEEDED_for_regular
= $
<integer
>5; }
408 | input_list1 AS_NEEDED
'('
409 { $
<integer
>$
= input_flags.add_DT_NEEDED_for_regular
;
410 input_flags.add_DT_NEEDED_for_regular
= TRUE
; }
412 { input_flags.add_DT_NEEDED_for_regular
= $
<integer
>4; }
416 SECTIONS
'{' sec_or_group_p1
'}'
420 sec_or_group_p1 section
421 | sec_or_group_p1 statement_anywhere
427 { lang_add_entry
($3, FALSE
); }
429 | ASSERT_K
{ldlex_expression
();} '(' exp
',' NAME
')'
431 lang_add_assignment
(exp_assert
($4, $6)); }
434 /* The '*' and '?' cases are there because the lexer returns them as
435 separate tokens rather than as NAME. */
451 wildcard_maybe_exclude:
456 $$.exclude_name_list
= NULL
;
457 $$.section_flag_list
= NULL
;
459 | EXCLUDE_FILE
'(' exclude_name_list
')' wildcard_name
463 $$.exclude_name_list
= $3;
464 $$.section_flag_list
= NULL
;
469 wildcard_maybe_exclude
470 | SORT_BY_NAME
'(' wildcard_maybe_exclude
')'
475 | SORT_NONE
'(' wildcard_maybe_exclude
')'
483 wildcard_maybe_exclude
484 | SORT_BY_NAME
'(' wildcard_maybe_exclude
')'
489 | SORT_BY_ALIGNMENT
'(' wildcard_maybe_exclude
')'
492 $$.sorted
= by_alignment
;
494 | SORT_NONE
'(' wildcard_maybe_exclude
')'
499 | SORT_BY_NAME
'(' SORT_BY_ALIGNMENT
'(' wildcard_maybe_exclude
')' ')'
502 $$.sorted
= by_name_alignment
;
504 | SORT_BY_NAME
'(' SORT_BY_NAME
'(' wildcard_maybe_exclude
')' ')'
509 | SORT_BY_ALIGNMENT
'(' SORT_BY_NAME
'(' wildcard_maybe_exclude
')' ')'
512 $$.sorted
= by_alignment_name
;
514 | SORT_BY_ALIGNMENT
'(' SORT_BY_ALIGNMENT
'(' wildcard_maybe_exclude
')' ')'
517 $$.sorted
= by_alignment
;
519 | SORT_BY_INIT_PRIORITY
'(' wildcard_maybe_exclude
')'
522 $$.sorted
= by_init_priority
;
528 struct flag_info_list
*n
;
529 n
= ((struct flag_info_list
*) xmalloc
(sizeof
*n
));
532 n
->with
= without_flags
;
537 n
->with
= with_flags
;
544 | sect_flag_list
'&' NAME
546 struct flag_info_list
*n
;
547 n
= ((struct flag_info_list
*) xmalloc
(sizeof
*n
));
550 n
->with
= without_flags
;
555 n
->with
= with_flags
;
565 INPUT_SECTION_FLAGS
'(' sect_flag_list
')'
568 n
= ((struct flag_info
*) xmalloc
(sizeof
*n
));
570 n
->flags_initialized
= FALSE
;
571 n
->not_with_flags
= 0;
572 n
->only_with_flags
= 0;
578 exclude_name_list wildcard_name
580 struct name_list
*tmp
;
581 tmp
= (struct name_list
*) xmalloc
(sizeof
*tmp
);
589 struct name_list
*tmp
;
590 tmp
= (struct name_list
*) xmalloc
(sizeof
*tmp
);
598 section_name_list opt_comma section_name_spec
600 struct wildcard_list
*tmp
;
601 tmp
= (struct wildcard_list
*) xmalloc
(sizeof
*tmp
);
609 struct wildcard_list
*tmp
;
610 tmp
= (struct wildcard_list
*) xmalloc
(sizeof
*tmp
);
617 input_section_spec_no_keep:
620 struct wildcard_spec tmp
;
622 tmp.exclude_name_list
= NULL
;
624 tmp.section_flag_list
= NULL
;
625 lang_add_wild
(&tmp
, NULL
, ldgram_had_keep
);
629 struct wildcard_spec tmp
;
631 tmp.exclude_name_list
= NULL
;
633 tmp.section_flag_list
= $1;
634 lang_add_wild
(&tmp
, NULL
, ldgram_had_keep
);
636 |
'[' section_name_list
']'
638 lang_add_wild
(NULL
, $2, ldgram_had_keep
);
640 | sect_flags
'[' section_name_list
']'
642 struct wildcard_spec tmp
;
644 tmp.exclude_name_list
= NULL
;
646 tmp.section_flag_list
= $1;
647 lang_add_wild
(&tmp
, $3, ldgram_had_keep
);
649 | filename_spec
'(' section_name_list
')'
651 lang_add_wild
(&$1, $3, ldgram_had_keep
);
653 | sect_flags filename_spec
'(' section_name_list
')'
655 $2.section_flag_list
= $1;
656 lang_add_wild
(&$2, $4, ldgram_had_keep
);
661 input_section_spec_no_keep
663 { ldgram_had_keep
= TRUE
; }
664 input_section_spec_no_keep
')'
665 { ldgram_had_keep
= FALSE
; }
670 | CREATE_OBJECT_SYMBOLS
672 lang_add_attribute
(lang_object_symbols_statement_enum
);
678 lang_add_attribute
(lang_constructors_statement_enum
);
680 | SORT_BY_NAME
'(' CONSTRUCTORS
')'
682 constructors_sorted
= TRUE
;
683 lang_add_attribute
(lang_constructors_statement_enum
);
686 | length
'(' mustbe_exp
')'
688 lang_add_data
((int) $1, $3);
691 | FILL
'(' fill_exp
')'
695 | ASSERT_K
{ldlex_expression
();} '(' exp
',' NAME
')' end
697 lang_add_assignment
(exp_assert
($4, $6)); }
699 { ldlex_script
(); ldfile_open_command_file
($2); }
700 statement_list_opt END
701 { ldlex_popstate
(); }
705 statement_list statement
730 $$
= exp_get_fill
($1, 0, "fill value");
737 |
{ $$
= (fill_type
*) 0; }
767 lang_add_assignment
(exp_assign
($1, $3, FALSE
));
769 | NAME assign_op mustbe_exp
771 lang_add_assignment
(exp_assign
($1,
777 | HIDDEN
'(' NAME
'=' mustbe_exp
')'
779 lang_add_assignment
(exp_assign
($3, $5, TRUE
));
781 | PROVIDE
'(' NAME
'=' mustbe_exp
')'
783 lang_add_assignment
(exp_provide
($3, $5, FALSE
));
785 | PROVIDE_HIDDEN
'(' NAME
'=' mustbe_exp
')'
787 lang_add_assignment
(exp_provide
($3, $5, TRUE
));
797 MEMORY
'{' memory_spec_list_opt
'}'
800 memory_spec_list_opt: memory_spec_list |
;
803 memory_spec_list opt_comma memory_spec
809 { region
= lang_memory_region_lookup
($1, TRUE
); }
811 origin_spec opt_comma length_spec
814 { ldlex_script
(); ldfile_open_command_file
($2); }
815 memory_spec_list_opt END
816 { ldlex_popstate
(); }
820 ORIGIN
'=' mustbe_exp
822 region
->origin_exp
= $3;
827 LENGTH
'=' mustbe_exp
829 region
->length_exp
= $3;
835 { /* dummy action to avoid bison 1.25 error message */ }
836 |
'(' attributes_list
')'
841 | attributes_list attributes_string
846 { lang_set_flags
(region
, $1, 0); }
848 { lang_set_flags
(region
, $2, 1); }
852 STARTUP
'(' filename
')'
853 { lang_startup
($3); }
857 HLL
'(' high_level_library_NAME_list
')'
859 { ldemul_hll
((char *)NULL
); }
862 high_level_library_NAME_list:
863 high_level_library_NAME_list opt_comma filename
871 SYSLIB
'(' low_level_library_NAME_list
')'
872 ; low_level_library_NAME_list
:
873 low_level_library_NAME_list opt_comma filename
874 { ldemul_syslib
($3); }
878 floating_point_support:
880 { lang_float
(TRUE
); }
882 { lang_float
(FALSE
); }
890 | NAME nocrossref_list
892 struct lang_nocrossref
*n
;
894 n
= (struct lang_nocrossref
*) xmalloc
(sizeof
*n
);
899 | NAME
',' nocrossref_list
901 struct lang_nocrossref
*n
;
903 n
= (struct lang_nocrossref
*) xmalloc
(sizeof
*n
);
910 mustbe_exp: { ldlex_expression
(); }
912 { ldlex_popstate
(); $$
=$2;}
917 { $$
= exp_unop
('-', $2); }
920 | NEXT
'(' exp
')' %prec UNARY
921 { $$
= exp_unop
((int) $1,$3); }
922 |
'!' exp %prec UNARY
923 { $$
= exp_unop
('!', $2); }
924 |
'+' exp %prec UNARY
926 |
'~' exp %prec UNARY
927 { $$
= exp_unop
('~', $2);}
930 { $$
= exp_binop
('*', $1, $3); }
932 { $$
= exp_binop
('/', $1, $3); }
934 { $$
= exp_binop
('%', $1, $3); }
936 { $$
= exp_binop
('+', $1, $3); }
938 { $$
= exp_binop
('-' , $1, $3); }
940 { $$
= exp_binop
(LSHIFT
, $1, $3); }
942 { $$
= exp_binop
(RSHIFT
, $1, $3); }
944 { $$
= exp_binop
(EQ
, $1, $3); }
946 { $$
= exp_binop
(NE
, $1, $3); }
948 { $$
= exp_binop
(LE
, $1, $3); }
950 { $$
= exp_binop
(GE
, $1, $3); }
952 { $$
= exp_binop
('<' , $1, $3); }
954 { $$
= exp_binop
('>' , $1, $3); }
956 { $$
= exp_binop
('&' , $1, $3); }
958 { $$
= exp_binop
('^' , $1, $3); }
960 { $$
= exp_binop
('|' , $1, $3); }
961 | exp
'?' exp
':' exp
962 { $$
= exp_trinop
('?' , $1, $3, $5); }
964 { $$
= exp_binop
(ANDAND
, $1, $3); }
966 { $$
= exp_binop
(OROR
, $1, $3); }
967 | DEFINED
'(' NAME
')'
968 { $$
= exp_nameop
(DEFINED
, $3); }
970 { $$
= exp_bigintop
($1.integer
, $1.str
); }
972 { $$
= exp_nameop
(SIZEOF_HEADERS
,0); }
974 | ALIGNOF
'(' NAME
')'
975 { $$
= exp_nameop
(ALIGNOF
,$3); }
976 | SIZEOF
'(' NAME
')'
977 { $$
= exp_nameop
(SIZEOF
,$3); }
979 { $$
= exp_nameop
(ADDR
,$3); }
980 | LOADADDR
'(' NAME
')'
981 { $$
= exp_nameop
(LOADADDR
,$3); }
982 | CONSTANT
'(' NAME
')'
983 { $$
= exp_nameop
(CONSTANT
,$3); }
984 | ABSOLUTE
'(' exp
')'
985 { $$
= exp_unop
(ABSOLUTE
, $3); }
986 | ALIGN_K
'(' exp
')'
987 { $$
= exp_unop
(ALIGN_K
,$3); }
988 | ALIGN_K
'(' exp
',' exp
')'
989 { $$
= exp_binop
(ALIGN_K
,$3,$5); }
990 | DATA_SEGMENT_ALIGN
'(' exp
',' exp
')'
991 { $$
= exp_binop
(DATA_SEGMENT_ALIGN
, $3, $5); }
992 | DATA_SEGMENT_RELRO_END
'(' exp
',' exp
')'
993 { $$
= exp_binop
(DATA_SEGMENT_RELRO_END
, $5, $3); }
994 | DATA_SEGMENT_END
'(' exp
')'
995 { $$
= exp_unop
(DATA_SEGMENT_END
, $3); }
996 | SEGMENT_START
'(' NAME
',' exp
')'
997 { /* The operands to the expression node are
998 placed in the opposite order from the way
999 in which they appear in the script as
1000 that allows us to reuse more code in
1002 $$
= exp_binop
(SEGMENT_START
,
1004 exp_nameop
(NAME
, $3)); }
1006 { $$
= exp_unop
(ALIGN_K
,$3); }
1008 { $$
= exp_nameop
(NAME
,$1); }
1009 | MAX_K
'(' exp
',' exp
')'
1010 { $$
= exp_binop
(MAX_K
, $3, $5 ); }
1011 | MIN_K
'(' exp
',' exp
')'
1012 { $$
= exp_binop
(MIN_K
, $3, $5 ); }
1013 | ASSERT_K
'(' exp
',' NAME
')'
1014 { $$
= exp_assert
($3, $5); }
1015 | ORIGIN
'(' NAME
')'
1016 { $$
= exp_nameop
(ORIGIN
, $3); }
1017 | LENGTH
'(' NAME
')'
1018 { $$
= exp_nameop
(LENGTH
, $3); }
1019 | LOG2CEIL
'(' exp
')'
1020 { $$
= exp_unop
(LOG2CEIL
, $3); }
1025 AT
'>' NAME
{ $$
= $3; }
1030 AT
'(' exp
')' { $$
= $3; }
1035 ALIGN_K
'(' exp
')' { $$
= $3; }
1039 opt_align_with_input:
1040 ALIGN_WITH_INPUT
{ $$
= ALIGN_WITH_INPUT
; }
1045 SUBALIGN
'(' exp
')' { $$
= $3; }
1050 ONLY_IF_RO
{ $$
= ONLY_IF_RO
; }
1051 | ONLY_IF_RW
{ $$
= ONLY_IF_RW
; }
1052 | SPECIAL
{ $$
= SPECIAL
; }
1056 section: NAME
{ ldlex_expression
(); }
1060 opt_align_with_input
1061 opt_subalign
{ ldlex_popstate
(); ldlex_script
(); }
1065 lang_enter_output_section_statement
($1, $3,
1067 $5, $7, $4, $9, $6);
1070 '}' { ldlex_popstate
(); ldlex_expression
(); }
1071 memspec_opt memspec_at_opt phdr_opt fill_opt
1074 lang_leave_output_section_statement
($18, $15, $17, $16);
1079 { ldlex_expression
(); }
1080 opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
1081 { ldlex_popstate
(); ldlex_script
(); }
1084 lang_enter_overlay
($3, $6);
1088 { ldlex_popstate
(); ldlex_expression
(); }
1089 memspec_opt memspec_at_opt phdr_opt fill_opt
1092 lang_leave_overlay
($5, (int) $4,
1093 $16, $13, $15, $14);
1096 |
/* The GROUP case is just enough to support the gcc
1097 svr3.ifile script. It is not intended to be full
1098 support. I'm not even sure what GROUP is supposed
1100 GROUP
{ ldlex_expression
(); }
1104 lang_add_assignment
(exp_assign
(".", $3, FALSE
));
1106 '{' sec_or_group_p1
'}'
1108 { ldlex_script
(); ldfile_open_command_file
($2); }
1110 { ldlex_popstate
(); }
1114 NOLOAD
{ sectype
= noload_section
; }
1115 | DSECT
{ sectype
= noalloc_section
; }
1116 | COPY
{ sectype
= noalloc_section
; }
1117 | INFO
{ sectype
= noalloc_section
; }
1118 | OVERLAY
{ sectype
= noalloc_section
; }
1123 |
/* EMPTY */ { sectype
= normal_section
; }
1124 |
'(' ')' { sectype
= normal_section
; }
1128 exp atype
':' { $$
= $1; }
1129 | atype
':' { $$
= (etree_type
*)NULL
; }
1130 |
/* The BIND cases are to support the gcc svr3.ifile
1131 script. They aren't intended to implement full
1132 support for the BIND keyword. I'm not even sure
1133 what BIND is supposed to mean. */
1134 BIND
'(' exp
')' atype
':' { $$
= $3; }
1135 | BIND
'(' exp
')' BLOCK
'(' exp
')' atype
':'
1139 opt_exp_without_type:
1140 exp
':' { $$
= $1; }
1141 |
':' { $$
= (etree_type
*) NULL
; }
1154 |
{ $$
= DEFAULT_MEMORY_REGION
; }
1164 struct lang_output_section_phdr_list
*n
;
1166 n
= ((struct lang_output_section_phdr_list
*)
1167 xmalloc
(sizeof
*n
));
1181 lang_enter_overlay_section
($2);
1183 '{' statement_list_opt
'}'
1184 { ldlex_popstate
(); ldlex_expression
(); }
1188 lang_leave_overlay_section
($9, $8);
1194 PHDRS
'{' phdr_list
'}'
1203 NAME
{ ldlex_expression
(); }
1204 phdr_type phdr_qualifiers
{ ldlex_popstate
(); }
1207 lang_new_phdr
($1, $3, $4.filehdr
, $4.phdrs
, $4.at
,
1217 if
($1->type.node_class
== etree_name
1218 && $1->type.node_code
== NAME
)
1222 static const char * const phdr_types
[] =
1224 "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
1225 "PT_INTERP", "PT_NOTE", "PT_SHLIB",
1231 i
< sizeof phdr_types
/ sizeof phdr_types
[0];
1233 if
(strcmp
(s
, phdr_types
[i
]) == 0)
1238 if
(i
== sizeof phdr_types
/ sizeof phdr_types
[0])
1240 if
(strcmp
(s
, "PT_GNU_EH_FRAME") == 0)
1241 $$
= exp_intop
(0x6474e550);
1242 else if
(strcmp
(s
, "PT_GNU_STACK") == 0)
1243 $$
= exp_intop
(0x6474e551);
1247 %X%P:%pS: unknown phdr type `%s' (try integer literal)\n"),
1259 memset
(&$$
, 0, sizeof
(struct phdr_info
));
1261 | NAME phdr_val phdr_qualifiers
1264 if
(strcmp
($1, "FILEHDR") == 0 && $2 == NULL
)
1266 else if
(strcmp
($1, "PHDRS") == 0 && $2 == NULL
)
1268 else if
(strcmp
($1, "FLAGS") == 0 && $2 != NULL
)
1271 einfo
(_
("%X%P:%pS: PHDRS syntax error at `%s'\n"),
1274 | AT
'(' exp
')' phdr_qualifiers
1294 ldlex_version_file
();
1295 PUSH_ERROR
(_
("dynamic list"));
1306 | dynamic_list_nodes dynamic_list_node
1310 '{' dynamic_list_tag
'}' ';'
1316 lang_append_dynamic_list
(current_dynamic_list_p
, $1);
1320 /* This syntax is used within an external version script file. */
1322 version_script_file:
1324 ldlex_version_file
();
1325 PUSH_ERROR
(_
("VERSION script"));
1334 /* This is used within a normal linker script file. */
1338 ldlex_version_script
();
1340 VERSIONK
'{' vers_nodes
'}'
1348 | vers_nodes vers_node
1352 '{' vers_tag
'}' ';'
1354 lang_register_vers_node
(NULL
, $2, NULL
);
1356 | VERS_TAG
'{' vers_tag
'}' ';'
1358 lang_register_vers_node
($1, $3, NULL
);
1360 | VERS_TAG
'{' vers_tag
'}' verdep
';'
1362 lang_register_vers_node
($1, $3, $5);
1369 $$
= lang_add_vers_depend
(NULL
, $1);
1373 $$
= lang_add_vers_depend
($1, $2);
1380 $$
= lang_new_vers_node
(NULL
, NULL
);
1384 $$
= lang_new_vers_node
($1, NULL
);
1386 | GLOBAL
':' vers_defns
';'
1388 $$
= lang_new_vers_node
($3, NULL
);
1390 | LOCAL
':' vers_defns
';'
1392 $$
= lang_new_vers_node
(NULL
, $3);
1394 | GLOBAL
':' vers_defns
';' LOCAL
':' vers_defns
';'
1396 $$
= lang_new_vers_node
($3, $7);
1403 $$
= lang_new_vers_pattern
(NULL
, $1, ldgram_vers_current_lang
, FALSE
);
1407 $$
= lang_new_vers_pattern
(NULL
, $1, ldgram_vers_current_lang
, TRUE
);
1409 | vers_defns
';' VERS_IDENTIFIER
1411 $$
= lang_new_vers_pattern
($1, $3, ldgram_vers_current_lang
, FALSE
);
1413 | vers_defns
';' NAME
1415 $$
= lang_new_vers_pattern
($1, $3, ldgram_vers_current_lang
, TRUE
);
1417 | vers_defns
';' EXTERN NAME
'{'
1419 $
<name
>$
= ldgram_vers_current_lang
;
1420 ldgram_vers_current_lang
= $4;
1422 vers_defns opt_semicolon
'}'
1424 struct bfd_elf_version_expr
*pat
;
1425 for
(pat
= $7; pat
->next
!= NULL
; pat
= pat
->next
);
1428 ldgram_vers_current_lang
= $
<name
>6;
1432 $
<name
>$
= ldgram_vers_current_lang
;
1433 ldgram_vers_current_lang
= $2;
1435 vers_defns opt_semicolon
'}'
1438 ldgram_vers_current_lang
= $
<name
>4;
1442 $$
= lang_new_vers_pattern
(NULL
, "global", ldgram_vers_current_lang
, FALSE
);
1444 | vers_defns
';' GLOBAL
1446 $$
= lang_new_vers_pattern
($1, "global", ldgram_vers_current_lang
, FALSE
);
1450 $$
= lang_new_vers_pattern
(NULL
, "local", ldgram_vers_current_lang
, FALSE
);
1452 | vers_defns
';' LOCAL
1454 $$
= lang_new_vers_pattern
($1, "local", ldgram_vers_current_lang
, FALSE
);
1458 $$
= lang_new_vers_pattern
(NULL
, "extern", ldgram_vers_current_lang
, FALSE
);
1460 | vers_defns
';' EXTERN
1462 $$
= lang_new_vers_pattern
($1, "extern", ldgram_vers_current_lang
, FALSE
);
1476 if
(ldfile_assumed_script
)
1477 einfo
(_
("%P:%s: file format not recognized; treating as linker script\n"),
1479 if
(error_index
> 0 && error_index
< ERROR_NAME_MAX
)
1480 einfo
("%F%P:%pS: %s in %s\n", NULL
, arg
, error_names
[error_index
- 1]);
1482 einfo
("%F%P:%pS: %s\n", NULL
, arg
);