1 /* A YACC grammar to parse a superset of the AT&T linker scripting language.
2 Copyright (C) 1991-2023 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 etree_type
*sectype_value
;
51 static lang_memory_region_type
*region
;
53 static bool ldgram_had_keep
= false
;
54 static 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
;
75 struct flag_info_list
*flag_info_list
;
76 struct flag_info
*flag_info
;
78 union etree_union
*etree
;
83 union etree_union
*at
;
84 union etree_union
*flags
;
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
;
93 %type
<etree
> exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val
94 %type
<etree
> opt_exp_without_type opt_subalign opt_align
95 %type
<fill
> fill_opt fill_exp
96 %type
<name_list
> exclude_name_list
97 %type
<wildcard_list
> section_name_list
98 %type
<flag_info_list
> sect_flag_list
99 %type
<flag_info
> sect_flags
100 %type
<name
> memspec_opt memspec_at_opt paren_script_name casesymlist
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 ASCIZ
129 %token SECTIONS PHDRS INSERT_K AFTER BEFORE LINKER_VERSION
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
144 %token DEFINED TARGET_K SEARCH_DIR MAP ENTRY
145 %token
<integer
> NEXT
146 %token SIZEOF ALIGNOF ADDR LOADADDR MAX_K MIN_K
147 %token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS NOCROSSREFS_TO
149 %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS
150 %token ALIGNMOD AT SUBALIGN HIDDEN PROVIDE PROVIDE_HIDDEN AS_NEEDED
151 %type
<token
> assign_op atype attributes_opt sect_constraint opt_align_with_input
152 %type
<name
> filename
153 %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K
154 %token LOG2CEIL FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL
155 %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START
156 %token
<name
> VERS_TAG VERS_IDENTIFIER
157 %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT
158 %token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL INPUT_SECTION_FLAGS ALIGN_WITH_INPUT
161 %type
<versyms
> vers_defns
162 %type
<versnode
> vers_tag
163 %type
<deflist
> verdep
164 %token INPUT_DYNAMIC_LIST
169 INPUT_SCRIPT script_file
170 | INPUT_MRI_SCRIPT mri_script_file
171 | INPUT_VERSION_SCRIPT version_script_file
172 | INPUT_DYNAMIC_LIST dynamic_list_file
173 | INPUT_DEFSYM defsym_expr
181 { ldlex_expression
(); }
183 { ldlex_popstate
(); }
186 /* SYNTAX WITHIN AN MRI SCRIPT FILE */
190 PUSH_ERROR
(_
("MRI style script"));
201 mri_script_lines mri_script_command NEWLINE
209 einfo
(_
("%F%P: unrecognised keyword in MRI style script '%s'\n"),$1);
212 config.map_filename
= "-";
214 | ORDER ordernamelist
216 | PUBLIC NAME
'=' exp
217 { mri_public
($2, $4); }
218 | PUBLIC NAME
',' exp
219 { mri_public
($2, $4); }
221 { mri_public
($2, $3); }
225 { mri_output_section
($2, $4);}
227 { mri_output_section
($2, $3);}
229 { mri_output_section
($2, $4);}
230 | ALIGN_K NAME
'=' exp
231 { mri_align
($2,$4); }
232 | ALIGN_K NAME
',' exp
233 { mri_align
($2,$4); }
234 | ALIGNMOD NAME
'=' exp
235 { mri_alignmod
($2,$4); }
236 | ALIGNMOD NAME
',' exp
237 { mri_alignmod
($2,$4); }
238 | ABSOLUTE mri_abs_name_list
239 | LOAD mri_load_name_list
242 | ALIAS NAME
',' NAME
243 { mri_alias
($2,$4,0);}
245 { mri_alias
($2, 0, (int) $4.integer
); }
249 { mri_truncate
((unsigned int) $2.integer
); }
251 | EXTERN extern_name_list
253 { ldfile_open_command_file
($2); }
256 { lang_add_entry
($2, false
); }
261 ordernamelist
',' NAME
{ mri_order
($3); }
262 | ordernamelist NAME
{ mri_order
($2); }
269 | mri_load_name_list
',' NAME
{ mri_load
($3); }
274 { mri_only_load
($1); }
275 | mri_abs_name_list
',' NAME
276 { mri_only_load
($3); }
280 /* empty */ { $$
= NULL
; }
282 | casesymlist
',' NAME
287 { ldlang_add_undef
($1, false
); }
288 | extern_name_list NAME
289 { ldlang_add_undef
($2, false
); }
290 | extern_name_list
',' NAME
291 { ldlang_add_undef
($3, false
); }
297 { ldlex_popstate
(); }
313 | floating_point_support
317 | TARGET_K
'(' NAME
')'
318 { lang_add_target
($3); }
319 | SEARCH_DIR
'(' filename
')'
320 { ldfile_add_library_path
($3, false
); }
321 | OUTPUT
'(' filename
')'
322 { lang_add_output
($3, 1); }
323 | OUTPUT_FORMAT
'(' NAME
')'
324 { lang_add_output_format
($3, (char *) NULL
,
326 | OUTPUT_FORMAT
'(' NAME
',' NAME
',' NAME
')'
327 { lang_add_output_format
($3, $5, $7, 1); }
328 | OUTPUT_ARCH
'(' NAME
')'
329 { ldfile_set_output_arch
($3, bfd_arch_unknown
); }
330 | FORCE_COMMON_ALLOCATION
331 { command_line.force_common_definition
= true
; }
332 | FORCE_GROUP_ALLOCATION
333 { command_line.force_group_allocation
= true
; }
334 | INHIBIT_COMMON_ALLOCATION
335 { link_info.inhibit_common_definition
= true
; }
336 | INPUT
'(' input_list
')'
338 { lang_enter_group
(); }
340 { lang_leave_group
(); }
341 | MAP
'(' filename
')'
342 { lang_add_map
($3); }
344 { ldfile_open_command_file
($2); }
346 | NOCROSSREFS
'(' nocrossref_list
')'
348 lang_add_nocrossref
($3);
350 | NOCROSSREFS_TO
'(' nocrossref_list
')'
352 lang_add_nocrossref_to
($3);
354 | EXTERN
'(' { ldlex_expression
(); } extern_name_list
')'
355 { ldlex_popstate
(); }
356 | INSERT_K AFTER NAME
357 { lang_add_insert
($3, 0); }
358 | INSERT_K BEFORE NAME
359 { lang_add_insert
($3, 1); }
360 | REGION_ALIAS
'(' NAME
',' NAME
')'
361 { lang_memory_region_alias
($3, $5); }
362 | LD_FEATURE
'(' NAME
')'
363 { lang_ld_feature
($3); }
367 { ldlex_inputlist
(); }
369 { ldlex_popstate
(); }
373 { lang_add_input_file
($1,lang_input_file_is_search_file_enum
,
375 | input_list1
',' NAME
376 { lang_add_input_file
($3,lang_input_file_is_search_file_enum
,
379 { lang_add_input_file
($2,lang_input_file_is_search_file_enum
,
382 { lang_add_input_file
($1,lang_input_file_is_l_enum
,
384 | input_list1
',' LNAME
385 { lang_add_input_file
($3,lang_input_file_is_l_enum
,
388 { lang_add_input_file
($2,lang_input_file_is_l_enum
,
391 { $
<integer
>$
= input_flags.add_DT_NEEDED_for_regular
;
392 input_flags.add_DT_NEEDED_for_regular
= true
; }
394 { input_flags.add_DT_NEEDED_for_regular
= $
<integer
>3; }
395 | input_list1
',' AS_NEEDED
'('
396 { $
<integer
>$
= input_flags.add_DT_NEEDED_for_regular
;
397 input_flags.add_DT_NEEDED_for_regular
= true
; }
399 { input_flags.add_DT_NEEDED_for_regular
= $
<integer
>5; }
400 | input_list1 AS_NEEDED
'('
401 { $
<integer
>$
= input_flags.add_DT_NEEDED_for_regular
;
402 input_flags.add_DT_NEEDED_for_regular
= true
; }
404 { input_flags.add_DT_NEEDED_for_regular
= $
<integer
>4; }
408 SECTIONS
'{' sec_or_group_p1
'}'
412 sec_or_group_p1 section
413 | sec_or_group_p1 statement_anywhere
419 { lang_add_entry
($3, false
); }
420 | assignment separator
421 | ASSERT_K
{ldlex_expression
();} '(' exp
',' NAME
')'
423 lang_add_assignment
(exp_assert
($4, $6)); }
433 wildcard_maybe_exclude:
438 $$.exclude_name_list
= NULL
;
439 $$.section_flag_list
= NULL
;
441 | EXCLUDE_FILE
'(' exclude_name_list
')' wildcard_name
445 $$.exclude_name_list
= $3;
446 $$.section_flag_list
= NULL
;
451 wildcard_maybe_exclude
452 | SORT_BY_NAME
'(' wildcard_maybe_exclude
')'
457 | SORT_NONE
'(' wildcard_maybe_exclude
')'
465 wildcard_maybe_exclude
466 | SORT_BY_NAME
'(' wildcard_maybe_exclude
')'
471 | SORT_BY_ALIGNMENT
'(' wildcard_maybe_exclude
')'
474 $$.sorted
= by_alignment
;
476 | SORT_NONE
'(' wildcard_maybe_exclude
')'
481 | SORT_BY_NAME
'(' SORT_BY_ALIGNMENT
'(' wildcard_maybe_exclude
')' ')'
484 $$.sorted
= by_name_alignment
;
486 | SORT_BY_NAME
'(' SORT_BY_NAME
'(' wildcard_maybe_exclude
')' ')'
491 | SORT_BY_ALIGNMENT
'(' SORT_BY_NAME
'(' wildcard_maybe_exclude
')' ')'
494 $$.sorted
= by_alignment_name
;
496 | SORT_BY_ALIGNMENT
'(' SORT_BY_ALIGNMENT
'(' wildcard_maybe_exclude
')' ')'
499 $$.sorted
= by_alignment
;
501 | SORT_BY_INIT_PRIORITY
'(' wildcard_maybe_exclude
')'
504 $$.sorted
= by_init_priority
;
510 struct flag_info_list
*n
;
511 n
= ((struct flag_info_list
*) xmalloc
(sizeof
*n
));
514 n
->with
= without_flags
;
519 n
->with
= with_flags
;
526 | sect_flag_list
'&' NAME
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
;
547 INPUT_SECTION_FLAGS
'(' sect_flag_list
')'
550 n
= ((struct flag_info
*) xmalloc
(sizeof
*n
));
552 n
->flags_initialized
= false
;
553 n
->not_with_flags
= 0;
554 n
->only_with_flags
= 0;
560 exclude_name_list wildcard_name
562 struct name_list
*tmp
;
563 tmp
= (struct name_list
*) xmalloc
(sizeof
*tmp
);
571 struct name_list
*tmp
;
572 tmp
= (struct name_list
*) xmalloc
(sizeof
*tmp
);
580 section_name_list opt_comma section_name_spec
582 struct wildcard_list
*tmp
;
583 tmp
= (struct wildcard_list
*) xmalloc
(sizeof
*tmp
);
591 struct wildcard_list
*tmp
;
592 tmp
= (struct wildcard_list
*) xmalloc
(sizeof
*tmp
);
599 input_section_spec_no_keep:
602 struct wildcard_spec tmp
;
604 tmp.exclude_name_list
= NULL
;
606 tmp.section_flag_list
= NULL
;
607 lang_add_wild
(&tmp
, NULL
, ldgram_had_keep
);
611 struct wildcard_spec tmp
;
613 tmp.exclude_name_list
= NULL
;
615 tmp.section_flag_list
= $1;
616 lang_add_wild
(&tmp
, NULL
, ldgram_had_keep
);
618 |
'[' section_name_list
']'
620 lang_add_wild
(NULL
, $2, ldgram_had_keep
);
622 | sect_flags
'[' section_name_list
']'
624 struct wildcard_spec tmp
;
626 tmp.exclude_name_list
= NULL
;
628 tmp.section_flag_list
= $1;
629 lang_add_wild
(&tmp
, $3, ldgram_had_keep
);
631 | filename_spec
'(' section_name_list
')'
633 lang_add_wild
(&$1, $3, ldgram_had_keep
);
635 | sect_flags filename_spec
'(' section_name_list
')'
637 $2.section_flag_list
= $1;
638 lang_add_wild
(&$2, $4, ldgram_had_keep
);
643 input_section_spec_no_keep
645 { ldgram_had_keep
= true
; }
646 input_section_spec_no_keep
')'
647 { ldgram_had_keep
= false
; }
652 | assignment separator
653 | CREATE_OBJECT_SYMBOLS
655 lang_add_attribute
(lang_object_symbols_statement_enum
);
659 lang_add_attribute
(lang_constructors_statement_enum
);
661 | SORT_BY_NAME
'(' CONSTRUCTORS
')'
663 constructors_sorted
= true
;
664 lang_add_attribute
(lang_constructors_statement_enum
);
667 | length
'(' mustbe_exp
')'
669 lang_add_data
((int) $1, $3);
673 lang_add_string
($2);
675 | FILL
'(' fill_exp
')'
681 lang_add_version_string
();
684 { ldlex_expression
(); }
685 '(' exp
',' NAME
')' separator
688 lang_add_assignment
(exp_assert
($4, $6));
692 ldfile_open_command_file
($2);
694 statement_list_opt END
698 statement_list statement
723 $$
= exp_get_fill
($1, 0, _
("fill value"));
730 |
{ $$
= (fill_type
*) 0; }
760 lang_add_assignment
(exp_assign
($1, $3, false
));
762 | NAME assign_op mustbe_exp
764 lang_add_assignment
(exp_assign
($1,
770 | HIDDEN
'(' NAME
'=' mustbe_exp
')'
772 lang_add_assignment
(exp_assign
($3, $5, true
));
774 | PROVIDE
'(' NAME
'=' mustbe_exp
')'
776 lang_add_assignment
(exp_provide
($3, $5, false
));
778 | PROVIDE_HIDDEN
'(' NAME
'=' mustbe_exp
')'
780 lang_add_assignment
(exp_provide
($3, $5, true
));
790 MEMORY
'{' memory_spec_list_opt
'}'
793 memory_spec_list_opt: memory_spec_list |
;
796 memory_spec_list opt_comma memory_spec
802 { region
= lang_memory_region_lookup
($1, true
); }
804 origin_spec opt_comma length_spec
807 { ldfile_open_command_file
($2); }
808 memory_spec_list_opt END
812 ORIGIN
'=' mustbe_exp
814 region
->origin_exp
= $3;
819 LENGTH
'=' mustbe_exp
826 region
->length_exp
= $3;
832 { /* dummy action to avoid bison 1.25 error message */ }
833 |
'(' attributes_list
')'
838 | attributes_list attributes_string
843 { lang_set_flags
(region
, $1, 0); }
845 { lang_set_flags
(region
, $2, 1); }
849 STARTUP
'(' filename
')'
850 { lang_startup
($3); }
854 HLL
'(' high_level_library_NAME_list
')'
856 { ldemul_hll
((char *)NULL
); }
859 high_level_library_NAME_list:
860 high_level_library_NAME_list opt_comma filename
867 SYSLIB
'(' low_level_library_NAME_list
')'
870 low_level_library_NAME_list:
871 low_level_library_NAME_list opt_comma filename
872 { ldemul_syslib
($3); }
876 floating_point_support:
878 { lang_float
(true
); }
880 { lang_float
(false
); }
888 | NAME nocrossref_list
890 struct lang_nocrossref
*n
;
892 n
= (struct lang_nocrossref
*) xmalloc
(sizeof
*n
);
897 | NAME
',' nocrossref_list
899 struct lang_nocrossref
*n
;
901 n
= (struct lang_nocrossref
*) xmalloc
(sizeof
*n
);
908 paren_script_name: { ldlex_script
(); }
910 { ldlex_popstate
(); $$
= $3; }
912 mustbe_exp: { ldlex_expression
(); }
914 { ldlex_popstate
(); $$
= $2; }
919 { $$
= exp_unop
('-', $2); }
922 | NEXT
'(' exp
')' %prec UNARY
923 { $$
= exp_unop
((int) $1,$3); }
924 |
'!' exp %prec UNARY
925 { $$
= exp_unop
('!', $2); }
926 |
'+' exp %prec UNARY
928 |
'~' exp %prec UNARY
929 { $$
= exp_unop
('~', $2);}
932 { $$
= exp_binop
('*', $1, $3); }
934 { $$
= exp_binop
('/', $1, $3); }
936 { $$
= exp_binop
('%', $1, $3); }
938 { $$
= exp_binop
('+', $1, $3); }
940 { $$
= exp_binop
('-' , $1, $3); }
942 { $$
= exp_binop
(LSHIFT
, $1, $3); }
944 { $$
= exp_binop
(RSHIFT
, $1, $3); }
946 { $$
= exp_binop
(EQ
, $1, $3); }
948 { $$
= exp_binop
(NE
, $1, $3); }
950 { $$
= exp_binop
(LE
, $1, $3); }
952 { $$
= exp_binop
(GE
, $1, $3); }
954 { $$
= exp_binop
('<' , $1, $3); }
956 { $$
= exp_binop
('>' , $1, $3); }
958 { $$
= exp_binop
('&' , $1, $3); }
960 { $$
= exp_binop
('^' , $1, $3); }
962 { $$
= exp_binop
('|' , $1, $3); }
963 | exp
'?' exp
':' exp
964 { $$
= exp_trinop
('?' , $1, $3, $5); }
966 { $$
= exp_binop
(ANDAND
, $1, $3); }
968 { $$
= exp_binop
(OROR
, $1, $3); }
969 | DEFINED
'(' NAME
')'
970 { $$
= exp_nameop
(DEFINED
, $3); }
972 { $$
= exp_bigintop
($1.integer
, $1.str
); }
974 { $$
= exp_nameop
(SIZEOF_HEADERS
,0); }
976 | ALIGNOF paren_script_name
977 { $$
= exp_nameop
(ALIGNOF
, $2); }
978 | SIZEOF paren_script_name
979 { $$
= exp_nameop
(SIZEOF
, $2); }
980 | ADDR paren_script_name
981 { $$
= exp_nameop
(ADDR
, $2); }
982 | LOADADDR paren_script_name
983 { $$
= exp_nameop
(LOADADDR
, $2); }
984 | CONSTANT
'(' NAME
')'
985 { $$
= exp_nameop
(CONSTANT
,$3); }
986 | ABSOLUTE
'(' exp
')'
987 { $$
= exp_unop
(ABSOLUTE
, $3); }
988 | ALIGN_K
'(' exp
')'
989 { $$
= exp_unop
(ALIGN_K
,$3); }
990 | ALIGN_K
'(' exp
',' exp
')'
991 { $$
= exp_binop
(ALIGN_K
,$3,$5); }
992 | DATA_SEGMENT_ALIGN
'(' exp
',' exp
')'
993 { $$
= exp_binop
(DATA_SEGMENT_ALIGN
, $3, $5); }
994 | DATA_SEGMENT_RELRO_END
'(' exp
',' exp
')'
995 { $$
= exp_binop
(DATA_SEGMENT_RELRO_END
, $5, $3); }
996 | DATA_SEGMENT_END
'(' exp
')'
997 { $$
= exp_unop
(DATA_SEGMENT_END
, $3); }
998 | SEGMENT_START
{ ldlex_script
(); } '(' NAME
999 { ldlex_popstate
(); } ',' exp
')'
1000 { /* The operands to the expression node are
1001 placed in the opposite order from the way
1002 in which they appear in the script as
1003 that allows us to reuse more code in
1005 $$
= exp_binop
(SEGMENT_START
,
1007 exp_nameop
(NAME
, $4)); }
1009 { $$
= exp_unop
(ALIGN_K
,$3); }
1011 { $$
= exp_nameop
(NAME
,$1); }
1012 | MAX_K
'(' exp
',' exp
')'
1013 { $$
= exp_binop
(MAX_K
, $3, $5 ); }
1014 | MIN_K
'(' exp
',' exp
')'
1015 { $$
= exp_binop
(MIN_K
, $3, $5 ); }
1016 | ASSERT_K
'(' exp
',' NAME
')'
1017 { $$
= exp_assert
($3, $5); }
1018 | ORIGIN paren_script_name
1019 { $$
= exp_nameop
(ORIGIN
, $2); }
1020 | LENGTH paren_script_name
1021 { $$
= exp_nameop
(LENGTH
, $2); }
1022 | LOG2CEIL
'(' exp
')'
1023 { $$
= exp_unop
(LOG2CEIL
, $3); }
1028 AT
'>' NAME
{ $$
= $3; }
1033 AT
'(' exp
')' { $$
= $3; }
1038 ALIGN_K
'(' exp
')' { $$
= $3; }
1042 opt_align_with_input:
1043 ALIGN_WITH_INPUT
{ $$
= ALIGN_WITH_INPUT
; }
1048 SUBALIGN
'(' exp
')' { $$
= $3; }
1053 ONLY_IF_RO
{ $$
= ONLY_IF_RO
; }
1054 | ONLY_IF_RW
{ $$
= ONLY_IF_RW
; }
1055 | SPECIAL
{ $$
= SPECIAL
; }
1060 { ldlex_expression
(); }
1064 opt_align_with_input
1070 lang_enter_output_section_statement
($1, $3, sectype
,
1071 sectype_value
, $5, $7, $4, $8, $6);
1076 { ldlex_popstate
(); }
1077 memspec_opt memspec_at_opt phdr_opt fill_opt
1079 /* fill_opt may have switched the lexer into
1080 expression state, and back again, but in
1081 order to find the end of the fill
1082 expression the parser must look ahead one
1083 token. If it is a NAME, throw it away as
1084 it will have been lexed in the wrong
1091 lang_leave_output_section_statement
($17, $14,
1096 { ldlex_expression
(); }
1097 opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
1098 { ldlex_popstate
(); }
1101 lang_enter_overlay
($3, $6);
1105 memspec_opt memspec_at_opt phdr_opt fill_opt
1112 lang_leave_overlay
($5, (int) $4,
1113 $15, $12, $14, $13);
1116 |
/* The GROUP case is just enough to support the gcc
1117 svr3.ifile script. It is not intended to be full
1118 support. I'm not even sure what GROUP is supposed
1121 { ldlex_expression
(); }
1125 lang_add_assignment
(exp_assign
(".", $3, false
));
1127 '{' sec_or_group_p1
'}'
1130 ldfile_open_command_file
($2);
1136 NOLOAD
{ sectype
= noload_section
; }
1137 | DSECT
{ sectype
= noalloc_section
; }
1138 | COPY
{ sectype
= noalloc_section
; }
1139 | INFO
{ sectype
= noalloc_section
; }
1140 | OVERLAY
{ sectype
= noalloc_section
; }
1141 | READONLY
'(' TYPE
'=' exp
')' { sectype
= typed_readonly_section
; sectype_value
= $5; }
1142 | READONLY
{ sectype
= readonly_section
; }
1143 | TYPE
'=' exp
{ sectype
= type_section
; sectype_value
= $3; }
1148 |
/* EMPTY */ { sectype
= normal_section
; }
1149 |
'(' ')' { sectype
= normal_section
; }
1153 exp atype
':' { $$
= $1; }
1154 | atype
':' { $$
= (etree_type
*)NULL
; }
1155 |
/* The BIND cases are to support the gcc svr3.ifile
1156 script. They aren't intended to implement full
1157 support for the BIND keyword. I'm not even sure
1158 what BIND is supposed to mean. */
1159 BIND
'(' exp
')' atype
':' { $$
= $3; }
1160 | BIND
'(' exp
')' BLOCK
'(' exp
')' atype
':'
1164 opt_exp_without_type:
1165 exp
':' { $$
= $1; }
1166 |
':' { $$
= (etree_type
*) NULL
; }
1179 |
{ $$
= DEFAULT_MEMORY_REGION
; }
1189 struct lang_output_section_phdr_list
*n
;
1191 n
= ((struct lang_output_section_phdr_list
*)
1192 xmalloc
(sizeof
*n
));
1206 lang_enter_overlay_section
($2);
1211 { ldlex_popstate
(); }
1219 lang_leave_overlay_section
($9, $8);
1225 PHDRS
'{' phdr_list
'}'
1234 NAME
{ ldlex_expression
(); }
1235 phdr_type phdr_qualifiers
{ ldlex_popstate
(); }
1238 lang_new_phdr
($1, $3, $4.filehdr
, $4.phdrs
, $4.at
,
1248 if
($1->type.node_class
== etree_name
1249 && $1->type.node_code
== NAME
)
1253 static const char * const phdr_types
[] =
1255 "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
1256 "PT_INTERP", "PT_NOTE", "PT_SHLIB",
1262 i
< sizeof phdr_types
/ sizeof phdr_types
[0];
1264 if
(strcmp
(s
, phdr_types
[i
]) == 0)
1269 if
(i
== sizeof phdr_types
/ sizeof phdr_types
[0])
1271 if
(strcmp
(s
, "PT_GNU_EH_FRAME") == 0)
1272 $$
= exp_intop
(0x6474e550);
1273 else if
(strcmp
(s
, "PT_GNU_STACK") == 0)
1274 $$
= exp_intop
(0x6474e551);
1275 else if
(strcmp
(s
, "PT_GNU_RELRO") == 0)
1276 $$
= exp_intop
(0x6474e552);
1277 else if
(strcmp
(s
, "PT_GNU_PROPERTY") == 0)
1278 $$
= exp_intop
(0x6474e553);
1282 %X%P:%pS: unknown phdr type `%s' (try integer literal)\n"),
1294 memset
(&$$
, 0, sizeof
(struct phdr_info
));
1296 | NAME phdr_val phdr_qualifiers
1299 if
(strcmp
($1, "FILEHDR") == 0 && $2 == NULL
)
1301 else if
(strcmp
($1, "PHDRS") == 0 && $2 == NULL
)
1303 else if
(strcmp
($1, "FLAGS") == 0 && $2 != NULL
)
1306 einfo
(_
("%X%P:%pS: PHDRS syntax error at `%s'\n"),
1309 | AT
'(' exp
')' phdr_qualifiers
1329 ldlex_version_file
();
1330 PUSH_ERROR
(_
("dynamic list"));
1341 | dynamic_list_nodes dynamic_list_node
1345 '{' dynamic_list_tag
'}' ';'
1351 lang_append_dynamic_list
(current_dynamic_list_p
, $1);
1355 /* This syntax is used within an external version script file. */
1357 version_script_file:
1359 ldlex_version_file
();
1360 PUSH_ERROR
(_
("VERSION script"));
1369 /* This is used within a normal linker script file. */
1373 ldlex_version_script
();
1375 VERSIONK
'{' vers_nodes
'}'
1383 | vers_nodes vers_node
1387 '{' vers_tag
'}' ';'
1389 lang_register_vers_node
(NULL
, $2, NULL
);
1391 | VERS_TAG
'{' vers_tag
'}' ';'
1393 lang_register_vers_node
($1, $3, NULL
);
1395 | VERS_TAG
'{' vers_tag
'}' verdep
';'
1397 lang_register_vers_node
($1, $3, $5);
1404 $$
= lang_add_vers_depend
(NULL
, $1);
1408 $$
= lang_add_vers_depend
($1, $2);
1415 $$
= lang_new_vers_node
(NULL
, NULL
);
1419 $$
= lang_new_vers_node
($1, NULL
);
1421 | GLOBAL
':' vers_defns
';'
1423 $$
= lang_new_vers_node
($3, NULL
);
1425 | LOCAL
':' vers_defns
';'
1427 $$
= lang_new_vers_node
(NULL
, $3);
1429 | GLOBAL
':' vers_defns
';' LOCAL
':' vers_defns
';'
1431 $$
= lang_new_vers_node
($3, $7);
1438 $$
= lang_new_vers_pattern
(NULL
, $1, ldgram_vers_current_lang
, false
);
1442 $$
= lang_new_vers_pattern
(NULL
, $1, ldgram_vers_current_lang
, true
);
1444 | vers_defns
';' VERS_IDENTIFIER
1446 $$
= lang_new_vers_pattern
($1, $3, ldgram_vers_current_lang
, false
);
1448 | vers_defns
';' NAME
1450 $$
= lang_new_vers_pattern
($1, $3, ldgram_vers_current_lang
, true
);
1452 | vers_defns
';' EXTERN NAME
'{'
1454 $
<name
>$
= ldgram_vers_current_lang
;
1455 ldgram_vers_current_lang
= $4;
1457 vers_defns opt_semicolon
'}'
1459 struct bfd_elf_version_expr
*pat
;
1460 for
(pat
= $7; pat
->next
!= NULL
; pat
= pat
->next
);
1463 ldgram_vers_current_lang
= $
<name
>6;
1467 $
<name
>$
= ldgram_vers_current_lang
;
1468 ldgram_vers_current_lang
= $2;
1470 vers_defns opt_semicolon
'}'
1473 ldgram_vers_current_lang
= $
<name
>4;
1477 $$
= lang_new_vers_pattern
(NULL
, "global", ldgram_vers_current_lang
, false
);
1479 | vers_defns
';' GLOBAL
1481 $$
= lang_new_vers_pattern
($1, "global", ldgram_vers_current_lang
, false
);
1485 $$
= lang_new_vers_pattern
(NULL
, "local", ldgram_vers_current_lang
, false
);
1487 | vers_defns
';' LOCAL
1489 $$
= lang_new_vers_pattern
($1, "local", ldgram_vers_current_lang
, false
);
1493 $$
= lang_new_vers_pattern
(NULL
, "extern", ldgram_vers_current_lang
, false
);
1495 | vers_defns
';' EXTERN
1497 $$
= lang_new_vers_pattern
($1, "extern", ldgram_vers_current_lang
, false
);
1511 if
(ldfile_assumed_script
)
1512 einfo
(_
("%P:%s: file format not recognized; treating as linker script\n"),
1514 if
(error_index
> 0 && error_index
< ERROR_NAME_MAX
)
1515 einfo
(_
("%F%P:%pS: %s in %s\n"), NULL
, arg
, error_names
[error_index
- 1]);
1517 einfo
("%F%P:%pS: %s\n", NULL
, arg
);