1 /* yyscript.y -- linker script grammer for gold. */
3 /* Copyright 2006, 2007 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor <iant@google.com>.
6 This file is part of gold.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
23 /* This is a bison grammar to parse a subset of the original GNU ld
24 linker script language. */
37 /* We need to use a pure parser because we might be multi-threaded.
38 We pass some arguments through the parser to the lexer. */
42 %parse-param {void* closure}
43 %lex-param {void* closure}
45 /* Since we require bison anyhow, we take advantage of it. */
49 /* The values associated with tokens. */
56 /* Operators, including a precedence table for expressions. */
58 %right PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
73 %token <string> STRING
74 %token <integer> INTEGER
76 /* Keywords. This list is taken from ldgram.y and ldlex.l in the old
77 GNU linker, with the keywords which only appear in MRI mode
78 removed. Not all these keywords are actually used in this grammar.
79 In most cases the keyword is recognized as the token name in upper
80 case. The comments indicate where this is not the case. */
84 %token ALIGN_K /* ALIGN */
85 %token ASSERT_K /* ASSERT */
94 %token CREATE_OBJECT_SYMBOLS
95 %token DATA_SEGMENT_ALIGN
96 %token DATA_SEGMENT_END
97 %token DATA_SEGMENT_RELRO_END
105 %token FORCE_COMMON_ALLOCATION
106 %token GLOBAL /* global */
111 %token INHIBIT_COMMON_ALLOCATION
114 %token LENGTH /* LENGTH, l, len */
116 %token LOCAL /* local */
119 %token MAX_K /* MAX */
121 %token MIN_K /* MIN */
128 %token ORIGIN /* ORIGIN, o, org */
135 %token PROVIDE_HIDDEN
142 %token SIZEOF_HEADERS /* SIZEOF_HEADERS, sizeof_headers */
143 %token SORT_BY_ALIGNMENT
150 %token TARGET_K /* TARGET */
152 %token VERSIONK /* VERSION */
154 /* Keywords, part 2. These are keywords that are unique to gold,
155 and not present in the old GNU linker. As before, unless the
156 comments say otherwise, the keyword is recognized as the token
157 name in upper case. */
169 OUTPUT_FORMAT '(' STRING ')'
171 { script_start_group(closure); }
173 { script_end_group(closure); }
174 | OPTION '(' STRING ')'
175 { script_parse_option(closure, $3); }
180 | input_list opt_comma input_list_element
185 { script_add_file(closure, $1); }
187 { script_start_as_needed(closure); }
189 { script_end_as_needed(closure); }