1 /* A YACC grammar to parse a superset of the AT&T linker scripting language.
2 Copyright (C) 1991-2022 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
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
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);
672 | FILL
'(' fill_exp
')'
677 { ldlex_expression
(); }
678 '(' exp
',' NAME
')' separator
681 lang_add_assignment
(exp_assert
($4, $6));
685 ldfile_open_command_file
($2);
687 statement_list_opt END
691 statement_list statement
716 $$
= exp_get_fill
($1, 0, "fill value");
723 |
{ $$
= (fill_type
*) 0; }
753 lang_add_assignment
(exp_assign
($1, $3, false
));
755 | NAME assign_op mustbe_exp
757 lang_add_assignment
(exp_assign
($1,
763 | HIDDEN
'(' NAME
'=' mustbe_exp
')'
765 lang_add_assignment
(exp_assign
($3, $5, true
));
767 | PROVIDE
'(' NAME
'=' mustbe_exp
')'
769 lang_add_assignment
(exp_provide
($3, $5, false
));
771 | PROVIDE_HIDDEN
'(' NAME
'=' mustbe_exp
')'
773 lang_add_assignment
(exp_provide
($3, $5, true
));
783 MEMORY
'{' memory_spec_list_opt
'}'
786 memory_spec_list_opt: memory_spec_list |
;
789 memory_spec_list opt_comma memory_spec
795 { region
= lang_memory_region_lookup
($1, true
); }
797 origin_spec opt_comma length_spec
800 { ldfile_open_command_file
($2); }
801 memory_spec_list_opt END
805 ORIGIN
'=' mustbe_exp
807 region
->origin_exp
= $3;
812 LENGTH
'=' mustbe_exp
819 region
->length_exp
= $3;
825 { /* dummy action to avoid bison 1.25 error message */ }
826 |
'(' attributes_list
')'
831 | attributes_list attributes_string
836 { lang_set_flags
(region
, $1, 0); }
838 { lang_set_flags
(region
, $2, 1); }
842 STARTUP
'(' filename
')'
843 { lang_startup
($3); }
847 HLL
'(' high_level_library_NAME_list
')'
849 { ldemul_hll
((char *)NULL
); }
852 high_level_library_NAME_list:
853 high_level_library_NAME_list opt_comma filename
860 SYSLIB
'(' low_level_library_NAME_list
')'
863 low_level_library_NAME_list:
864 low_level_library_NAME_list opt_comma filename
865 { ldemul_syslib
($3); }
869 floating_point_support:
871 { lang_float
(true
); }
873 { lang_float
(false
); }
881 | NAME nocrossref_list
883 struct lang_nocrossref
*n
;
885 n
= (struct lang_nocrossref
*) xmalloc
(sizeof
*n
);
890 | NAME
',' nocrossref_list
892 struct lang_nocrossref
*n
;
894 n
= (struct lang_nocrossref
*) xmalloc
(sizeof
*n
);
901 paren_script_name: { ldlex_script
(); }
903 { ldlex_popstate
(); $$
= $3; }
905 mustbe_exp: { ldlex_expression
(); }
907 { ldlex_popstate
(); $$
= $2; }
912 { $$
= exp_unop
('-', $2); }
915 | NEXT
'(' exp
')' %prec UNARY
916 { $$
= exp_unop
((int) $1,$3); }
917 |
'!' exp %prec UNARY
918 { $$
= exp_unop
('!', $2); }
919 |
'+' exp %prec UNARY
921 |
'~' exp %prec UNARY
922 { $$
= exp_unop
('~', $2);}
925 { $$
= exp_binop
('*', $1, $3); }
927 { $$
= exp_binop
('/', $1, $3); }
929 { $$
= exp_binop
('%', $1, $3); }
931 { $$
= exp_binop
('+', $1, $3); }
933 { $$
= exp_binop
('-' , $1, $3); }
935 { $$
= exp_binop
(LSHIFT
, $1, $3); }
937 { $$
= exp_binop
(RSHIFT
, $1, $3); }
939 { $$
= exp_binop
(EQ
, $1, $3); }
941 { $$
= exp_binop
(NE
, $1, $3); }
943 { $$
= exp_binop
(LE
, $1, $3); }
945 { $$
= exp_binop
(GE
, $1, $3); }
947 { $$
= exp_binop
('<' , $1, $3); }
949 { $$
= exp_binop
('>' , $1, $3); }
951 { $$
= exp_binop
('&' , $1, $3); }
953 { $$
= exp_binop
('^' , $1, $3); }
955 { $$
= exp_binop
('|' , $1, $3); }
956 | exp
'?' exp
':' exp
957 { $$
= exp_trinop
('?' , $1, $3, $5); }
959 { $$
= exp_binop
(ANDAND
, $1, $3); }
961 { $$
= exp_binop
(OROR
, $1, $3); }
962 | DEFINED
'(' NAME
')'
963 { $$
= exp_nameop
(DEFINED
, $3); }
965 { $$
= exp_bigintop
($1.integer
, $1.str
); }
967 { $$
= exp_nameop
(SIZEOF_HEADERS
,0); }
969 | ALIGNOF paren_script_name
970 { $$
= exp_nameop
(ALIGNOF
, $2); }
971 | SIZEOF paren_script_name
972 { $$
= exp_nameop
(SIZEOF
, $2); }
973 | ADDR paren_script_name
974 { $$
= exp_nameop
(ADDR
, $2); }
975 | LOADADDR paren_script_name
976 { $$
= exp_nameop
(LOADADDR
, $2); }
977 | CONSTANT
'(' NAME
')'
978 { $$
= exp_nameop
(CONSTANT
,$3); }
979 | ABSOLUTE
'(' exp
')'
980 { $$
= exp_unop
(ABSOLUTE
, $3); }
981 | ALIGN_K
'(' exp
')'
982 { $$
= exp_unop
(ALIGN_K
,$3); }
983 | ALIGN_K
'(' exp
',' exp
')'
984 { $$
= exp_binop
(ALIGN_K
,$3,$5); }
985 | DATA_SEGMENT_ALIGN
'(' exp
',' exp
')'
986 { $$
= exp_binop
(DATA_SEGMENT_ALIGN
, $3, $5); }
987 | DATA_SEGMENT_RELRO_END
'(' exp
',' exp
')'
988 { $$
= exp_binop
(DATA_SEGMENT_RELRO_END
, $5, $3); }
989 | DATA_SEGMENT_END
'(' exp
')'
990 { $$
= exp_unop
(DATA_SEGMENT_END
, $3); }
991 | SEGMENT_START
{ ldlex_script
(); } '(' NAME
992 { ldlex_popstate
(); } ',' exp
')'
993 { /* The operands to the expression node are
994 placed in the opposite order from the way
995 in which they appear in the script as
996 that allows us to reuse more code in
998 $$
= exp_binop
(SEGMENT_START
,
1000 exp_nameop
(NAME
, $4)); }
1002 { $$
= exp_unop
(ALIGN_K
,$3); }
1004 { $$
= exp_nameop
(NAME
,$1); }
1005 | MAX_K
'(' exp
',' exp
')'
1006 { $$
= exp_binop
(MAX_K
, $3, $5 ); }
1007 | MIN_K
'(' exp
',' exp
')'
1008 { $$
= exp_binop
(MIN_K
, $3, $5 ); }
1009 | ASSERT_K
'(' exp
',' NAME
')'
1010 { $$
= exp_assert
($3, $5); }
1011 | ORIGIN paren_script_name
1012 { $$
= exp_nameop
(ORIGIN
, $2); }
1013 | LENGTH paren_script_name
1014 { $$
= exp_nameop
(LENGTH
, $2); }
1015 | LOG2CEIL
'(' exp
')'
1016 { $$
= exp_unop
(LOG2CEIL
, $3); }
1021 AT
'>' NAME
{ $$
= $3; }
1026 AT
'(' exp
')' { $$
= $3; }
1031 ALIGN_K
'(' exp
')' { $$
= $3; }
1035 opt_align_with_input:
1036 ALIGN_WITH_INPUT
{ $$
= ALIGN_WITH_INPUT
; }
1041 SUBALIGN
'(' exp
')' { $$
= $3; }
1046 ONLY_IF_RO
{ $$
= ONLY_IF_RO
; }
1047 | ONLY_IF_RW
{ $$
= ONLY_IF_RW
; }
1048 | SPECIAL
{ $$
= SPECIAL
; }
1053 { ldlex_expression
(); }
1057 opt_align_with_input
1063 lang_enter_output_section_statement
($1, $3, sectype
,
1064 sectype_value
, $5, $7, $4, $8, $6);
1069 { ldlex_popstate
(); }
1070 memspec_opt memspec_at_opt phdr_opt fill_opt
1072 /* fill_opt may have switched the lexer into
1073 expression state, and back again, but in
1074 order to find the end of the fill
1075 expression the parser must look ahead one
1076 token. If it is a NAME, throw it away as
1077 it will have been lexed in the wrong
1084 lang_leave_output_section_statement
($17, $14,
1089 { ldlex_expression
(); }
1090 opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
1091 { ldlex_popstate
(); }
1094 lang_enter_overlay
($3, $6);
1098 memspec_opt memspec_at_opt phdr_opt fill_opt
1105 lang_leave_overlay
($5, (int) $4,
1106 $15, $12, $14, $13);
1109 |
/* The GROUP case is just enough to support the gcc
1110 svr3.ifile script. It is not intended to be full
1111 support. I'm not even sure what GROUP is supposed
1114 { ldlex_expression
(); }
1118 lang_add_assignment
(exp_assign
(".", $3, false
));
1120 '{' sec_or_group_p1
'}'
1123 ldfile_open_command_file
($2);
1129 NOLOAD
{ sectype
= noload_section
; }
1130 | DSECT
{ sectype
= noalloc_section
; }
1131 | COPY
{ sectype
= noalloc_section
; }
1132 | INFO
{ sectype
= noalloc_section
; }
1133 | OVERLAY
{ sectype
= noalloc_section
; }
1134 | READONLY
'(' TYPE
'=' exp
')' { sectype
= typed_readonly_section
; sectype_value
= $5; }
1135 | READONLY
{ sectype
= readonly_section
; }
1136 | TYPE
'=' exp
{ sectype
= type_section
; sectype_value
= $3; }
1141 |
/* EMPTY */ { sectype
= normal_section
; }
1142 |
'(' ')' { sectype
= normal_section
; }
1146 exp atype
':' { $$
= $1; }
1147 | atype
':' { $$
= (etree_type
*)NULL
; }
1148 |
/* The BIND cases are to support the gcc svr3.ifile
1149 script. They aren't intended to implement full
1150 support for the BIND keyword. I'm not even sure
1151 what BIND is supposed to mean. */
1152 BIND
'(' exp
')' atype
':' { $$
= $3; }
1153 | BIND
'(' exp
')' BLOCK
'(' exp
')' atype
':'
1157 opt_exp_without_type:
1158 exp
':' { $$
= $1; }
1159 |
':' { $$
= (etree_type
*) NULL
; }
1172 |
{ $$
= DEFAULT_MEMORY_REGION
; }
1182 struct lang_output_section_phdr_list
*n
;
1184 n
= ((struct lang_output_section_phdr_list
*)
1185 xmalloc
(sizeof
*n
));
1199 lang_enter_overlay_section
($2);
1204 { ldlex_popstate
(); }
1212 lang_leave_overlay_section
($9, $8);
1218 PHDRS
'{' phdr_list
'}'
1227 NAME
{ ldlex_expression
(); }
1228 phdr_type phdr_qualifiers
{ ldlex_popstate
(); }
1231 lang_new_phdr
($1, $3, $4.filehdr
, $4.phdrs
, $4.at
,
1241 if
($1->type.node_class
== etree_name
1242 && $1->type.node_code
== NAME
)
1246 static const char * const phdr_types
[] =
1248 "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
1249 "PT_INTERP", "PT_NOTE", "PT_SHLIB",
1255 i
< sizeof phdr_types
/ sizeof phdr_types
[0];
1257 if
(strcmp
(s
, phdr_types
[i
]) == 0)
1262 if
(i
== sizeof phdr_types
/ sizeof phdr_types
[0])
1264 if
(strcmp
(s
, "PT_GNU_EH_FRAME") == 0)
1265 $$
= exp_intop
(0x6474e550);
1266 else if
(strcmp
(s
, "PT_GNU_STACK") == 0)
1267 $$
= exp_intop
(0x6474e551);
1268 else if
(strcmp
(s
, "PT_GNU_RELRO") == 0)
1269 $$
= exp_intop
(0x6474e552);
1270 else if
(strcmp
(s
, "PT_GNU_PROPERTY") == 0)
1271 $$
= exp_intop
(0x6474e553);
1275 %X%P:%pS: unknown phdr type `%s' (try integer literal)\n"),
1287 memset
(&$$
, 0, sizeof
(struct phdr_info
));
1289 | NAME phdr_val phdr_qualifiers
1292 if
(strcmp
($1, "FILEHDR") == 0 && $2 == NULL
)
1294 else if
(strcmp
($1, "PHDRS") == 0 && $2 == NULL
)
1296 else if
(strcmp
($1, "FLAGS") == 0 && $2 != NULL
)
1299 einfo
(_
("%X%P:%pS: PHDRS syntax error at `%s'\n"),
1302 | AT
'(' exp
')' phdr_qualifiers
1322 ldlex_version_file
();
1323 PUSH_ERROR
(_
("dynamic list"));
1334 | dynamic_list_nodes dynamic_list_node
1338 '{' dynamic_list_tag
'}' ';'
1344 lang_append_dynamic_list
(current_dynamic_list_p
, $1);
1348 /* This syntax is used within an external version script file. */
1350 version_script_file:
1352 ldlex_version_file
();
1353 PUSH_ERROR
(_
("VERSION script"));
1362 /* This is used within a normal linker script file. */
1366 ldlex_version_script
();
1368 VERSIONK
'{' vers_nodes
'}'
1376 | vers_nodes vers_node
1380 '{' vers_tag
'}' ';'
1382 lang_register_vers_node
(NULL
, $2, NULL
);
1384 | VERS_TAG
'{' vers_tag
'}' ';'
1386 lang_register_vers_node
($1, $3, NULL
);
1388 | VERS_TAG
'{' vers_tag
'}' verdep
';'
1390 lang_register_vers_node
($1, $3, $5);
1397 $$
= lang_add_vers_depend
(NULL
, $1);
1401 $$
= lang_add_vers_depend
($1, $2);
1408 $$
= lang_new_vers_node
(NULL
, NULL
);
1412 $$
= lang_new_vers_node
($1, NULL
);
1414 | GLOBAL
':' vers_defns
';'
1416 $$
= lang_new_vers_node
($3, NULL
);
1418 | LOCAL
':' vers_defns
';'
1420 $$
= lang_new_vers_node
(NULL
, $3);
1422 | GLOBAL
':' vers_defns
';' LOCAL
':' vers_defns
';'
1424 $$
= lang_new_vers_node
($3, $7);
1431 $$
= lang_new_vers_pattern
(NULL
, $1, ldgram_vers_current_lang
, false
);
1435 $$
= lang_new_vers_pattern
(NULL
, $1, ldgram_vers_current_lang
, true
);
1437 | vers_defns
';' VERS_IDENTIFIER
1439 $$
= lang_new_vers_pattern
($1, $3, ldgram_vers_current_lang
, false
);
1441 | vers_defns
';' NAME
1443 $$
= lang_new_vers_pattern
($1, $3, ldgram_vers_current_lang
, true
);
1445 | vers_defns
';' EXTERN NAME
'{'
1447 $
<name
>$
= ldgram_vers_current_lang
;
1448 ldgram_vers_current_lang
= $4;
1450 vers_defns opt_semicolon
'}'
1452 struct bfd_elf_version_expr
*pat
;
1453 for
(pat
= $7; pat
->next
!= NULL
; pat
= pat
->next
);
1456 ldgram_vers_current_lang
= $
<name
>6;
1460 $
<name
>$
= ldgram_vers_current_lang
;
1461 ldgram_vers_current_lang
= $2;
1463 vers_defns opt_semicolon
'}'
1466 ldgram_vers_current_lang
= $
<name
>4;
1470 $$
= lang_new_vers_pattern
(NULL
, "global", ldgram_vers_current_lang
, false
);
1472 | vers_defns
';' GLOBAL
1474 $$
= lang_new_vers_pattern
($1, "global", ldgram_vers_current_lang
, false
);
1478 $$
= lang_new_vers_pattern
(NULL
, "local", ldgram_vers_current_lang
, false
);
1480 | vers_defns
';' LOCAL
1482 $$
= lang_new_vers_pattern
($1, "local", ldgram_vers_current_lang
, false
);
1486 $$
= lang_new_vers_pattern
(NULL
, "extern", ldgram_vers_current_lang
, false
);
1488 | vers_defns
';' EXTERN
1490 $$
= lang_new_vers_pattern
($1, "extern", ldgram_vers_current_lang
, false
);
1504 if
(ldfile_assumed_script
)
1505 einfo
(_
("%P:%s: file format not recognized; treating as linker script\n"),
1507 if
(error_index
> 0 && error_index
< ERROR_NAME_MAX
)
1508 einfo
("%F%P:%pS: %s in %s\n", NULL
, arg
, error_names
[error_index
- 1]);
1510 einfo
("%F%P:%pS: %s\n", NULL
, arg
);