1 /* A YACC grammar to parse a superset of the AT&T linker scripting language.
2 Copyright (C) 1991-2024 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
30 #include "libiberty.h"
50 static enum section_type sectype
;
51 static etree_type
*sectype_value
;
52 static lang_memory_region_type
*region
;
54 static bool ldgram_had_keep
= false
;
55 static char *ldgram_vers_current_lang
= NULL
;
57 #define ERROR_NAME_MAX 20
58 static char *error_names
[ERROR_NAME_MAX
];
59 static int error_index
;
60 #define PUSH_ERROR(x) if (error_index < ERROR_NAME_MAX) error_names[error_index] = x; error_index++;
61 #define POP_ERROR() error_index--;
63 static void yyerror (const char *);
75 struct wildcard_spec wildcard
;
76 struct wildcard_list
*wildcard_list
;
77 struct name_list
*name_list
;
78 struct flag_info_list
*flag_info_list
;
79 struct flag_info
*flag_info
;
81 union etree_union
*etree
;
86 union etree_union
*at
;
87 union etree_union
*flags
;
89 struct lang_nocrossref
*nocrossref
;
90 struct lang_output_section_phdr_list
*section_phdr
;
91 struct bfd_elf_version_deps
*deflist
;
92 struct bfd_elf_version_expr
*versyms
;
93 struct bfd_elf_version_tree
*versnode
;
96 %type
<etree
> exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val
97 %type
<etree
> opt_exp_without_type opt_subalign opt_align
98 %type
<fill
> fill_opt fill_exp
99 %type
<name_list
> exclude_name_list
100 %type
<wildcard_list
> section_name_list
101 %type
<flag_info_list
> sect_flag_list
102 %type
<flag_info
> sect_flags
103 %type
<name
> memspec_opt memspec_at_opt paren_script_name casesymlist
104 %type
<cname
> wildcard_name
105 %type
<wildcard
> section_name_spec filename_spec wildcard_maybe_exclude wildcard_maybe_reverse
107 %token
<name
> NAME LNAME
108 %type
<integer
> length
109 %type
<phdr
> phdr_qualifiers
110 %type
<nocrossref
> nocrossref_list
111 %type
<section_phdr
> phdr_opt
112 %type
<integer
> opt_nocrossrefs
114 %right
<token
> PLUSEQ MINUSEQ MULTEQ DIVEQ
'=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ XOREQ
115 %right
<token
> '?' ':'
122 %left
<token
> '<' '>' LE GE
123 %left
<token
> LSHIFT RSHIFT
125 %left
<token
> '+' '-'
126 %left
<token
> '*' '/' '%'
131 %token
<token
> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE ASCIZ
132 %token SECTIONS PHDRS INSERT_K AFTER BEFORE LINKER_VERSION
133 %token DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END
134 %token SORT_BY_NAME SORT_BY_ALIGNMENT SORT_NONE
135 %token SORT_BY_INIT_PRIORITY REVERSE
137 %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
138 %token INHIBIT_COMMON_ALLOCATION FORCE_GROUP_ALLOCATION
144 %token NOLOAD DSECT COPY INFO OVERLAY
147 %token DEFINED TARGET_K SEARCH_DIR MAP ENTRY
148 %token
<integer
> NEXT
149 %token SIZEOF ALIGNOF ADDR LOADADDR MAX_K MIN_K
150 %token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS NOCROSSREFS_TO
152 %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS
153 %token ALIGNMOD AT SUBALIGN HIDDEN PROVIDE PROVIDE_HIDDEN AS_NEEDED
154 %type
<token
> assign_op atype attributes_opt sect_constraint opt_align_with_input
155 %type
<name
> filename
156 %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K
157 %token LOG2CEIL FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL
158 %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START
159 %token
<name
> VERS_TAG VERS_IDENTIFIER
160 %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT
161 %token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL INPUT_SECTION_FLAGS ALIGN_WITH_INPUT
164 %type
<versyms
> vers_defns
165 %type
<versnode
> vers_tag
166 %type
<deflist
> verdep
167 %token INPUT_DYNAMIC_LIST
172 INPUT_SCRIPT script_file
173 | INPUT_MRI_SCRIPT mri_script_file
174 | INPUT_VERSION_SCRIPT version_script_file
175 | INPUT_DYNAMIC_LIST dynamic_list_file
176 | INPUT_DEFSYM defsym_expr
184 { ldlex_expression
(); }
186 { ldlex_popstate
(); }
189 /* SYNTAX WITHIN AN MRI SCRIPT FILE */
193 PUSH_ERROR
(_
("MRI style script"));
204 mri_script_lines mri_script_command NEWLINE
212 einfo
(_
("%F%P: unrecognised keyword in MRI style script '%s'\n"),$1);
215 config.map_filename
= "-";
217 | ORDER ordernamelist
219 | PUBLIC NAME
'=' exp
220 { mri_public
($2, $4); }
221 | PUBLIC NAME
',' exp
222 { mri_public
($2, $4); }
224 { mri_public
($2, $3); }
228 { mri_output_section
($2, $4);}
230 { mri_output_section
($2, $3);}
232 { mri_output_section
($2, $4);}
233 | ALIGN_K NAME
'=' exp
234 { mri_align
($2,$4); }
235 | ALIGN_K NAME
',' exp
236 { mri_align
($2,$4); }
237 | ALIGNMOD NAME
'=' exp
238 { mri_alignmod
($2,$4); }
239 | ALIGNMOD NAME
',' exp
240 { mri_alignmod
($2,$4); }
241 | ABSOLUTE mri_abs_name_list
242 | LOAD mri_load_name_list
245 | ALIAS NAME
',' NAME
246 { mri_alias
($2,$4,0);}
248 { mri_alias
($2, 0, (int) $4.integer
); }
252 { mri_truncate
((unsigned int) $2.integer
); }
254 | EXTERN extern_name_list
256 { ldfile_open_command_file
($2); }
259 { lang_add_entry
($2, false
); }
264 ordernamelist
',' NAME
{ mri_order
($3); }
265 | ordernamelist NAME
{ mri_order
($2); }
272 | mri_load_name_list
',' NAME
{ mri_load
($3); }
277 { mri_only_load
($1); }
278 | mri_abs_name_list
',' NAME
279 { mri_only_load
($3); }
283 /* empty */ { $$
= NULL
; }
285 | casesymlist
',' NAME
290 { ldlang_add_undef
($1, false
); }
291 | extern_name_list NAME
292 { ldlang_add_undef
($2, false
); }
293 | extern_name_list
',' NAME
294 { ldlang_add_undef
($3, false
); }
300 { ldlex_popstate
(); }
316 | floating_point_support
320 | TARGET_K
'(' NAME
')'
321 { lang_add_target
($3); }
322 | SEARCH_DIR
'(' filename
')'
323 { ldfile_add_library_path
($3, false
); }
324 | OUTPUT
'(' filename
')'
325 { lang_add_output
($3, 1); }
326 | OUTPUT_FORMAT
'(' NAME
')'
327 { lang_add_output_format
($3, (char *) NULL
,
329 | OUTPUT_FORMAT
'(' NAME
',' NAME
',' NAME
')'
330 { lang_add_output_format
($3, $5, $7, 1); }
331 | OUTPUT_ARCH
'(' NAME
')'
332 { ldfile_set_output_arch
($3, bfd_arch_unknown
); }
333 | FORCE_COMMON_ALLOCATION
334 { command_line.force_common_definition
= true
; }
335 | FORCE_GROUP_ALLOCATION
336 { command_line.force_group_allocation
= true
; }
337 | INHIBIT_COMMON_ALLOCATION
338 { link_info.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 { ldfile_open_command_file
($2); }
349 | NOCROSSREFS
'(' nocrossref_list
')'
351 lang_add_nocrossref
($3);
353 | NOCROSSREFS_TO
'(' nocrossref_list
')'
355 lang_add_nocrossref_to
($3);
357 | EXTERN
'(' { ldlex_expression
(); } extern_name_list
')'
358 { ldlex_popstate
(); }
359 | INSERT_K AFTER NAME
360 { lang_add_insert
($3, 0); }
361 | INSERT_K BEFORE NAME
362 { lang_add_insert
($3, 1); }
363 | REGION_ALIAS
'(' NAME
',' NAME
')'
364 { lang_memory_region_alias
($3, $5); }
365 | LD_FEATURE
'(' NAME
')'
366 { lang_ld_feature
($3); }
370 { ldlex_inputlist
(); }
372 { ldlex_popstate
(); }
376 { lang_add_input_file
($1,lang_input_file_is_search_file_enum
,
378 | input_list1
',' NAME
379 { lang_add_input_file
($3,lang_input_file_is_search_file_enum
,
382 { lang_add_input_file
($2,lang_input_file_is_search_file_enum
,
385 { lang_add_input_file
($1,lang_input_file_is_l_enum
,
387 | input_list1
',' LNAME
388 { lang_add_input_file
($3,lang_input_file_is_l_enum
,
391 { lang_add_input_file
($2,lang_input_file_is_l_enum
,
394 { $
<integer
>$
= input_flags.add_DT_NEEDED_for_regular
;
395 input_flags.add_DT_NEEDED_for_regular
= true
; }
397 { input_flags.add_DT_NEEDED_for_regular
= $
<integer
>3; }
398 | input_list1
',' AS_NEEDED
'('
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
>5; }
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
>4; }
411 SECTIONS
'{' sec_or_group_p1
'}'
415 sec_or_group_p1 section
416 | sec_or_group_p1 statement_anywhere
422 { lang_add_entry
($3, false
); }
423 | assignment separator
424 | ASSERT_K
{ldlex_expression
();} '(' exp
',' NAME
')'
426 lang_add_assignment
(exp_assert
($4, $6)); }
436 wildcard_maybe_exclude:
441 $$.exclude_name_list
= NULL
;
442 $$.section_flag_list
= NULL
;
445 | EXCLUDE_FILE
'(' exclude_name_list
')' wildcard_name
449 $$.exclude_name_list
= $3;
450 $$.section_flag_list
= NULL
;
455 wildcard_maybe_reverse:
456 wildcard_maybe_exclude
457 | REVERSE
'(' wildcard_maybe_exclude
')'
466 wildcard_maybe_reverse
467 | SORT_BY_NAME
'(' wildcard_maybe_reverse
')'
472 | SORT_NONE
'(' wildcard_maybe_reverse
')'
478 | REVERSE
'(' SORT_BY_NAME
'(' wildcard_maybe_exclude
')' ')'
487 wildcard_maybe_reverse
488 | SORT_BY_NAME
'(' wildcard_maybe_reverse
')'
493 | SORT_BY_ALIGNMENT
'(' wildcard_maybe_reverse
')'
496 $$.sorted
= by_alignment
;
498 | SORT_NONE
'(' wildcard_maybe_reverse
')'
503 | SORT_BY_NAME
'(' SORT_BY_ALIGNMENT
'(' wildcard_maybe_reverse
')' ')'
506 $$.sorted
= by_name_alignment
;
508 | SORT_BY_NAME
'(' SORT_BY_NAME
'(' wildcard_maybe_reverse
')' ')'
513 | SORT_BY_ALIGNMENT
'(' SORT_BY_NAME
'(' wildcard_maybe_reverse
')' ')'
516 $$.sorted
= by_alignment_name
;
518 | SORT_BY_ALIGNMENT
'(' SORT_BY_ALIGNMENT
'(' wildcard_maybe_reverse
')' ')'
521 $$.sorted
= by_alignment
;
523 | SORT_BY_INIT_PRIORITY
'(' wildcard_maybe_reverse
')'
526 $$.sorted
= by_init_priority
;
528 | REVERSE
'(' SORT_BY_NAME
'(' wildcard_maybe_exclude
')' ')'
534 | REVERSE
'(' SORT_BY_INIT_PRIORITY
'(' wildcard_maybe_exclude
')' ')'
537 $$.sorted
= by_init_priority
;
544 struct flag_info_list
*n
;
545 n
= ((struct flag_info_list
*) xmalloc
(sizeof
*n
));
548 n
->with
= without_flags
;
553 n
->with
= with_flags
;
560 | sect_flag_list
'&' NAME
562 struct flag_info_list
*n
;
563 n
= ((struct flag_info_list
*) xmalloc
(sizeof
*n
));
566 n
->with
= without_flags
;
571 n
->with
= with_flags
;
581 INPUT_SECTION_FLAGS
'(' sect_flag_list
')'
584 n
= ((struct flag_info
*) xmalloc
(sizeof
*n
));
586 n
->flags_initialized
= false
;
587 n
->not_with_flags
= 0;
588 n
->only_with_flags
= 0;
594 exclude_name_list wildcard_name
596 struct name_list
*tmp
;
597 tmp
= (struct name_list
*) xmalloc
(sizeof
*tmp
);
605 struct name_list
*tmp
;
606 tmp
= (struct name_list
*) xmalloc
(sizeof
*tmp
);
614 section_name_list opt_comma section_name_spec
616 struct wildcard_list
*tmp
;
617 tmp
= (struct wildcard_list
*) xmalloc
(sizeof
*tmp
);
625 struct wildcard_list
*tmp
;
626 tmp
= (struct wildcard_list
*) xmalloc
(sizeof
*tmp
);
633 input_section_spec_no_keep:
636 struct wildcard_spec tmp
;
638 tmp.exclude_name_list
= NULL
;
640 tmp.section_flag_list
= NULL
;
641 lang_add_wild
(&tmp
, NULL
, ldgram_had_keep
);
645 struct wildcard_spec tmp
;
647 tmp.exclude_name_list
= NULL
;
649 tmp.section_flag_list
= $1;
650 lang_add_wild
(&tmp
, NULL
, ldgram_had_keep
);
652 |
'[' section_name_list
']'
654 lang_add_wild
(NULL
, $2, ldgram_had_keep
);
656 | sect_flags
'[' section_name_list
']'
658 struct wildcard_spec tmp
;
660 tmp.exclude_name_list
= NULL
;
662 tmp.section_flag_list
= $1;
663 lang_add_wild
(&tmp
, $3, ldgram_had_keep
);
665 | filename_spec
'(' section_name_list
')'
667 lang_add_wild
(&$1, $3, ldgram_had_keep
);
669 | sect_flags filename_spec
'(' section_name_list
')'
671 $2.section_flag_list
= $1;
672 lang_add_wild
(&$2, $4, ldgram_had_keep
);
677 input_section_spec_no_keep
679 { ldgram_had_keep
= true
; }
680 input_section_spec_no_keep
')'
681 { ldgram_had_keep
= false
; }
686 | assignment separator
687 | CREATE_OBJECT_SYMBOLS
689 lang_add_attribute
(lang_object_symbols_statement_enum
);
693 lang_add_attribute
(lang_constructors_statement_enum
);
695 | SORT_BY_NAME
'(' CONSTRUCTORS
')'
697 constructors_sorted
= true
;
698 lang_add_attribute
(lang_constructors_statement_enum
);
701 | length
'(' mustbe_exp
')'
703 lang_add_data
((int) $1, $3);
707 lang_add_string
($2);
709 | FILL
'(' fill_exp
')'
715 lang_add_version_string
();
718 { ldlex_expression
(); }
719 '(' exp
',' NAME
')' separator
722 lang_add_assignment
(exp_assert
($4, $6));
726 ldfile_open_command_file
($2);
728 statement_list_opt END
732 statement_list statement
757 $$
= exp_get_fill
($1, 0, _
("fill value"));
764 |
{ $$
= (fill_type
*) 0; }
796 lang_add_assignment
(exp_assign
($1, $3, false
));
798 | NAME assign_op mustbe_exp
800 lang_add_assignment
(exp_assign
($1,
806 | HIDDEN
'(' NAME
'=' mustbe_exp
')'
808 lang_add_assignment
(exp_assign
($3, $5, true
));
810 | PROVIDE
'(' NAME
'=' mustbe_exp
')'
812 lang_add_assignment
(exp_provide
($3, $5, false
));
814 | PROVIDE_HIDDEN
'(' NAME
'=' mustbe_exp
')'
816 lang_add_assignment
(exp_provide
($3, $5, true
));
826 MEMORY
'{' memory_spec_list_opt
'}'
829 memory_spec_list_opt: memory_spec_list |
;
832 memory_spec_list opt_comma memory_spec
838 { region
= lang_memory_region_lookup
($1, true
); }
840 origin_spec opt_comma length_spec
843 { ldfile_open_command_file
($2); }
844 memory_spec_list_opt END
848 ORIGIN
'=' mustbe_exp
850 region
->origin_exp
= $3;
855 LENGTH
'=' mustbe_exp
862 region
->length_exp
= $3;
868 { /* dummy action to avoid bison 1.25 error message */ }
869 |
'(' attributes_list
')'
874 | attributes_list attributes_string
879 { lang_set_flags
(region
, $1, 0); }
881 { lang_set_flags
(region
, $2, 1); }
885 STARTUP
'(' filename
')'
886 { lang_startup
($3); }
890 HLL
'(' high_level_library_NAME_list
')'
892 { ldemul_hll
((char *)NULL
); }
895 high_level_library_NAME_list:
896 high_level_library_NAME_list opt_comma filename
903 SYSLIB
'(' low_level_library_NAME_list
')'
906 low_level_library_NAME_list:
907 low_level_library_NAME_list opt_comma filename
908 { ldemul_syslib
($3); }
912 floating_point_support:
914 { lang_float
(true
); }
916 { lang_float
(false
); }
924 | NAME nocrossref_list
926 struct lang_nocrossref
*n
;
928 n
= (struct lang_nocrossref
*) xmalloc
(sizeof
*n
);
933 | NAME
',' nocrossref_list
935 struct lang_nocrossref
*n
;
937 n
= (struct lang_nocrossref
*) xmalloc
(sizeof
*n
);
944 paren_script_name: { ldlex_script
(); }
946 { ldlex_popstate
(); $$
= $3; }
948 mustbe_exp: { ldlex_expression
(); }
950 { ldlex_popstate
(); $$
= $2; }
955 { $$
= exp_unop
('-', $2); }
958 | NEXT
'(' exp
')' %prec UNARY
959 { $$
= exp_unop
((int) $1,$3); }
960 |
'!' exp %prec UNARY
961 { $$
= exp_unop
('!', $2); }
962 |
'+' exp %prec UNARY
964 |
'~' exp %prec UNARY
965 { $$
= exp_unop
('~', $2);}
968 { $$
= exp_binop
('*', $1, $3); }
970 { $$
= exp_binop
('/', $1, $3); }
972 { $$
= exp_binop
('%', $1, $3); }
974 { $$
= exp_binop
('+', $1, $3); }
976 { $$
= exp_binop
('-' , $1, $3); }
978 { $$
= exp_binop
(LSHIFT
, $1, $3); }
980 { $$
= exp_binop
(RSHIFT
, $1, $3); }
982 { $$
= exp_binop
(EQ
, $1, $3); }
984 { $$
= exp_binop
(NE
, $1, $3); }
986 { $$
= exp_binop
(LE
, $1, $3); }
988 { $$
= exp_binop
(GE
, $1, $3); }
990 { $$
= exp_binop
('<' , $1, $3); }
992 { $$
= exp_binop
('>' , $1, $3); }
994 { $$
= exp_binop
('&' , $1, $3); }
996 { $$
= exp_binop
('^' , $1, $3); }
998 { $$
= exp_binop
('|' , $1, $3); }
999 | exp
'?' exp
':' exp
1000 { $$
= exp_trinop
('?' , $1, $3, $5); }
1002 { $$
= exp_binop
(ANDAND
, $1, $3); }
1004 { $$
= exp_binop
(OROR
, $1, $3); }
1005 | DEFINED
'(' NAME
')'
1006 { $$
= exp_nameop
(DEFINED
, $3); }
1008 { $$
= exp_bigintop
($1.integer
, $1.str
); }
1010 { $$
= exp_nameop
(SIZEOF_HEADERS
,0); }
1012 | ALIGNOF paren_script_name
1013 { $$
= exp_nameop
(ALIGNOF
, $2); }
1014 | SIZEOF paren_script_name
1015 { $$
= exp_nameop
(SIZEOF
, $2); }
1016 | ADDR paren_script_name
1017 { $$
= exp_nameop
(ADDR
, $2); }
1018 | LOADADDR paren_script_name
1019 { $$
= exp_nameop
(LOADADDR
, $2); }
1020 | CONSTANT
'(' NAME
')'
1021 { $$
= exp_nameop
(CONSTANT
,$3); }
1022 | ABSOLUTE
'(' exp
')'
1023 { $$
= exp_unop
(ABSOLUTE
, $3); }
1024 | ALIGN_K
'(' exp
')'
1025 { $$
= exp_unop
(ALIGN_K
,$3); }
1026 | ALIGN_K
'(' exp
',' exp
')'
1027 { $$
= exp_binop
(ALIGN_K
,$3,$5); }
1028 | DATA_SEGMENT_ALIGN
'(' exp
',' exp
')'
1029 { $$
= exp_binop
(DATA_SEGMENT_ALIGN
, $3, $5); }
1030 | DATA_SEGMENT_RELRO_END
'(' exp
',' exp
')'
1031 { $$
= exp_binop
(DATA_SEGMENT_RELRO_END
, $5, $3); }
1032 | DATA_SEGMENT_END
'(' exp
')'
1033 { $$
= exp_unop
(DATA_SEGMENT_END
, $3); }
1034 | SEGMENT_START
{ ldlex_script
(); } '(' NAME
1035 { ldlex_popstate
(); } ',' exp
')'
1036 { /* The operands to the expression node are
1037 placed in the opposite order from the way
1038 in which they appear in the script as
1039 that allows us to reuse more code in
1041 $$
= exp_binop
(SEGMENT_START
,
1043 exp_nameop
(NAME
, $4)); }
1045 { $$
= exp_unop
(ALIGN_K
,$3); }
1047 { $$
= exp_nameop
(NAME
,$1); }
1048 | MAX_K
'(' exp
',' exp
')'
1049 { $$
= exp_binop
(MAX_K
, $3, $5 ); }
1050 | MIN_K
'(' exp
',' exp
')'
1051 { $$
= exp_binop
(MIN_K
, $3, $5 ); }
1052 | ASSERT_K
'(' exp
',' NAME
')'
1053 { $$
= exp_assert
($3, $5); }
1054 | ORIGIN paren_script_name
1055 { $$
= exp_nameop
(ORIGIN
, $2); }
1056 | LENGTH paren_script_name
1057 { $$
= exp_nameop
(LENGTH
, $2); }
1058 | LOG2CEIL
'(' exp
')'
1059 { $$
= exp_unop
(LOG2CEIL
, $3); }
1064 AT
'>' NAME
{ $$
= $3; }
1069 AT
'(' exp
')' { $$
= $3; }
1074 ALIGN_K
'(' exp
')' { $$
= $3; }
1078 opt_align_with_input:
1079 ALIGN_WITH_INPUT
{ $$
= ALIGN_WITH_INPUT
; }
1084 SUBALIGN
'(' exp
')' { $$
= $3; }
1089 ONLY_IF_RO
{ $$
= ONLY_IF_RO
; }
1090 | ONLY_IF_RW
{ $$
= ONLY_IF_RW
; }
1091 | SPECIAL
{ $$
= SPECIAL
; }
1096 { ldlex_expression
(); }
1100 opt_align_with_input
1106 lang_enter_output_section_statement
($1, $3, sectype
,
1107 sectype_value
, $5, $7, $4, $8, $6);
1112 { ldlex_popstate
(); }
1113 memspec_opt memspec_at_opt phdr_opt fill_opt
1115 /* fill_opt may have switched the lexer into
1116 expression state, and back again, but in
1117 order to find the end of the fill
1118 expression the parser must look ahead one
1119 token. If it is a NAME, throw it away as
1120 it will have been lexed in the wrong
1127 lang_leave_output_section_statement
($17, $14,
1132 { ldlex_expression
(); }
1133 opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
1134 { ldlex_popstate
(); }
1137 lang_enter_overlay
($3, $6);
1141 memspec_opt memspec_at_opt phdr_opt fill_opt
1148 lang_leave_overlay
($5, (int) $4,
1149 $15, $12, $14, $13);
1152 |
/* The GROUP case is just enough to support the gcc
1153 svr3.ifile script. It is not intended to be full
1154 support. I'm not even sure what GROUP is supposed
1157 { ldlex_expression
(); }
1161 lang_add_assignment
(exp_assign
(".", $3, false
));
1163 '{' sec_or_group_p1
'}'
1166 ldfile_open_command_file
($2);
1172 NOLOAD
{ sectype
= noload_section
; }
1173 | DSECT
{ sectype
= noalloc_section
; }
1174 | COPY
{ sectype
= noalloc_section
; }
1175 | INFO
{ sectype
= noalloc_section
; }
1176 | OVERLAY
{ sectype
= noalloc_section
; }
1177 | READONLY
'(' TYPE
'=' exp
')' { sectype
= typed_readonly_section
; sectype_value
= $5; }
1178 | READONLY
{ sectype
= readonly_section
; }
1179 | TYPE
'=' exp
{ sectype
= type_section
; sectype_value
= $3; }
1184 |
/* EMPTY */ { sectype
= normal_section
; }
1185 |
'(' ')' { sectype
= normal_section
; }
1189 exp atype
':' { $$
= $1; }
1190 | atype
':' { $$
= (etree_type
*)NULL
; }
1191 |
/* The BIND cases are to support the gcc svr3.ifile
1192 script. They aren't intended to implement full
1193 support for the BIND keyword. I'm not even sure
1194 what BIND is supposed to mean. */
1195 BIND
'(' exp
')' atype
':' { $$
= $3; }
1196 | BIND
'(' exp
')' BLOCK
'(' exp
')' atype
':'
1200 opt_exp_without_type:
1201 exp
':' { $$
= $1; }
1202 |
':' { $$
= (etree_type
*) NULL
; }
1215 |
{ $$
= DEFAULT_MEMORY_REGION
; }
1225 struct lang_output_section_phdr_list
*n
;
1227 n
= ((struct lang_output_section_phdr_list
*)
1228 xmalloc
(sizeof
*n
));
1242 lang_enter_overlay_section
($2);
1247 { ldlex_popstate
(); }
1255 lang_leave_overlay_section
($9, $8);
1261 PHDRS
'{' phdr_list
'}'
1270 NAME
{ ldlex_expression
(); }
1271 phdr_type phdr_qualifiers
{ ldlex_popstate
(); }
1274 lang_new_phdr
($1, $3, $4.filehdr
, $4.phdrs
, $4.at
,
1284 if
($1->type.node_class
== etree_name
1285 && $1->type.node_code
== NAME
)
1289 static const char * const phdr_types
[] =
1291 "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
1292 "PT_INTERP", "PT_NOTE", "PT_SHLIB",
1298 i
< sizeof phdr_types
/ sizeof phdr_types
[0];
1300 if
(strcmp
(s
, phdr_types
[i
]) == 0)
1305 if
(i
== sizeof phdr_types
/ sizeof phdr_types
[0])
1307 if
(strcmp
(s
, "PT_GNU_EH_FRAME") == 0)
1308 $$
= exp_intop
(0x6474e550);
1309 else if
(strcmp
(s
, "PT_GNU_STACK") == 0)
1310 $$
= exp_intop
(0x6474e551);
1311 else if
(strcmp
(s
, "PT_GNU_RELRO") == 0)
1312 $$
= exp_intop
(0x6474e552);
1313 else if
(strcmp
(s
, "PT_GNU_PROPERTY") == 0)
1314 $$
= exp_intop
(0x6474e553);
1318 %X%P:%pS: unknown phdr type `%s' (try integer literal)\n"),
1330 memset
(&$$
, 0, sizeof
(struct phdr_info
));
1332 | NAME phdr_val phdr_qualifiers
1335 if
(strcmp
($1, "FILEHDR") == 0 && $2 == NULL
)
1337 else if
(strcmp
($1, "PHDRS") == 0 && $2 == NULL
)
1339 else if
(strcmp
($1, "FLAGS") == 0 && $2 != NULL
)
1342 einfo
(_
("%X%P:%pS: PHDRS syntax error at `%s'\n"),
1345 | AT
'(' exp
')' phdr_qualifiers
1365 ldlex_version_file
();
1366 PUSH_ERROR
(_
("dynamic list"));
1377 | dynamic_list_nodes dynamic_list_node
1381 '{' dynamic_list_tag
'}' ';'
1387 lang_append_dynamic_list
(current_dynamic_list_p
, $1);
1391 /* This syntax is used within an external version script file. */
1393 version_script_file:
1395 ldlex_version_file
();
1396 PUSH_ERROR
(_
("VERSION script"));
1405 /* This is used within a normal linker script file. */
1409 ldlex_version_script
();
1411 VERSIONK
'{' vers_nodes
'}'
1419 | vers_nodes vers_node
1423 '{' vers_tag
'}' ';'
1425 lang_register_vers_node
(NULL
, $2, NULL
);
1427 | VERS_TAG
'{' vers_tag
'}' ';'
1429 lang_register_vers_node
($1, $3, NULL
);
1431 | VERS_TAG
'{' vers_tag
'}' verdep
';'
1433 lang_register_vers_node
($1, $3, $5);
1440 $$
= lang_add_vers_depend
(NULL
, $1);
1444 $$
= lang_add_vers_depend
($1, $2);
1451 $$
= lang_new_vers_node
(NULL
, NULL
);
1455 $$
= lang_new_vers_node
($1, NULL
);
1457 | GLOBAL
':' vers_defns
';'
1459 $$
= lang_new_vers_node
($3, NULL
);
1461 | LOCAL
':' vers_defns
';'
1463 $$
= lang_new_vers_node
(NULL
, $3);
1465 | GLOBAL
':' vers_defns
';' LOCAL
':' vers_defns
';'
1467 $$
= lang_new_vers_node
($3, $7);
1474 $$
= lang_new_vers_pattern
(NULL
, $1, ldgram_vers_current_lang
, false
);
1478 $$
= lang_new_vers_pattern
(NULL
, $1, ldgram_vers_current_lang
, true
);
1480 | vers_defns
';' VERS_IDENTIFIER
1482 $$
= lang_new_vers_pattern
($1, $3, ldgram_vers_current_lang
, false
);
1484 | vers_defns
';' NAME
1486 $$
= lang_new_vers_pattern
($1, $3, ldgram_vers_current_lang
, true
);
1488 | vers_defns
';' EXTERN NAME
'{'
1490 $
<name
>$
= ldgram_vers_current_lang
;
1491 ldgram_vers_current_lang
= $4;
1493 vers_defns opt_semicolon
'}'
1495 struct bfd_elf_version_expr
*pat
;
1496 for
(pat
= $7; pat
->next
!= NULL
; pat
= pat
->next
);
1499 ldgram_vers_current_lang
= $
<name
>6;
1503 $
<name
>$
= ldgram_vers_current_lang
;
1504 ldgram_vers_current_lang
= $2;
1506 vers_defns opt_semicolon
'}'
1509 ldgram_vers_current_lang
= $
<name
>4;
1513 $$
= lang_new_vers_pattern
(NULL
, "global", ldgram_vers_current_lang
, false
);
1515 | vers_defns
';' GLOBAL
1517 $$
= lang_new_vers_pattern
($1, "global", ldgram_vers_current_lang
, false
);
1521 $$
= lang_new_vers_pattern
(NULL
, "local", ldgram_vers_current_lang
, false
);
1523 | vers_defns
';' LOCAL
1525 $$
= lang_new_vers_pattern
($1, "local", ldgram_vers_current_lang
, false
);
1529 $$
= lang_new_vers_pattern
(NULL
, "extern", ldgram_vers_current_lang
, false
);
1531 | vers_defns
';' EXTERN
1533 $$
= lang_new_vers_pattern
($1, "extern", ldgram_vers_current_lang
, false
);
1544 yyerror (const char *arg
)
1546 if
(ldfile_assumed_script
)
1547 einfo
(_
("%P:%s: file format not recognized; treating as linker script\n"),
1549 if
(error_index
> 0 && error_index
< ERROR_NAME_MAX
)
1550 einfo
(_
("%F%P:%pS: %s in %s\n"), NULL
, arg
, error_names
[error_index
- 1]);
1552 einfo
("%F%P:%pS: %s\n", NULL
, arg
);