More dynamic object support, initial scripting support.
[deliverable/binutils-gdb.git] / gold / yyscript.y
1 /* yyscript.y -- linker script grammer for gold. */
2
3 /* This is a bison grammar to parse a subset of the original GNU ld
4 linker script language. */
5
6 %{
7
8 #include "config.h"
9
10 #include <stddef.h>
11 #include <stdint.h>
12
13 #include "script-c.h"
14
15 %}
16
17 /* We need to use a pure parser because we might be multi-threaded.
18 We pass some arguments through the parser to the lexer. */
19
20 %pure-parser
21
22 %parse-param {void* closure}
23 %lex-param {void* closure}
24
25 /* Since we require bison anyhow, we take advantage of it. */
26
27 %error-verbose
28
29 /* The values associated with tokens. */
30
31 %union {
32 const char* string;
33 int64_t integer;
34 }
35
36 /* Operators, including a precedence table for expressions. */
37
38 %right PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
39 %right '?' ':'
40 %left OROR
41 %left ANDAND
42 %left '|'
43 %left '^'
44 %left '&'
45 %left EQ NE
46 %left '<' '>' LE GE
47 %left LSHIFT RSHIFT
48 %left '+' '-'
49 %left '*' '/' '%'
50
51 /* Constants. */
52
53 %token <string> STRING
54 %token <integer> INTEGER
55
56 /* Keywords. This list is taken from ldgram.y and ldlex.l in the old
57 GNU linker, with the keywords which only appear in MRI mode
58 removed. Not all these keywords are actually used in this grammar.
59 In most cases the keyword is recognized as the token name in upper
60 case. The comments indicate where this is not the case. */
61
62 %token ABSOLUTE
63 %token ADDR
64 %token ALIGN_K /* ALIGN */
65 %token ASSERT_K /* ASSERT */
66 %token AS_NEEDED
67 %token AT
68 %token BIND
69 %token BLOCK
70 %token BYTE
71 %token CONSTANT
72 %token CONSTRUCTORS
73 %token COPY
74 %token CREATE_OBJECT_SYMBOLS
75 %token DATA_SEGMENT_ALIGN
76 %token DATA_SEGMENT_END
77 %token DATA_SEGMENT_RELRO_END
78 %token DEFINED
79 %token DSECT
80 %token ENTRY
81 %token EXCLUDE_FILE
82 %token EXTERN
83 %token FILL
84 %token FLOAT
85 %token FORCE_COMMON_ALLOCATION
86 %token GLOBAL /* global */
87 %token GROUP
88 %token HLL
89 %token INCLUDE
90 %token INFO
91 %token INHIBIT_COMMON_ALLOCATION
92 %token INPUT
93 %token KEEP
94 %token LENGTH /* LENGTH, l, len */
95 %token LOADADDR
96 %token LOCAL /* local */
97 %token LONG
98 %token MAP
99 %token MAX_K /* MAX */
100 %token MEMORY
101 %token MIN_K /* MIN */
102 %token NEXT
103 %token NOCROSSREFS
104 %token NOFLOAT
105 %token NOLOAD
106 %token ONLY_IF_RO
107 %token ONLY_IF_RW
108 %token ORIGIN /* ORIGIN, o, org */
109 %token OUTPUT
110 %token OUTPUT_ARCH
111 %token OUTPUT_FORMAT
112 %token OVERLAY
113 %token PHDRS
114 %token PROVIDE
115 %token PROVIDE_HIDDEN
116 %token QUAD
117 %token SEARCH_DIR
118 %token SECTIONS
119 %token SEGMENT_START
120 %token SHORT
121 %token SIZEOF
122 %token SIZEOF_HEADERS /* SIZEOF_HEADERS, sizeof_headers */
123 %token SORT_BY_ALIGNMENT
124 %token SORT_BY_NAME
125 %token SPECIAL
126 %token SQUAD
127 %token STARTUP
128 %token SUBALIGN
129 %token SYSLIB
130 %token TARGET_K /* TARGET */
131 %token TRUNCATE
132 %token VERSIONK /* VERSION */
133
134 %%
135
136 file_list:
137 file_list file_cmd
138 | /* empty */
139 ;
140
141 file_cmd:
142 OUTPUT_FORMAT '(' STRING ')'
143 | GROUP
144 { script_start_group(closure); }
145 '(' input_list ')'
146 { script_end_group(closure); }
147 ;
148
149 input_list:
150 input_list_element
151 | input_list opt_comma input_list_element
152 ;
153
154 input_list_element:
155 STRING
156 { script_add_file(closure, $1); }
157 | AS_NEEDED
158 { script_start_as_needed(closure); }
159 '(' input_list ')'
160 { script_end_as_needed(closure); }
161 ;
162
163 opt_comma:
164 ','
165 | /* empty */
166 ;
167
168 %%
This page took 0.034394 seconds and 5 git commands to generate.