Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | %{ /* defparse.y - parser for .def files */ |
2 | ||
aa820537 | 3 | /* Copyright 1995, 1997, 1998, 1999, 2001, 2004, 2005, 2007 |
32866df7 NC |
4 | Free Software Foundation, Inc. |
5 | ||
6 | This file is part of GNU Binutils. | |
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. */ | |
252b5132 | 22 | |
3db64b00 | 23 | #include "sysdep.h" |
252b5132 | 24 | #include "bfd.h" |
3db64b00 | 25 | #include "libiberty.h" |
252b5132 RH |
26 | #include "dlltool.h" |
27 | %} | |
28 | ||
29 | %union { | |
30 | char *id; | |
aa83d1ec | 31 | const char *id_const; |
252b5132 RH |
32 | int number; |
33 | }; | |
34 | ||
74aba8aa DS |
35 | %token NAME LIBRARY DESCRIPTION STACKSIZE HEAPSIZE CODE DATA |
36 | %token SECTIONS EXPORTS IMPORTS VERSIONK BASE CONSTANT | |
7aa52b1f | 37 | %token READ WRITE EXECUTE SHARED NONSHARED NONAME PRIVATE |
d7ec8102 | 38 | %token SINGLE MULTIPLE INITINSTANCE INITGLOBAL TERMINSTANCE TERMGLOBAL |
bf201fdd | 39 | %token EQUAL |
252b5132 RH |
40 | %token <id> ID |
41 | %token <number> NUMBER | |
7aa52b1f | 42 | %type <number> opt_base opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE |
252b5132 | 43 | %type <number> attr attr_list opt_number |
aa83d1ec KT |
44 | %type <id> opt_name opt_name2 opt_equal_name opt_import_name |
45 | %type <id_const> keyword_as_name | |
252b5132 RH |
46 | |
47 | %% | |
48 | ||
49 | start: start command | |
50 | | command | |
51 | ; | |
52 | ||
53 | command: | |
54 | NAME opt_name opt_base { def_name ($2, $3); } | |
d7ec8102 | 55 | | LIBRARY opt_name opt_base option_list { def_library ($2, $3); } |
252b5132 RH |
56 | | EXPORTS explist |
57 | | DESCRIPTION ID { def_description ($2);} | |
58 | | STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);} | |
59 | | HEAPSIZE NUMBER opt_number { def_heapsize ($2, $3);} | |
60 | | CODE attr_list { def_code ($2);} | |
61 | | DATA attr_list { def_data ($2);} | |
62 | | SECTIONS seclist | |
63 | | IMPORTS implist | |
64 | | VERSIONK NUMBER { def_version ($2,0);} | |
65 | | VERSIONK NUMBER '.' NUMBER { def_version ($2,$4);} | |
66 | ; | |
67 | ||
68 | ||
69 | explist: | |
70 | /* EMPTY */ | |
252b5132 RH |
71 | | explist expline |
72 | ; | |
73 | ||
74 | expline: | |
7aa52b1f | 75 | ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE |
bf201fdd KT |
76 | opt_import_name |
77 | { def_exports ($1, $2, $3, $4, $5, $6, $7, $8);} | |
252b5132 RH |
78 | ; |
79 | implist: | |
80 | implist impline | |
81 | | impline | |
82 | ; | |
83 | ||
84 | impline: | |
bf201fdd KT |
85 | ID '=' ID '.' ID '.' ID opt_import_name |
86 | { def_import ($1,$3,$5,$7, 0, $8); } | |
87 | | ID '=' ID '.' ID '.' NUMBER opt_import_name | |
88 | { def_import ($1,$3,$5, 0,$7, $8); } | |
89 | | ID '=' ID '.' ID opt_import_name | |
90 | { def_import ($1,$3, 0,$5, 0, $6); } | |
91 | | ID '=' ID '.' NUMBER opt_import_name | |
92 | { def_import ($1,$3, 0, 0,$5, $6); } | |
93 | | ID '.' ID '.' ID opt_import_name | |
94 | { def_import ( 0,$1,$3,$5, 0, $6); } | |
95 | | ID '.' ID '.' NUMBER opt_import_name | |
96 | { def_import ( 0,$1,$3, 0,$5, $6); } | |
97 | | ID '.' ID opt_import_name | |
98 | { def_import ( 0,$1, 0,$3, 0, $4); } | |
99 | | ID '.' NUMBER opt_import_name | |
100 | { def_import ( 0,$1, 0, 0,$3, $4); } | |
252b5132 RH |
101 | ; |
102 | ||
103 | seclist: | |
104 | seclist secline | |
105 | | secline | |
106 | ; | |
107 | ||
108 | secline: | |
109 | ID attr_list { def_section ($1,$2);} | |
110 | ; | |
111 | ||
112 | attr_list: | |
113 | attr_list opt_comma attr | |
114 | | attr | |
115 | ; | |
116 | ||
117 | opt_comma: | |
118 | ',' | |
119 | | | |
120 | ; | |
121 | opt_number: ',' NUMBER { $$=$2;} | |
122 | | { $$=-1;} | |
123 | ; | |
124 | ||
125 | attr: | |
d7ec8102 ILT |
126 | READ { $$ = 1; } |
127 | | WRITE { $$ = 2; } | |
128 | | EXECUTE { $$ = 4; } | |
129 | | SHARED { $$ = 8; } | |
130 | | NONSHARED { $$ = 0; } | |
131 | | SINGLE { $$ = 0; } | |
132 | | MULTIPLE { $$ = 0; } | |
252b5132 RH |
133 | ; |
134 | ||
135 | opt_CONSTANT: | |
136 | CONSTANT {$$=1;} | |
137 | | {$$=0;} | |
138 | ; | |
139 | ||
140 | opt_NONAME: | |
141 | NONAME {$$=1;} | |
142 | | {$$=0;} | |
143 | ; | |
144 | ||
145 | opt_DATA: | |
146 | DATA { $$ = 1; } | |
147 | | { $$ = 0; } | |
148 | ; | |
149 | ||
7aa52b1f NC |
150 | opt_PRIVATE: |
151 | PRIVATE { $$ = 1; } | |
152 | | { $$ = 0; } | |
153 | ; | |
154 | ||
aa83d1ec | 155 | keyword_as_name: NAME { $$ = "NAME"; } |
5b3d386e KT |
156 | /* Disabled LIBRARY keyword for a quirk in libtool. It places LIBRARY |
157 | command after EXPORTS list, which is illegal by specification. | |
158 | See PR binutils/13710 | |
159 | | LIBRARY { $$ = "LIBRARY"; } */ | |
aa83d1ec KT |
160 | | DESCRIPTION { $$ = "DESCRIPTION"; } |
161 | | STACKSIZE { $$ = "STACKSIZE"; } | |
162 | | HEAPSIZE { $$ = "HEAPSIZE"; } | |
163 | | CODE { $$ = "CODE"; } | |
164 | | DATA { $$ = "DATA"; } | |
165 | | SECTIONS { $$ = "SECTIONS"; } | |
166 | | EXPORTS { $$ = "EXPORTS"; } | |
167 | | IMPORTS { $$ = "IMPORTS"; } | |
168 | | VERSIONK { $$ = "VERSION"; } | |
169 | | BASE { $$ = "BASE"; } | |
170 | | CONSTANT { $$ = "CONSTANT"; } | |
171 | | NONAME { $$ = "NONAME"; } | |
172 | | PRIVATE { $$ = "PRIVATE"; } | |
173 | | READ { $$ = "READ"; } | |
174 | | WRITE { $$ = "WRITE"; } | |
175 | | EXECUTE { $$ = "EXECUTE"; } | |
176 | | SHARED { $$ = "SHARED"; } | |
177 | | NONSHARED { $$ = "NONSHARED"; } | |
178 | | SINGLE { $$ = "SINGLE"; } | |
179 | | MULTIPLE { $$ = "MULTIPLE"; } | |
180 | | INITINSTANCE { $$ = "INITINSTANCE"; } | |
181 | | INITGLOBAL { $$ = "INITGLOBAL"; } | |
182 | | TERMINSTANCE { $$ = "TERMINSTANCE"; } | |
183 | | TERMGLOBAL { $$ = "TERMGLOBAL"; } | |
184 | ; | |
185 | ||
186 | opt_name2: ID { $$ = $1; } | |
187 | | '.' keyword_as_name | |
188 | { | |
189 | char *name = xmalloc (strlen ($2) + 2); | |
190 | sprintf (name, ".%s", $2); | |
191 | $$ = name; | |
192 | } | |
193 | | '.' opt_name2 | |
194 | { | |
195 | char *name = xmalloc (strlen ($2) + 2); | |
196 | sprintf (name, ".%s", $2); | |
197 | $$ = name; | |
198 | } | |
199 | | keyword_as_name '.' opt_name2 | |
200 | { | |
201 | char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1); | |
202 | sprintf (name, "%s.%s", $1, $3); | |
203 | $$ = name; | |
204 | } | |
205 | | ID '.' opt_name2 | |
252b5132 RH |
206 | { |
207 | char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1); | |
208 | sprintf (name, "%s.%s", $1, $3); | |
209 | $$ = name; | |
210 | } | |
aa83d1ec KT |
211 | ; |
212 | opt_name: opt_name2 { $$ =$1; } | |
252b5132 RH |
213 | | { $$=""; } |
214 | ; | |
215 | ||
216 | opt_ordinal: | |
217 | '@' NUMBER { $$=$2;} | |
218 | | { $$=-1;} | |
219 | ; | |
220 | ||
bf201fdd | 221 | opt_import_name: |
aa83d1ec | 222 | EQUAL opt_name2 { $$ = $2; } |
bf201fdd KT |
223 | | { $$ = 0; } |
224 | ; | |
225 | ||
252b5132 | 226 | opt_equal_name: |
aa83d1ec | 227 | '=' opt_name2 { $$ = $2; } |
252b5132 RH |
228 | | { $$ = 0; } |
229 | ; | |
230 | ||
231 | opt_base: BASE '=' NUMBER { $$= $3;} | |
232 | | { $$=-1;} | |
233 | ; | |
234 | ||
d7ec8102 ILT |
235 | option_list: |
236 | /* empty */ | |
237 | | option_list opt_comma option | |
238 | ; | |
252b5132 | 239 | |
d7ec8102 ILT |
240 | option: |
241 | INITINSTANCE | |
242 | | INITGLOBAL | |
243 | | TERMINSTANCE | |
244 | | TERMGLOBAL | |
245 | ; |