*** empty log message ***
[deliverable/binutils-gdb.git] / gold / yyscript.y
CommitLineData
dbe717ef
ILT
1/* yyscript.y -- linker script grammer for gold. */
2
6cb15b7f
ILT
3/* Copyright 2006, 2007 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor <iant@google.com>.
5
6 This file is part of gold.
7
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.
12
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.
17
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. */
22
dbe717ef
ILT
23/* This is a bison grammar to parse a subset of the original GNU ld
24 linker script language. */
25
26%{
27
28#include "config.h"
29
30#include <stddef.h>
31#include <stdint.h>
32
33#include "script-c.h"
34
35%}
36
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. */
39
40%pure-parser
41
42%parse-param {void* closure}
43%lex-param {void* closure}
44
45/* Since we require bison anyhow, we take advantage of it. */
46
47%error-verbose
48
49/* The values associated with tokens. */
50
51%union {
52 const char* string;
53 int64_t integer;
54}
55
56/* Operators, including a precedence table for expressions. */
57
58%right PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
59%right '?' ':'
60%left OROR
61%left ANDAND
62%left '|'
63%left '^'
64%left '&'
65%left EQ NE
66%left '<' '>' LE GE
67%left LSHIFT RSHIFT
68%left '+' '-'
69%left '*' '/' '%'
70
71/* Constants. */
72
73%token <string> STRING
74%token <integer> INTEGER
75
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. */
81
82%token ABSOLUTE
83%token ADDR
84%token ALIGN_K /* ALIGN */
85%token ASSERT_K /* ASSERT */
86%token AS_NEEDED
87%token AT
88%token BIND
89%token BLOCK
90%token BYTE
91%token CONSTANT
92%token CONSTRUCTORS
93%token COPY
94%token CREATE_OBJECT_SYMBOLS
95%token DATA_SEGMENT_ALIGN
96%token DATA_SEGMENT_END
97%token DATA_SEGMENT_RELRO_END
98%token DEFINED
99%token DSECT
100%token ENTRY
101%token EXCLUDE_FILE
102%token EXTERN
103%token FILL
104%token FLOAT
105%token FORCE_COMMON_ALLOCATION
106%token GLOBAL /* global */
107%token GROUP
108%token HLL
109%token INCLUDE
110%token INFO
111%token INHIBIT_COMMON_ALLOCATION
112%token INPUT
113%token KEEP
114%token LENGTH /* LENGTH, l, len */
115%token LOADADDR
116%token LOCAL /* local */
117%token LONG
118%token MAP
119%token MAX_K /* MAX */
120%token MEMORY
121%token MIN_K /* MIN */
122%token NEXT
123%token NOCROSSREFS
124%token NOFLOAT
125%token NOLOAD
126%token ONLY_IF_RO
127%token ONLY_IF_RW
128%token ORIGIN /* ORIGIN, o, org */
129%token OUTPUT
130%token OUTPUT_ARCH
131%token OUTPUT_FORMAT
132%token OVERLAY
133%token PHDRS
134%token PROVIDE
135%token PROVIDE_HIDDEN
136%token QUAD
137%token SEARCH_DIR
138%token SECTIONS
139%token SEGMENT_START
140%token SHORT
141%token SIZEOF
142%token SIZEOF_HEADERS /* SIZEOF_HEADERS, sizeof_headers */
143%token SORT_BY_ALIGNMENT
144%token SORT_BY_NAME
145%token SPECIAL
146%token SQUAD
147%token STARTUP
148%token SUBALIGN
149%token SYSLIB
150%token TARGET_K /* TARGET */
151%token TRUNCATE
152%token VERSIONK /* VERSION */
153
195e7dc6
ILT
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. */
158
159%token OPTION
160
dbe717ef
ILT
161%%
162
163file_list:
164 file_list file_cmd
165 | /* empty */
166 ;
167
168file_cmd:
169 OUTPUT_FORMAT '(' STRING ')'
170 | GROUP
171 { script_start_group(closure); }
172 '(' input_list ')'
173 { script_end_group(closure); }
195e7dc6
ILT
174 | OPTION '(' STRING ')'
175 { script_parse_option(closure, $3); }
dbe717ef
ILT
176 ;
177
178input_list:
179 input_list_element
180 | input_list opt_comma input_list_element
181 ;
182
183input_list_element:
184 STRING
185 { script_add_file(closure, $1); }
186 | AS_NEEDED
187 { script_start_as_needed(closure); }
188 '(' input_list ')'
189 { script_end_as_needed(closure); }
190 ;
191
192opt_comma:
193 ','
194 | /* empty */
195 ;
196
197%%
This page took 0.077616 seconds and 4 git commands to generate.