1 %
{ /* defparse.y - parser for .def files */
3 /* Copyright (C) 1995-2022 Free Software Foundation, Inc.
5 This file is part of 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. */
24 #include "libiberty.h"
34 %token NAME LIBRARY DESCRIPTION STACKSIZE HEAPSIZE CODE DATA
35 %token SECTIONS EXPORTS IMPORTS VERSIONK BASE CONSTANT
36 %token READ WRITE EXECUTE SHARED NONSHARED NONAME PRIVATE
37 %token SINGLE MULTIPLE INITINSTANCE INITGLOBAL TERMINSTANCE TERMGLOBAL
40 %token
<number
> NUMBER
41 %type
<number
> opt_base opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
42 %type
<number
> attr attr_list opt_number
43 %type
<id
> opt_name opt_name2 opt_equal_name opt_import_name
44 %type
<id_const
> keyword_as_name
53 NAME opt_name opt_base
{ def_name
($2, $3); }
54 | LIBRARY opt_name opt_base option_list
{ def_library
($2, $3); }
56 | DESCRIPTION ID
{ def_description
($2);}
57 | STACKSIZE NUMBER opt_number
{ def_stacksize
($2, $3);}
58 | HEAPSIZE NUMBER opt_number
{ def_heapsize
($2, $3);}
59 | CODE attr_list
{ def_code
($2);}
60 | DATA attr_list
{ def_data
($2);}
63 | VERSIONK NUMBER
{ def_version
($2,0);}
64 | VERSIONK NUMBER
'.' NUMBER
{ def_version
($2,$4);}
74 ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
76 { def_exports
($1, $2, $3, $4, $5, $6, $7, $8);}
84 ID
'=' ID
'.' ID
'.' ID opt_import_name
85 { def_import
($1,$3,$5,$7, 0, $8); }
86 | ID
'=' ID
'.' ID
'.' NUMBER opt_import_name
87 { def_import
($1,$3,$5, 0,$7, $8); }
88 | ID
'=' ID
'.' ID opt_import_name
89 { def_import
($1,$3, 0,$5, 0, $6); }
90 | ID
'=' ID
'.' NUMBER opt_import_name
91 { def_import
($1,$3, 0, 0,$5, $6); }
92 | ID
'.' ID
'.' ID opt_import_name
93 { def_import
( 0,$1,$3,$5, 0, $6); }
94 | ID
'.' ID
'.' NUMBER opt_import_name
95 { def_import
( 0,$1,$3, 0,$5, $6); }
96 | ID
'.' ID opt_import_name
97 { def_import
( 0,$1, 0,$3, 0, $4); }
98 | ID
'.' NUMBER opt_import_name
99 { def_import
( 0,$1, 0, 0,$3, $4); }
108 ID attr_list
{ def_section
($1,$2);}
112 attr_list opt_comma attr
120 opt_number: ',' NUMBER
{ $$
=$2;}
127 | EXECUTE
{ $$
= 4; }
129 | NONSHARED
{ $$
= 0; }
131 | MULTIPLE
{ $$
= 0; }
154 keyword_as_name: NAME
{ $$
= "NAME"; }
155 /* Disabled LIBRARY keyword for a quirk in libtool. It places LIBRARY
156 command after EXPORTS list, which is illegal by specification.
157 See PR binutils/13710
158 | LIBRARY { $$ = "LIBRARY"; } */
159 | DESCRIPTION
{ $$
= "DESCRIPTION"; }
160 | STACKSIZE
{ $$
= "STACKSIZE"; }
161 | HEAPSIZE
{ $$
= "HEAPSIZE"; }
162 | CODE
{ $$
= "CODE"; }
163 | DATA
{ $$
= "DATA"; }
164 | SECTIONS
{ $$
= "SECTIONS"; }
165 | EXPORTS
{ $$
= "EXPORTS"; }
166 | IMPORTS
{ $$
= "IMPORTS"; }
167 | VERSIONK
{ $$
= "VERSION"; }
168 | BASE
{ $$
= "BASE"; }
169 | CONSTANT
{ $$
= "CONSTANT"; }
170 | NONAME
{ $$
= "NONAME"; }
171 | PRIVATE
{ $$
= "PRIVATE"; }
172 | READ
{ $$
= "READ"; }
173 | WRITE
{ $$
= "WRITE"; }
174 | EXECUTE
{ $$
= "EXECUTE"; }
175 | SHARED
{ $$
= "SHARED"; }
176 | NONSHARED
{ $$
= "NONSHARED"; }
177 | SINGLE
{ $$
= "SINGLE"; }
178 | MULTIPLE
{ $$
= "MULTIPLE"; }
179 | INITINSTANCE
{ $$
= "INITINSTANCE"; }
180 | INITGLOBAL
{ $$
= "INITGLOBAL"; }
181 | TERMINSTANCE
{ $$
= "TERMINSTANCE"; }
182 | TERMGLOBAL
{ $$
= "TERMGLOBAL"; }
185 opt_name2: ID
{ $$
= $1; }
186 |
'.' keyword_as_name
188 char *name
= xmalloc
(strlen
($2) + 2);
189 sprintf
(name
, ".%s", $2);
194 char *name
= xmalloc
(strlen
($2) + 2);
195 sprintf
(name
, ".%s", $2);
198 | keyword_as_name
'.' opt_name2
200 char *name
= xmalloc
(strlen
($1) + 1 + strlen
($3) + 1);
201 sprintf
(name
, "%s.%s", $1, $3);
206 char *name
= xmalloc
(strlen
($1) + 1 + strlen
($3) + 1);
207 sprintf
(name
, "%s.%s", $1, $3);
211 opt_name: opt_name2
{ $$
=$1; }
221 EQUAL opt_name2
{ $$
= $2; }
226 '=' opt_name2
{ $$
= $2; }
230 opt_base: BASE
'=' NUMBER
{ $$
= $3;}
236 | option_list opt_comma option