xref: /netbsd-src/external/gpl3/binutils.old/dist/ld/deffilep.c (revision eceb233b9bd0dfebb902ed73b531ae6964fa3f9b)
1 /* A Bison parser, made by GNU Bison 3.0.4.  */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5    Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6 
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.
11 
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.
16 
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19 
20 /* As a special exception, you may create a larger work that contains
21    part or all of the Bison parser skeleton and distribute that work
22    under terms of your choice, so long as that work isn't itself a
23    parser generator using the skeleton or a modified version thereof
24    as a parser skeleton.  Alternatively, if you modify or redistribute
25    the parser skeleton itself, you may (at your option) remove this
26    special exception, which will cause the skeleton and the resulting
27    Bison output files to be licensed under the GNU General Public
28    License without this special exception.
29 
30    This special exception was added by the Free Software Foundation in
31    version 2.2 of Bison.  */
32 
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34    simplifying the original so-called "semantic" parser.  */
35 
36 /* All symbols defined below should begin with yy or YY, to avoid
37    infringing on user name space.  This should be done even for local
38    variables, as they might otherwise be expanded by user macros.
39    There are some unavoidable exceptions within include files to
40    define necessary library symbols; they are noted "INFRINGES ON
41    USER NAME SPACE" below.  */
42 
43 /* Identify Bison output.  */
44 #define YYBISON 1
45 
46 /* Bison version.  */
47 #define YYBISON_VERSION "3.0.4"
48 
49 /* Skeleton name.  */
50 #define YYSKELETON_NAME "yacc.c"
51 
52 /* Pure parsers.  */
53 #define YYPURE 0
54 
55 /* Push parsers.  */
56 #define YYPUSH 0
57 
58 /* Pull parsers.  */
59 #define YYPULL 1
60 
61 
62 
63 
64 /* Copy the first part of user declarations.  */
65 #line 1 "deffilep.y" /* yacc.c:339  */
66  /* deffilep.y - parser for .def files */
67 
68 /*   Copyright (C) 1995-2018 Free Software Foundation, Inc.
69 
70      This file is part of GNU Binutils.
71 
72      This program is free software; you can redistribute it and/or modify
73      it under the terms of the GNU General Public License as published by
74      the Free Software Foundation; either version 3 of the License, or
75      (at your option) any later version.
76 
77      This program is distributed in the hope that it will be useful,
78      but WITHOUT ANY WARRANTY; without even the implied warranty of
79      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
80      GNU General Public License for more details.
81 
82      You should have received a copy of the GNU General Public License
83      along with this program; if not, write to the Free Software
84      Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
85      MA 02110-1301, USA.  */
86 
87 #include "sysdep.h"
88 #include "libiberty.h"
89 #include "safe-ctype.h"
90 #include "bfd.h"
91 #include "ld.h"
92 #include "ldmisc.h"
93 #include "deffile.h"
94 
95 #define TRACE 0
96 
97 #define ROUND_UP(a, b) (((a)+((b)-1))&~((b)-1))
98 
99 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
100    as well as gratuitiously global symbol names, so we can have multiple
101    yacc generated parsers in ld.  Note that these are only the variables
102    produced by yacc.  If other parser generators (bison, byacc, etc) produce
103    additional global names that conflict at link time, then those parser
104    generators need to be fixed instead of adding those names to this list.  */
105 
106 #define	yymaxdepth def_maxdepth
107 #define	yyparse	def_parse
108 #define	yylex	def_lex
109 #define	yyerror	def_error
110 #define	yylval	def_lval
111 #define	yychar	def_char
112 #define	yydebug	def_debug
113 #define	yypact	def_pact
114 #define	yyr1	def_r1
115 #define	yyr2	def_r2
116 #define	yydef	def_def
117 #define	yychk	def_chk
118 #define	yypgo	def_pgo
119 #define	yyact	def_act
120 #define	yyexca	def_exca
121 #define yyerrflag def_errflag
122 #define yynerrs	def_nerrs
123 #define	yyps	def_ps
124 #define	yypv	def_pv
125 #define	yys	def_s
126 #define	yy_yys	def_yys
127 #define	yystate	def_state
128 #define	yytmp	def_tmp
129 #define	yyv	def_v
130 #define	yy_yyv	def_yyv
131 #define	yyval	def_val
132 #define	yylloc	def_lloc
133 #define yyreds	def_reds		/* With YYDEBUG defined.  */
134 #define yytoks	def_toks		/* With YYDEBUG defined.  */
135 #define yylhs	def_yylhs
136 #define yylen	def_yylen
137 #define yydefred def_yydefred
138 #define yydgoto	def_yydgoto
139 #define yysindex def_yysindex
140 #define yyrindex def_yyrindex
141 #define yygindex def_yygindex
142 #define yytable	 def_yytable
143 #define yycheck	 def_yycheck
144 
145 typedef struct def_pool_str {
146   struct def_pool_str *next;
147   char data[1];
148 } def_pool_str;
149 
150 static def_pool_str *pool_strs = NULL;
151 
152 static char *def_pool_alloc (size_t sz);
153 static char *def_pool_strdup (const char *str);
154 static void def_pool_free (void);
155 
156 static void def_description (const char *);
157 static void def_exports (const char *, const char *, int, int, const char *);
158 static void def_heapsize (int, int);
159 static void def_import (const char *, const char *, const char *, const char *,
160 			int, const char *);
161 static void def_image_name (const char *, bfd_vma, int);
162 static void def_section (const char *, int);
163 static void def_section_alt (const char *, const char *);
164 static void def_stacksize (int, int);
165 static void def_version (int, int);
166 static void def_directive (char *);
167 static void def_aligncomm (char *str, int align);
168 static int def_parse (void);
169 static int def_error (const char *);
170 static int def_lex (void);
171 
172 static int lex_forced_token = 0;
173 static const char *lex_parse_string = 0;
174 static const char *lex_parse_string_end = 0;
175 
176 
177 #line 178 "deffilep.c" /* yacc.c:339  */
178 
179 # ifndef YY_NULLPTR
180 #  if defined __cplusplus && 201103L <= __cplusplus
181 #   define YY_NULLPTR nullptr
182 #  else
183 #   define YY_NULLPTR 0
184 #  endif
185 # endif
186 
187 /* Enabling verbose error messages.  */
188 #ifdef YYERROR_VERBOSE
189 # undef YYERROR_VERBOSE
190 # define YYERROR_VERBOSE 1
191 #else
192 # define YYERROR_VERBOSE 0
193 #endif
194 
195 /* In a future release of Bison, this section will be replaced
196    by #include "y.tab.h".  */
197 #ifndef YY_YY_DEFFILEP_H_INCLUDED
198 # define YY_YY_DEFFILEP_H_INCLUDED
199 /* Debug traces.  */
200 #ifndef YYDEBUG
201 # define YYDEBUG 0
202 #endif
203 #if YYDEBUG
204 extern int yydebug;
205 #endif
206 
207 /* Token type.  */
208 #ifndef YYTOKENTYPE
209 # define YYTOKENTYPE
210   enum yytokentype
211   {
212     NAME = 258,
213     LIBRARY = 259,
214     DESCRIPTION = 260,
215     STACKSIZE_K = 261,
216     HEAPSIZE = 262,
217     CODE = 263,
218     DATAU = 264,
219     DATAL = 265,
220     SECTIONS = 266,
221     EXPORTS = 267,
222     IMPORTS = 268,
223     VERSIONK = 269,
224     BASE = 270,
225     CONSTANTU = 271,
226     CONSTANTL = 272,
227     PRIVATEU = 273,
228     PRIVATEL = 274,
229     ALIGNCOMM = 275,
230     READ = 276,
231     WRITE = 277,
232     EXECUTE = 278,
233     SHARED = 279,
234     NONAMEU = 280,
235     NONAMEL = 281,
236     DIRECTIVE = 282,
237     EQUAL = 283,
238     ID = 284,
239     DIGITS = 285
240   };
241 #endif
242 /* Tokens.  */
243 #define NAME 258
244 #define LIBRARY 259
245 #define DESCRIPTION 260
246 #define STACKSIZE_K 261
247 #define HEAPSIZE 262
248 #define CODE 263
249 #define DATAU 264
250 #define DATAL 265
251 #define SECTIONS 266
252 #define EXPORTS 267
253 #define IMPORTS 268
254 #define VERSIONK 269
255 #define BASE 270
256 #define CONSTANTU 271
257 #define CONSTANTL 272
258 #define PRIVATEU 273
259 #define PRIVATEL 274
260 #define ALIGNCOMM 275
261 #define READ 276
262 #define WRITE 277
263 #define EXECUTE 278
264 #define SHARED 279
265 #define NONAMEU 280
266 #define NONAMEL 281
267 #define DIRECTIVE 282
268 #define EQUAL 283
269 #define ID 284
270 #define DIGITS 285
271 
272 /* Value type.  */
273 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
274 
275 union YYSTYPE
276 {
277 #line 113 "deffilep.y" /* yacc.c:355  */
278 
279   char *id;
280   const char *id_const;
281   int number;
282   bfd_vma vma;
283   char *digits;
284 
285 #line 286 "deffilep.c" /* yacc.c:355  */
286 };
287 
288 typedef union YYSTYPE YYSTYPE;
289 # define YYSTYPE_IS_TRIVIAL 1
290 # define YYSTYPE_IS_DECLARED 1
291 #endif
292 
293 
294 extern YYSTYPE yylval;
295 
296 int yyparse (void);
297 
298 #endif /* !YY_YY_DEFFILEP_H_INCLUDED  */
299 
300 /* Copy the second part of user declarations.  */
301 
302 #line 303 "deffilep.c" /* yacc.c:358  */
303 
304 #ifdef short
305 # undef short
306 #endif
307 
308 #ifdef YYTYPE_UINT8
309 typedef YYTYPE_UINT8 yytype_uint8;
310 #else
311 typedef unsigned char yytype_uint8;
312 #endif
313 
314 #ifdef YYTYPE_INT8
315 typedef YYTYPE_INT8 yytype_int8;
316 #else
317 typedef signed char yytype_int8;
318 #endif
319 
320 #ifdef YYTYPE_UINT16
321 typedef YYTYPE_UINT16 yytype_uint16;
322 #else
323 typedef unsigned short int yytype_uint16;
324 #endif
325 
326 #ifdef YYTYPE_INT16
327 typedef YYTYPE_INT16 yytype_int16;
328 #else
329 typedef short int yytype_int16;
330 #endif
331 
332 #ifndef YYSIZE_T
333 # ifdef __SIZE_TYPE__
334 #  define YYSIZE_T __SIZE_TYPE__
335 # elif defined size_t
336 #  define YYSIZE_T size_t
337 # elif ! defined YYSIZE_T
338 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
339 #  define YYSIZE_T size_t
340 # else
341 #  define YYSIZE_T unsigned int
342 # endif
343 #endif
344 
345 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
346 
347 #ifndef YY_
348 # if defined YYENABLE_NLS && YYENABLE_NLS
349 #  if ENABLE_NLS
350 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
351 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
352 #  endif
353 # endif
354 # ifndef YY_
355 #  define YY_(Msgid) Msgid
356 # endif
357 #endif
358 
359 #ifndef YY_ATTRIBUTE
360 # if (defined __GNUC__                                               \
361       && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)))  \
362      || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
363 #  define YY_ATTRIBUTE(Spec) __attribute__(Spec)
364 # else
365 #  define YY_ATTRIBUTE(Spec) /* empty */
366 # endif
367 #endif
368 
369 #ifndef YY_ATTRIBUTE_PURE
370 # define YY_ATTRIBUTE_PURE   YY_ATTRIBUTE ((__pure__))
371 #endif
372 
373 #ifndef YY_ATTRIBUTE_UNUSED
374 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
375 #endif
376 
377 #if !defined _Noreturn \
378      && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
379 # if defined _MSC_VER && 1200 <= _MSC_VER
380 #  define _Noreturn __declspec (noreturn)
381 # else
382 #  define _Noreturn YY_ATTRIBUTE ((__noreturn__))
383 # endif
384 #endif
385 
386 /* Suppress unused-variable warnings by "using" E.  */
387 #if ! defined lint || defined __GNUC__
388 # define YYUSE(E) ((void) (E))
389 #else
390 # define YYUSE(E) /* empty */
391 #endif
392 
393 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
394 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
395 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
396     _Pragma ("GCC diagnostic push") \
397     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
398     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
399 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
400     _Pragma ("GCC diagnostic pop")
401 #else
402 # define YY_INITIAL_VALUE(Value) Value
403 #endif
404 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
405 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
406 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
407 #endif
408 #ifndef YY_INITIAL_VALUE
409 # define YY_INITIAL_VALUE(Value) /* Nothing. */
410 #endif
411 
412 
413 #if ! defined yyoverflow || YYERROR_VERBOSE
414 
415 /* The parser invokes alloca or malloc; define the necessary symbols.  */
416 
417 # ifdef YYSTACK_USE_ALLOCA
418 #  if YYSTACK_USE_ALLOCA
419 #   ifdef __GNUC__
420 #    define YYSTACK_ALLOC __builtin_alloca
421 #   elif defined __BUILTIN_VA_ARG_INCR
422 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
423 #   elif defined _AIX
424 #    define YYSTACK_ALLOC __alloca
425 #   elif defined _MSC_VER
426 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
427 #    define alloca _alloca
428 #   else
429 #    define YYSTACK_ALLOC alloca
430 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
431 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
432       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
433 #     ifndef EXIT_SUCCESS
434 #      define EXIT_SUCCESS 0
435 #     endif
436 #    endif
437 #   endif
438 #  endif
439 # endif
440 
441 # ifdef YYSTACK_ALLOC
442    /* Pacify GCC's 'empty if-body' warning.  */
443 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
444 #  ifndef YYSTACK_ALLOC_MAXIMUM
445     /* The OS might guarantee only one guard page at the bottom of the stack,
446        and a page size can be as small as 4096 bytes.  So we cannot safely
447        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
448        to allow for a few compiler-allocated temporary stack slots.  */
449 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
450 #  endif
451 # else
452 #  define YYSTACK_ALLOC YYMALLOC
453 #  define YYSTACK_FREE YYFREE
454 #  ifndef YYSTACK_ALLOC_MAXIMUM
455 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
456 #  endif
457 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
458        && ! ((defined YYMALLOC || defined malloc) \
459              && (defined YYFREE || defined free)))
460 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
461 #   ifndef EXIT_SUCCESS
462 #    define EXIT_SUCCESS 0
463 #   endif
464 #  endif
465 #  ifndef YYMALLOC
466 #   define YYMALLOC malloc
467 #   if ! defined malloc && ! defined EXIT_SUCCESS
468 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
469 #   endif
470 #  endif
471 #  ifndef YYFREE
472 #   define YYFREE free
473 #   if ! defined free && ! defined EXIT_SUCCESS
474 void free (void *); /* INFRINGES ON USER NAME SPACE */
475 #   endif
476 #  endif
477 # endif
478 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
479 
480 
481 #if (! defined yyoverflow \
482      && (! defined __cplusplus \
483          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
484 
485 /* A type that is properly aligned for any stack member.  */
486 union yyalloc
487 {
488   yytype_int16 yyss_alloc;
489   YYSTYPE yyvs_alloc;
490 };
491 
492 /* The size of the maximum gap between one aligned stack and the next.  */
493 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
494 
495 /* The size of an array large to enough to hold all stacks, each with
496    N elements.  */
497 # define YYSTACK_BYTES(N) \
498      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
499       + YYSTACK_GAP_MAXIMUM)
500 
501 # define YYCOPY_NEEDED 1
502 
503 /* Relocate STACK from its old location to the new one.  The
504    local variables YYSIZE and YYSTACKSIZE give the old and new number of
505    elements in the stack, and YYPTR gives the new location of the
506    stack.  Advance YYPTR to a properly aligned location for the next
507    stack.  */
508 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
509     do                                                                  \
510       {                                                                 \
511         YYSIZE_T yynewbytes;                                            \
512         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
513         Stack = &yyptr->Stack_alloc;                                    \
514         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
515         yyptr += yynewbytes / sizeof (*yyptr);                          \
516       }                                                                 \
517     while (0)
518 
519 #endif
520 
521 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
522 /* Copy COUNT objects from SRC to DST.  The source and destination do
523    not overlap.  */
524 # ifndef YYCOPY
525 #  if defined __GNUC__ && 1 < __GNUC__
526 #   define YYCOPY(Dst, Src, Count) \
527       __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
528 #  else
529 #   define YYCOPY(Dst, Src, Count)              \
530       do                                        \
531         {                                       \
532           YYSIZE_T yyi;                         \
533           for (yyi = 0; yyi < (Count); yyi++)   \
534             (Dst)[yyi] = (Src)[yyi];            \
535         }                                       \
536       while (0)
537 #  endif
538 # endif
539 #endif /* !YYCOPY_NEEDED */
540 
541 /* YYFINAL -- State number of the termination state.  */
542 #define YYFINAL  69
543 /* YYLAST -- Last index in YYTABLE.  */
544 #define YYLAST   149
545 
546 /* YYNTOKENS -- Number of terminals.  */
547 #define YYNTOKENS  35
548 /* YYNNTS -- Number of nonterminals.  */
549 #define YYNNTS  27
550 /* YYNRULES -- Number of rules.  */
551 #define YYNRULES  99
552 /* YYNSTATES -- Number of states.  */
553 #define YYNSTATES  146
554 
555 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
556    by yylex, with out-of-bounds checking.  */
557 #define YYUNDEFTOK  2
558 #define YYMAXUTOK   285
559 
560 #define YYTRANSLATE(YYX)                                                \
561   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
562 
563 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
564    as returned by yylex, without out-of-bounds checking.  */
565 static const yytype_uint8 yytranslate[] =
566 {
567        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
568        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
569        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
570        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
571        2,     2,     2,     2,    32,     2,    31,     2,     2,     2,
572        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
573        2,    33,     2,     2,    34,     2,     2,     2,     2,     2,
574        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
575        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
576        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
577        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
578        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
579        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
580        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
581        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
582        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
583        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
584        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
585        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
586        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
587        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
588        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
589        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
590        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
591        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
592        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
593        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
594       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
595       25,    26,    27,    28,    29,    30
596 };
597 
598 #if YYDEBUG
599   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
600 static const yytype_uint16 yyrline[] =
601 {
602        0,   138,   138,   139,   143,   144,   145,   146,   147,   148,
603      149,   150,   151,   152,   153,   154,   155,   156,   160,   162,
604      163,   170,   177,   178,   181,   182,   183,   184,   185,   186,
605      187,   188,   191,   192,   196,   198,   200,   202,   204,   206,
606      211,   212,   216,   217,   221,   222,   226,   227,   229,   230,
607      234,   235,   236,   237,   241,   242,   243,   244,   245,   246,
608      247,   248,   249,   250,   251,   252,   259,   260,   261,   262,
609      263,   264,   265,   266,   267,   268,   271,   272,   278,   284,
610      290,   298,   299,   302,   303,   307,   308,   312,   313,   316,
611      317,   320,   321,   327,   335,   336,   339,   340,   343,   345
612 };
613 #endif
614 
615 #if YYDEBUG || YYERROR_VERBOSE || 0
616 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
617    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
618 static const char *const yytname[] =
619 {
620   "$end", "error", "$undefined", "NAME", "LIBRARY", "DESCRIPTION",
621   "STACKSIZE_K", "HEAPSIZE", "CODE", "DATAU", "DATAL", "SECTIONS",
622   "EXPORTS", "IMPORTS", "VERSIONK", "BASE", "CONSTANTU", "CONSTANTL",
623   "PRIVATEU", "PRIVATEL", "ALIGNCOMM", "READ", "WRITE", "EXECUTE",
624   "SHARED", "NONAMEU", "NONAMEL", "DIRECTIVE", "EQUAL", "ID", "DIGITS",
625   "'.'", "','", "'='", "'@'", "$accept", "start", "command", "explist",
626   "expline", "exp_opt_list", "exp_opt", "implist", "impline", "seclist",
627   "secline", "attr_list", "opt_comma", "opt_number", "attr",
628   "keyword_as_name", "opt_name2", "opt_name", "opt_equalequal_name",
629   "opt_ordinal", "opt_equal_name", "opt_base", "anylang_id", "opt_digits",
630   "opt_id", "NUMBER", "VMA", YY_NULLPTR
631 };
632 #endif
633 
634 # ifdef YYPRINT
635 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
636    (internal) symbol number NUM (which must be that of a token).  */
637 static const yytype_uint16 yytoknum[] =
638 {
639        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
640      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
641      275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
642      285,    46,    44,    61,    64
643 };
644 # endif
645 
646 #define YYPACT_NINF -82
647 
648 #define yypact_value_is_default(Yystate) \
649   (!!((Yystate) == (-82)))
650 
651 #define YYTABLE_NINF -48
652 
653 #define yytable_value_is_error(Yytable_value) \
654   0
655 
656   /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
657      STATE-NUM.  */
658 static const yytype_int8 yypact[] =
659 {
660      122,    11,    11,   -25,     9,     9,    53,    53,   -17,    11,
661       14,     9,   -18,    20,    95,   -82,   -82,   -82,   -82,   -82,
662      -82,   -82,   -82,   -82,   -82,   -82,   -82,   -82,   -82,   -82,
663      -82,   -82,   -82,   -82,   -82,   -82,   -82,   -82,    29,    11,
664       47,   -82,    67,    67,   -82,   -82,    54,    54,   -82,   -82,
665      -82,   -82,    48,   -82,    48,   -14,   -17,   -82,    11,   -82,
666       58,    50,    14,   -82,    61,   -82,    64,    33,   -82,   -82,
667      -82,    11,    47,   -82,    11,    63,   -82,   -82,     9,   -82,
668      -82,   -82,    53,   -82,    48,   -82,   -82,    11,    60,    76,
669       81,   -82,     9,   -82,    83,     9,   -82,   -82,    84,   -82,
670      -82,   -82,     9,    79,   -26,    85,   -82,   -82,    88,   -82,
671      -82,   -82,   -82,    36,    89,    90,   -82,    55,   -82,   -82,
672      -82,   -82,   -82,   -82,   -82,   -82,   -82,   -82,    79,    79,
673      -82,    92,    13,    92,    92,    36,   -82,    59,   -82,   -82,
674      -82,   -82,    92,    92,   -82,   -82
675 };
676 
677   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
678      Performed when YYTABLE does not specify something else to do.  Zero
679      means the default is an error.  */
680 static const yytype_uint8 yydefact[] =
681 {
682        0,    82,    82,     0,     0,     0,     0,     0,     0,    18,
683        0,     0,     0,     0,     0,     3,    66,    60,    73,    64,
684       55,    58,    59,    63,    65,    74,    54,    56,    57,    69,
685       70,    71,    75,    62,    72,    67,    68,    61,    76,     0,
686        0,    81,    90,    90,     6,    98,    49,    49,    50,    51,
687       52,    53,     9,    45,    10,     0,    11,    41,    12,    19,
688       88,     0,    13,    33,    14,    91,     0,     0,    16,     1,
689        2,     0,    77,    78,     0,     0,     4,     5,     0,     7,
690        8,    46,     0,    43,    42,    40,    20,     0,    86,     0,
691        0,    32,     0,    92,    95,     0,    80,    79,     0,    48,
692       44,    87,     0,    47,    84,     0,    15,    94,    97,    17,
693       99,    89,    85,    23,     0,     0,    39,     0,    96,    93,
694       28,    29,    26,    27,    30,    31,    24,    25,    47,    47,
695       83,    84,    84,    84,    84,    23,    38,     0,    36,    37,
696       21,    22,    84,    84,    34,    35
697 };
698 
699   /* YYPGOTO[NTERM-NUM].  */
700 static const yytype_int16 yypgoto[] =
701 {
702      -82,   -82,   107,   -82,    65,   -11,   -82,   -82,    75,   -82,
703       82,    -4,   -81,    93,    57,   102,    -8,   141,   -75,   -82,
704      -82,   101,   -82,   -82,   -82,    -5,   -82
705 };
706 
707   /* YYDEFGOTO[NTERM-NUM].  */
708 static const yytype_int16 yydefgoto[] =
709 {
710       -1,    14,    15,    58,    59,   128,   129,    62,    63,    56,
711       57,    52,    82,    79,    53,    40,    41,    42,   116,   103,
712       88,    76,    67,   108,   119,    46,   111
713 };
714 
715   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
716      positive, shift that token.  If negative, reduce the rule whose
717      number is the opposite.  If YYTABLE_NINF, syntax error.  */
718 static const yytype_int16 yytable[] =
719 {
720       47,    60,   114,    54,    44,   115,    64,    48,    49,    50,
721       51,    65,    55,    66,    16,    83,    17,    18,    19,    20,
722       21,    22,   113,    23,    24,    25,    26,    27,    28,    29,
723       30,    73,    31,    32,    33,    34,    35,    36,    37,    45,
724       38,   114,    39,    61,   137,   120,   121,   134,   135,    68,
725       60,    84,   122,   123,   124,   125,   136,   138,   139,   140,
726       71,   126,   127,    96,    94,    95,    97,   144,   145,   -47,
727      -47,   -47,   -47,    99,    48,    49,    50,    51,    74,   101,
728       81,    89,    75,    90,   132,    45,    78,   106,   142,    45,
729      109,    87,    92,    93,   102,    69,    98,   112,     1,     2,
730        3,     4,     5,     6,     7,   104,     8,     9,    10,    11,
731      105,    81,   133,   107,   110,    12,   117,   118,   130,   131,
732      114,    70,    13,    86,   141,     1,     2,     3,     4,     5,
733        6,     7,   143,     8,     9,    10,    11,    91,    85,   100,
734       80,    72,    12,    43,    77,     0,     0,     0,     0,    13
735 };
736 
737 static const yytype_int16 yycheck[] =
738 {
739        5,     9,    28,     7,    29,    31,    11,    21,    22,    23,
740       24,    29,    29,    31,     3,    29,     5,     6,     7,     8,
741        9,    10,   103,    12,    13,    14,    15,    16,    17,    18,
742       19,    39,    21,    22,    23,    24,    25,    26,    27,    30,
743       29,    28,    31,    29,    31,     9,    10,   128,   129,    29,
744       58,    55,    16,    17,    18,    19,   131,   132,   133,   134,
745       31,    25,    26,    71,    31,    32,    74,   142,   143,    21,
746       22,    23,    24,    78,    21,    22,    23,    24,    31,    87,
747       32,    31,    15,    33,    29,    30,    32,    92,    29,    30,
748       95,    33,    31,    29,    34,     0,    33,   102,     3,     4,
749        5,     6,     7,     8,     9,    29,    11,    12,    13,    14,
750       29,    32,   117,    30,    30,    20,    31,    29,    29,    29,
751       28,    14,    27,    58,   135,     3,     4,     5,     6,     7,
752        8,     9,   137,    11,    12,    13,    14,    62,    56,    82,
753       47,    39,    20,     2,    43,    -1,    -1,    -1,    -1,    27
754 };
755 
756   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
757      symbol of state STATE-NUM.  */
758 static const yytype_uint8 yystos[] =
759 {
760        0,     3,     4,     5,     6,     7,     8,     9,    11,    12,
761       13,    14,    20,    27,    36,    37,     3,     5,     6,     7,
762        8,     9,    10,    12,    13,    14,    15,    16,    17,    18,
763       19,    21,    22,    23,    24,    25,    26,    27,    29,    31,
764       50,    51,    52,    52,    29,    30,    60,    60,    21,    22,
765       23,    24,    46,    49,    46,    29,    44,    45,    38,    39,
766       51,    29,    42,    43,    60,    29,    31,    57,    29,     0,
767       37,    31,    50,    51,    31,    15,    56,    56,    32,    48,
768       48,    32,    47,    29,    46,    45,    39,    33,    55,    31,
769       33,    43,    31,    29,    31,    32,    51,    51,    33,    60,
770       49,    51,    34,    54,    29,    29,    60,    30,    58,    60,
771       30,    61,    60,    47,    28,    31,    53,    31,    29,    59,
772        9,    10,    16,    17,    18,    19,    25,    26,    40,    41,
773       29,    29,    29,    60,    47,    47,    53,    31,    53,    53,
774       53,    40,    29,    60,    53,    53
775 };
776 
777   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
778 static const yytype_uint8 yyr1[] =
779 {
780        0,    35,    36,    36,    37,    37,    37,    37,    37,    37,
781       37,    37,    37,    37,    37,    37,    37,    37,    38,    38,
782       38,    39,    40,    40,    41,    41,    41,    41,    41,    41,
783       41,    41,    42,    42,    43,    43,    43,    43,    43,    43,
784       44,    44,    45,    45,    46,    46,    47,    47,    48,    48,
785       49,    49,    49,    49,    50,    50,    50,    50,    50,    50,
786       50,    50,    50,    50,    50,    50,    50,    50,    50,    50,
787       50,    50,    50,    50,    50,    50,    51,    51,    51,    51,
788       51,    52,    52,    53,    53,    54,    54,    55,    55,    56,
789       56,    57,    57,    57,    58,    58,    59,    59,    60,    61
790 };
791 
792   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
793 static const yytype_uint8 yyr2[] =
794 {
795        0,     2,     2,     1,     3,     3,     2,     3,     3,     2,
796        2,     2,     2,     2,     2,     4,     2,     4,     0,     1,
797        2,     7,     3,     0,     1,     1,     1,     1,     1,     1,
798        1,     1,     2,     1,     8,     8,     6,     6,     6,     4,
799        2,     1,     2,     2,     3,     1,     1,     0,     2,     0,
800        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
801        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
802        1,     1,     1,     1,     1,     1,     1,     2,     2,     3,
803        3,     1,     0,     2,     0,     2,     0,     2,     0,     3,
804        0,     1,     2,     4,     1,     0,     1,     0,     1,     1
805 };
806 
807 
808 #define yyerrok         (yyerrstatus = 0)
809 #define yyclearin       (yychar = YYEMPTY)
810 #define YYEMPTY         (-2)
811 #define YYEOF           0
812 
813 #define YYACCEPT        goto yyacceptlab
814 #define YYABORT         goto yyabortlab
815 #define YYERROR         goto yyerrorlab
816 
817 
818 #define YYRECOVERING()  (!!yyerrstatus)
819 
820 #define YYBACKUP(Token, Value)                                  \
821 do                                                              \
822   if (yychar == YYEMPTY)                                        \
823     {                                                           \
824       yychar = (Token);                                         \
825       yylval = (Value);                                         \
826       YYPOPSTACK (yylen);                                       \
827       yystate = *yyssp;                                         \
828       goto yybackup;                                            \
829     }                                                           \
830   else                                                          \
831     {                                                           \
832       yyerror (YY_("syntax error: cannot back up")); \
833       YYERROR;                                                  \
834     }                                                           \
835 while (0)
836 
837 /* Error token number */
838 #define YYTERROR        1
839 #define YYERRCODE       256
840 
841 
842 
843 /* Enable debugging if requested.  */
844 #if YYDEBUG
845 
846 # ifndef YYFPRINTF
847 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
848 #  define YYFPRINTF fprintf
849 # endif
850 
851 # define YYDPRINTF(Args)                        \
852 do {                                            \
853   if (yydebug)                                  \
854     YYFPRINTF Args;                             \
855 } while (0)
856 
857 /* This macro is provided for backward compatibility. */
858 #ifndef YY_LOCATION_PRINT
859 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
860 #endif
861 
862 
863 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
864 do {                                                                      \
865   if (yydebug)                                                            \
866     {                                                                     \
867       YYFPRINTF (stderr, "%s ", Title);                                   \
868       yy_symbol_print (stderr,                                            \
869                   Type, Value); \
870       YYFPRINTF (stderr, "\n");                                           \
871     }                                                                     \
872 } while (0)
873 
874 
875 /*----------------------------------------.
876 | Print this symbol's value on YYOUTPUT.  |
877 `----------------------------------------*/
878 
879 static void
880 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
881 {
882   FILE *yyo = yyoutput;
883   YYUSE (yyo);
884   if (!yyvaluep)
885     return;
886 # ifdef YYPRINT
887   if (yytype < YYNTOKENS)
888     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
889 # endif
890   YYUSE (yytype);
891 }
892 
893 
894 /*--------------------------------.
895 | Print this symbol on YYOUTPUT.  |
896 `--------------------------------*/
897 
898 static void
899 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
900 {
901   YYFPRINTF (yyoutput, "%s %s (",
902              yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
903 
904   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
905   YYFPRINTF (yyoutput, ")");
906 }
907 
908 /*------------------------------------------------------------------.
909 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
910 | TOP (included).                                                   |
911 `------------------------------------------------------------------*/
912 
913 static void
914 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
915 {
916   YYFPRINTF (stderr, "Stack now");
917   for (; yybottom <= yytop; yybottom++)
918     {
919       int yybot = *yybottom;
920       YYFPRINTF (stderr, " %d", yybot);
921     }
922   YYFPRINTF (stderr, "\n");
923 }
924 
925 # define YY_STACK_PRINT(Bottom, Top)                            \
926 do {                                                            \
927   if (yydebug)                                                  \
928     yy_stack_print ((Bottom), (Top));                           \
929 } while (0)
930 
931 
932 /*------------------------------------------------.
933 | Report that the YYRULE is going to be reduced.  |
934 `------------------------------------------------*/
935 
936 static void
937 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
938 {
939   unsigned long int yylno = yyrline[yyrule];
940   int yynrhs = yyr2[yyrule];
941   int yyi;
942   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
943              yyrule - 1, yylno);
944   /* The symbols being reduced.  */
945   for (yyi = 0; yyi < yynrhs; yyi++)
946     {
947       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
948       yy_symbol_print (stderr,
949                        yystos[yyssp[yyi + 1 - yynrhs]],
950                        &(yyvsp[(yyi + 1) - (yynrhs)])
951                                               );
952       YYFPRINTF (stderr, "\n");
953     }
954 }
955 
956 # define YY_REDUCE_PRINT(Rule)          \
957 do {                                    \
958   if (yydebug)                          \
959     yy_reduce_print (yyssp, yyvsp, Rule); \
960 } while (0)
961 
962 /* Nonzero means print parse trace.  It is left uninitialized so that
963    multiple parsers can coexist.  */
964 int yydebug;
965 #else /* !YYDEBUG */
966 # define YYDPRINTF(Args)
967 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
968 # define YY_STACK_PRINT(Bottom, Top)
969 # define YY_REDUCE_PRINT(Rule)
970 #endif /* !YYDEBUG */
971 
972 
973 /* YYINITDEPTH -- initial size of the parser's stacks.  */
974 #ifndef YYINITDEPTH
975 # define YYINITDEPTH 200
976 #endif
977 
978 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
979    if the built-in stack extension method is used).
980 
981    Do not make this value too large; the results are undefined if
982    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
983    evaluated with infinite-precision integer arithmetic.  */
984 
985 #ifndef YYMAXDEPTH
986 # define YYMAXDEPTH 10000
987 #endif
988 
989 
990 #if YYERROR_VERBOSE
991 
992 # ifndef yystrlen
993 #  if defined __GLIBC__ && defined _STRING_H
994 #   define yystrlen strlen
995 #  else
996 /* Return the length of YYSTR.  */
997 static YYSIZE_T
998 yystrlen (const char *yystr)
999 {
1000   YYSIZE_T yylen;
1001   for (yylen = 0; yystr[yylen]; yylen++)
1002     continue;
1003   return yylen;
1004 }
1005 #  endif
1006 # endif
1007 
1008 # ifndef yystpcpy
1009 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1010 #   define yystpcpy stpcpy
1011 #  else
1012 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1013    YYDEST.  */
1014 static char *
1015 yystpcpy (char *yydest, const char *yysrc)
1016 {
1017   char *yyd = yydest;
1018   const char *yys = yysrc;
1019 
1020   while ((*yyd++ = *yys++) != '\0')
1021     continue;
1022 
1023   return yyd - 1;
1024 }
1025 #  endif
1026 # endif
1027 
1028 # ifndef yytnamerr
1029 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1030    quotes and backslashes, so that it's suitable for yyerror.  The
1031    heuristic is that double-quoting is unnecessary unless the string
1032    contains an apostrophe, a comma, or backslash (other than
1033    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1034    null, do not copy; instead, return the length of what the result
1035    would have been.  */
1036 static YYSIZE_T
1037 yytnamerr (char *yyres, const char *yystr)
1038 {
1039   if (*yystr == '"')
1040     {
1041       YYSIZE_T yyn = 0;
1042       char const *yyp = yystr;
1043 
1044       for (;;)
1045         switch (*++yyp)
1046           {
1047           case '\'':
1048           case ',':
1049             goto do_not_strip_quotes;
1050 
1051           case '\\':
1052             if (*++yyp != '\\')
1053               goto do_not_strip_quotes;
1054             /* Fall through.  */
1055           default:
1056             if (yyres)
1057               yyres[yyn] = *yyp;
1058             yyn++;
1059             break;
1060 
1061           case '"':
1062             if (yyres)
1063               yyres[yyn] = '\0';
1064             return yyn;
1065           }
1066     do_not_strip_quotes: ;
1067     }
1068 
1069   if (! yyres)
1070     return yystrlen (yystr);
1071 
1072   return yystpcpy (yyres, yystr) - yyres;
1073 }
1074 # endif
1075 
1076 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1077    about the unexpected token YYTOKEN for the state stack whose top is
1078    YYSSP.
1079 
1080    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
1081    not large enough to hold the message.  In that case, also set
1082    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
1083    required number of bytes is too large to store.  */
1084 static int
1085 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1086                 yytype_int16 *yyssp, int yytoken)
1087 {
1088   YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1089   YYSIZE_T yysize = yysize0;
1090   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1091   /* Internationalized format string. */
1092   const char *yyformat = YY_NULLPTR;
1093   /* Arguments of yyformat. */
1094   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1095   /* Number of reported tokens (one for the "unexpected", one per
1096      "expected"). */
1097   int yycount = 0;
1098 
1099   /* There are many possibilities here to consider:
1100      - If this state is a consistent state with a default action, then
1101        the only way this function was invoked is if the default action
1102        is an error action.  In that case, don't check for expected
1103        tokens because there are none.
1104      - The only way there can be no lookahead present (in yychar) is if
1105        this state is a consistent state with a default action.  Thus,
1106        detecting the absence of a lookahead is sufficient to determine
1107        that there is no unexpected or expected token to report.  In that
1108        case, just report a simple "syntax error".
1109      - Don't assume there isn't a lookahead just because this state is a
1110        consistent state with a default action.  There might have been a
1111        previous inconsistent state, consistent state with a non-default
1112        action, or user semantic action that manipulated yychar.
1113      - Of course, the expected token list depends on states to have
1114        correct lookahead information, and it depends on the parser not
1115        to perform extra reductions after fetching a lookahead from the
1116        scanner and before detecting a syntax error.  Thus, state merging
1117        (from LALR or IELR) and default reductions corrupt the expected
1118        token list.  However, the list is correct for canonical LR with
1119        one exception: it will still contain any token that will not be
1120        accepted due to an error action in a later state.
1121   */
1122   if (yytoken != YYEMPTY)
1123     {
1124       int yyn = yypact[*yyssp];
1125       yyarg[yycount++] = yytname[yytoken];
1126       if (!yypact_value_is_default (yyn))
1127         {
1128           /* Start YYX at -YYN if negative to avoid negative indexes in
1129              YYCHECK.  In other words, skip the first -YYN actions for
1130              this state because they are default actions.  */
1131           int yyxbegin = yyn < 0 ? -yyn : 0;
1132           /* Stay within bounds of both yycheck and yytname.  */
1133           int yychecklim = YYLAST - yyn + 1;
1134           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1135           int yyx;
1136 
1137           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1138             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1139                 && !yytable_value_is_error (yytable[yyx + yyn]))
1140               {
1141                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1142                   {
1143                     yycount = 1;
1144                     yysize = yysize0;
1145                     break;
1146                   }
1147                 yyarg[yycount++] = yytname[yyx];
1148                 {
1149                   YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1150                   if (! (yysize <= yysize1
1151                          && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1152                     return 2;
1153                   yysize = yysize1;
1154                 }
1155               }
1156         }
1157     }
1158 
1159   switch (yycount)
1160     {
1161 # define YYCASE_(N, S)                      \
1162       case N:                               \
1163         yyformat = S;                       \
1164       break
1165       YYCASE_(0, YY_("syntax error"));
1166       YYCASE_(1, YY_("syntax error, unexpected %s"));
1167       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1168       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1169       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1170       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1171 # undef YYCASE_
1172     }
1173 
1174   {
1175     YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1176     if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1177       return 2;
1178     yysize = yysize1;
1179   }
1180 
1181   if (*yymsg_alloc < yysize)
1182     {
1183       *yymsg_alloc = 2 * yysize;
1184       if (! (yysize <= *yymsg_alloc
1185              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1186         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1187       return 1;
1188     }
1189 
1190   /* Avoid sprintf, as that infringes on the user's name space.
1191      Don't have undefined behavior even if the translation
1192      produced a string with the wrong number of "%s"s.  */
1193   {
1194     char *yyp = *yymsg;
1195     int yyi = 0;
1196     while ((*yyp = *yyformat) != '\0')
1197       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1198         {
1199           yyp += yytnamerr (yyp, yyarg[yyi++]);
1200           yyformat += 2;
1201         }
1202       else
1203         {
1204           yyp++;
1205           yyformat++;
1206         }
1207   }
1208   return 0;
1209 }
1210 #endif /* YYERROR_VERBOSE */
1211 
1212 /*-----------------------------------------------.
1213 | Release the memory associated to this symbol.  |
1214 `-----------------------------------------------*/
1215 
1216 static void
1217 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1218 {
1219   YYUSE (yyvaluep);
1220   if (!yymsg)
1221     yymsg = "Deleting";
1222   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1223 
1224   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1225   YYUSE (yytype);
1226   YY_IGNORE_MAYBE_UNINITIALIZED_END
1227 }
1228 
1229 
1230 
1231 
1232 /* The lookahead symbol.  */
1233 int yychar;
1234 
1235 /* The semantic value of the lookahead symbol.  */
1236 YYSTYPE yylval;
1237 /* Number of syntax errors so far.  */
1238 int yynerrs;
1239 
1240 
1241 /*----------.
1242 | yyparse.  |
1243 `----------*/
1244 
1245 int
1246 yyparse (void)
1247 {
1248     int yystate;
1249     /* Number of tokens to shift before error messages enabled.  */
1250     int yyerrstatus;
1251 
1252     /* The stacks and their tools:
1253        'yyss': related to states.
1254        'yyvs': related to semantic values.
1255 
1256        Refer to the stacks through separate pointers, to allow yyoverflow
1257        to reallocate them elsewhere.  */
1258 
1259     /* The state stack.  */
1260     yytype_int16 yyssa[YYINITDEPTH];
1261     yytype_int16 *yyss;
1262     yytype_int16 *yyssp;
1263 
1264     /* The semantic value stack.  */
1265     YYSTYPE yyvsa[YYINITDEPTH];
1266     YYSTYPE *yyvs;
1267     YYSTYPE *yyvsp;
1268 
1269     YYSIZE_T yystacksize;
1270 
1271   int yyn;
1272   int yyresult;
1273   /* Lookahead token as an internal (translated) token number.  */
1274   int yytoken = 0;
1275   /* The variables used to return semantic value and location from the
1276      action routines.  */
1277   YYSTYPE yyval;
1278 
1279 #if YYERROR_VERBOSE
1280   /* Buffer for error messages, and its allocated size.  */
1281   char yymsgbuf[128];
1282   char *yymsg = yymsgbuf;
1283   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1284 #endif
1285 
1286 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1287 
1288   /* The number of symbols on the RHS of the reduced rule.
1289      Keep to zero when no symbol should be popped.  */
1290   int yylen = 0;
1291 
1292   yyssp = yyss = yyssa;
1293   yyvsp = yyvs = yyvsa;
1294   yystacksize = YYINITDEPTH;
1295 
1296   YYDPRINTF ((stderr, "Starting parse\n"));
1297 
1298   yystate = 0;
1299   yyerrstatus = 0;
1300   yynerrs = 0;
1301   yychar = YYEMPTY; /* Cause a token to be read.  */
1302   goto yysetstate;
1303 
1304 /*------------------------------------------------------------.
1305 | yynewstate -- Push a new state, which is found in yystate.  |
1306 `------------------------------------------------------------*/
1307  yynewstate:
1308   /* In all cases, when you get here, the value and location stacks
1309      have just been pushed.  So pushing a state here evens the stacks.  */
1310   yyssp++;
1311 
1312  yysetstate:
1313   *yyssp = yystate;
1314 
1315   if (yyss + yystacksize - 1 <= yyssp)
1316     {
1317       /* Get the current used size of the three stacks, in elements.  */
1318       YYSIZE_T yysize = yyssp - yyss + 1;
1319 
1320 #ifdef yyoverflow
1321       {
1322         /* Give user a chance to reallocate the stack.  Use copies of
1323            these so that the &'s don't force the real ones into
1324            memory.  */
1325         YYSTYPE *yyvs1 = yyvs;
1326         yytype_int16 *yyss1 = yyss;
1327 
1328         /* Each stack pointer address is followed by the size of the
1329            data in use in that stack, in bytes.  This used to be a
1330            conditional around just the two extra args, but that might
1331            be undefined if yyoverflow is a macro.  */
1332         yyoverflow (YY_("memory exhausted"),
1333                     &yyss1, yysize * sizeof (*yyssp),
1334                     &yyvs1, yysize * sizeof (*yyvsp),
1335                     &yystacksize);
1336 
1337         yyss = yyss1;
1338         yyvs = yyvs1;
1339       }
1340 #else /* no yyoverflow */
1341 # ifndef YYSTACK_RELOCATE
1342       goto yyexhaustedlab;
1343 # else
1344       /* Extend the stack our own way.  */
1345       if (YYMAXDEPTH <= yystacksize)
1346         goto yyexhaustedlab;
1347       yystacksize *= 2;
1348       if (YYMAXDEPTH < yystacksize)
1349         yystacksize = YYMAXDEPTH;
1350 
1351       {
1352         yytype_int16 *yyss1 = yyss;
1353         union yyalloc *yyptr =
1354           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1355         if (! yyptr)
1356           goto yyexhaustedlab;
1357         YYSTACK_RELOCATE (yyss_alloc, yyss);
1358         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1359 #  undef YYSTACK_RELOCATE
1360         if (yyss1 != yyssa)
1361           YYSTACK_FREE (yyss1);
1362       }
1363 # endif
1364 #endif /* no yyoverflow */
1365 
1366       yyssp = yyss + yysize - 1;
1367       yyvsp = yyvs + yysize - 1;
1368 
1369       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1370                   (unsigned long int) yystacksize));
1371 
1372       if (yyss + yystacksize - 1 <= yyssp)
1373         YYABORT;
1374     }
1375 
1376   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1377 
1378   if (yystate == YYFINAL)
1379     YYACCEPT;
1380 
1381   goto yybackup;
1382 
1383 /*-----------.
1384 | yybackup.  |
1385 `-----------*/
1386 yybackup:
1387 
1388   /* Do appropriate processing given the current state.  Read a
1389      lookahead token if we need one and don't already have one.  */
1390 
1391   /* First try to decide what to do without reference to lookahead token.  */
1392   yyn = yypact[yystate];
1393   if (yypact_value_is_default (yyn))
1394     goto yydefault;
1395 
1396   /* Not known => get a lookahead token if don't already have one.  */
1397 
1398   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1399   if (yychar == YYEMPTY)
1400     {
1401       YYDPRINTF ((stderr, "Reading a token: "));
1402       yychar = yylex ();
1403     }
1404 
1405   if (yychar <= YYEOF)
1406     {
1407       yychar = yytoken = YYEOF;
1408       YYDPRINTF ((stderr, "Now at end of input.\n"));
1409     }
1410   else
1411     {
1412       yytoken = YYTRANSLATE (yychar);
1413       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1414     }
1415 
1416   /* If the proper action on seeing token YYTOKEN is to reduce or to
1417      detect an error, take that action.  */
1418   yyn += yytoken;
1419   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1420     goto yydefault;
1421   yyn = yytable[yyn];
1422   if (yyn <= 0)
1423     {
1424       if (yytable_value_is_error (yyn))
1425         goto yyerrlab;
1426       yyn = -yyn;
1427       goto yyreduce;
1428     }
1429 
1430   /* Count tokens shifted since error; after three, turn off error
1431      status.  */
1432   if (yyerrstatus)
1433     yyerrstatus--;
1434 
1435   /* Shift the lookahead token.  */
1436   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1437 
1438   /* Discard the shifted token.  */
1439   yychar = YYEMPTY;
1440 
1441   yystate = yyn;
1442   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1443   *++yyvsp = yylval;
1444   YY_IGNORE_MAYBE_UNINITIALIZED_END
1445 
1446   goto yynewstate;
1447 
1448 
1449 /*-----------------------------------------------------------.
1450 | yydefault -- do the default action for the current state.  |
1451 `-----------------------------------------------------------*/
1452 yydefault:
1453   yyn = yydefact[yystate];
1454   if (yyn == 0)
1455     goto yyerrlab;
1456   goto yyreduce;
1457 
1458 
1459 /*-----------------------------.
1460 | yyreduce -- Do a reduction.  |
1461 `-----------------------------*/
1462 yyreduce:
1463   /* yyn is the number of a rule to reduce with.  */
1464   yylen = yyr2[yyn];
1465 
1466   /* If YYLEN is nonzero, implement the default value of the action:
1467      '$$ = $1'.
1468 
1469      Otherwise, the following line sets YYVAL to garbage.
1470      This behavior is undocumented and Bison
1471      users should not rely upon it.  Assigning to YYVAL
1472      unconditionally makes the parser a bit smaller, and it avoids a
1473      GCC warning that YYVAL may be used uninitialized.  */
1474   yyval = yyvsp[1-yylen];
1475 
1476 
1477   YY_REDUCE_PRINT (yyn);
1478   switch (yyn)
1479     {
1480         case 4:
1481 #line 143 "deffilep.y" /* yacc.c:1646  */
1482     { def_image_name ((yyvsp[-1].id), (yyvsp[0].vma), 0); }
1483 #line 1484 "deffilep.c" /* yacc.c:1646  */
1484     break;
1485 
1486   case 5:
1487 #line 144 "deffilep.y" /* yacc.c:1646  */
1488     { def_image_name ((yyvsp[-1].id), (yyvsp[0].vma), 1); }
1489 #line 1490 "deffilep.c" /* yacc.c:1646  */
1490     break;
1491 
1492   case 6:
1493 #line 145 "deffilep.y" /* yacc.c:1646  */
1494     { def_description ((yyvsp[0].id));}
1495 #line 1496 "deffilep.c" /* yacc.c:1646  */
1496     break;
1497 
1498   case 7:
1499 #line 146 "deffilep.y" /* yacc.c:1646  */
1500     { def_stacksize ((yyvsp[-1].number), (yyvsp[0].number));}
1501 #line 1502 "deffilep.c" /* yacc.c:1646  */
1502     break;
1503 
1504   case 8:
1505 #line 147 "deffilep.y" /* yacc.c:1646  */
1506     { def_heapsize ((yyvsp[-1].number), (yyvsp[0].number));}
1507 #line 1508 "deffilep.c" /* yacc.c:1646  */
1508     break;
1509 
1510   case 9:
1511 #line 148 "deffilep.y" /* yacc.c:1646  */
1512     { def_section ("CODE", (yyvsp[0].number));}
1513 #line 1514 "deffilep.c" /* yacc.c:1646  */
1514     break;
1515 
1516   case 10:
1517 #line 149 "deffilep.y" /* yacc.c:1646  */
1518     { def_section ("DATA", (yyvsp[0].number));}
1519 #line 1520 "deffilep.c" /* yacc.c:1646  */
1520     break;
1521 
1522   case 14:
1523 #line 153 "deffilep.y" /* yacc.c:1646  */
1524     { def_version ((yyvsp[0].number), 0);}
1525 #line 1526 "deffilep.c" /* yacc.c:1646  */
1526     break;
1527 
1528   case 15:
1529 #line 154 "deffilep.y" /* yacc.c:1646  */
1530     { def_version ((yyvsp[-2].number), (yyvsp[0].number));}
1531 #line 1532 "deffilep.c" /* yacc.c:1646  */
1532     break;
1533 
1534   case 16:
1535 #line 155 "deffilep.y" /* yacc.c:1646  */
1536     { def_directive ((yyvsp[0].id));}
1537 #line 1538 "deffilep.c" /* yacc.c:1646  */
1538     break;
1539 
1540   case 17:
1541 #line 156 "deffilep.y" /* yacc.c:1646  */
1542     { def_aligncomm ((yyvsp[-2].id), (yyvsp[0].number));}
1543 #line 1544 "deffilep.c" /* yacc.c:1646  */
1544     break;
1545 
1546   case 21:
1547 #line 171 "deffilep.y" /* yacc.c:1646  */
1548     { def_exports ((yyvsp[-6].id), (yyvsp[-5].id), (yyvsp[-4].number), (yyvsp[-2].number), (yyvsp[0].id)); }
1549 #line 1550 "deffilep.c" /* yacc.c:1646  */
1550     break;
1551 
1552   case 22:
1553 #line 177 "deffilep.y" /* yacc.c:1646  */
1554     { (yyval.number) = (yyvsp[-2].number) | (yyvsp[0].number); }
1555 #line 1556 "deffilep.c" /* yacc.c:1646  */
1556     break;
1557 
1558   case 23:
1559 #line 178 "deffilep.y" /* yacc.c:1646  */
1560     { (yyval.number) = 0; }
1561 #line 1562 "deffilep.c" /* yacc.c:1646  */
1562     break;
1563 
1564   case 24:
1565 #line 181 "deffilep.y" /* yacc.c:1646  */
1566     { (yyval.number) = 1; }
1567 #line 1568 "deffilep.c" /* yacc.c:1646  */
1568     break;
1569 
1570   case 25:
1571 #line 182 "deffilep.y" /* yacc.c:1646  */
1572     { (yyval.number) = 1; }
1573 #line 1574 "deffilep.c" /* yacc.c:1646  */
1574     break;
1575 
1576   case 26:
1577 #line 183 "deffilep.y" /* yacc.c:1646  */
1578     { (yyval.number) = 2; }
1579 #line 1580 "deffilep.c" /* yacc.c:1646  */
1580     break;
1581 
1582   case 27:
1583 #line 184 "deffilep.y" /* yacc.c:1646  */
1584     { (yyval.number) = 2; }
1585 #line 1586 "deffilep.c" /* yacc.c:1646  */
1586     break;
1587 
1588   case 28:
1589 #line 185 "deffilep.y" /* yacc.c:1646  */
1590     { (yyval.number) = 4; }
1591 #line 1592 "deffilep.c" /* yacc.c:1646  */
1592     break;
1593 
1594   case 29:
1595 #line 186 "deffilep.y" /* yacc.c:1646  */
1596     { (yyval.number) = 4; }
1597 #line 1598 "deffilep.c" /* yacc.c:1646  */
1598     break;
1599 
1600   case 30:
1601 #line 187 "deffilep.y" /* yacc.c:1646  */
1602     { (yyval.number) = 8; }
1603 #line 1604 "deffilep.c" /* yacc.c:1646  */
1604     break;
1605 
1606   case 31:
1607 #line 188 "deffilep.y" /* yacc.c:1646  */
1608     { (yyval.number) = 8; }
1609 #line 1610 "deffilep.c" /* yacc.c:1646  */
1610     break;
1611 
1612   case 34:
1613 #line 197 "deffilep.y" /* yacc.c:1646  */
1614     { def_import ((yyvsp[-7].id), (yyvsp[-5].id), (yyvsp[-3].id), (yyvsp[-1].id), -1, (yyvsp[0].id)); }
1615 #line 1616 "deffilep.c" /* yacc.c:1646  */
1616     break;
1617 
1618   case 35:
1619 #line 199 "deffilep.y" /* yacc.c:1646  */
1620     { def_import ((yyvsp[-7].id), (yyvsp[-5].id), (yyvsp[-3].id),  0, (yyvsp[-1].number), (yyvsp[0].id)); }
1621 #line 1622 "deffilep.c" /* yacc.c:1646  */
1622     break;
1623 
1624   case 36:
1625 #line 201 "deffilep.y" /* yacc.c:1646  */
1626     { def_import ((yyvsp[-5].id), (yyvsp[-3].id),	0, (yyvsp[-1].id), -1, (yyvsp[0].id)); }
1627 #line 1628 "deffilep.c" /* yacc.c:1646  */
1628     break;
1629 
1630   case 37:
1631 #line 203 "deffilep.y" /* yacc.c:1646  */
1632     { def_import ((yyvsp[-5].id), (yyvsp[-3].id),	0,  0, (yyvsp[-1].number), (yyvsp[0].id)); }
1633 #line 1634 "deffilep.c" /* yacc.c:1646  */
1634     break;
1635 
1636   case 38:
1637 #line 205 "deffilep.y" /* yacc.c:1646  */
1638     { def_import( 0, (yyvsp[-5].id), (yyvsp[-3].id), (yyvsp[-1].id), -1, (yyvsp[0].id)); }
1639 #line 1640 "deffilep.c" /* yacc.c:1646  */
1640     break;
1641 
1642   case 39:
1643 #line 207 "deffilep.y" /* yacc.c:1646  */
1644     { def_import ( 0, (yyvsp[-3].id),	0, (yyvsp[-1].id), -1, (yyvsp[0].id)); }
1645 #line 1646 "deffilep.c" /* yacc.c:1646  */
1646     break;
1647 
1648   case 42:
1649 #line 216 "deffilep.y" /* yacc.c:1646  */
1650     { def_section ((yyvsp[-1].id), (yyvsp[0].number));}
1651 #line 1652 "deffilep.c" /* yacc.c:1646  */
1652     break;
1653 
1654   case 43:
1655 #line 217 "deffilep.y" /* yacc.c:1646  */
1656     { def_section_alt ((yyvsp[-1].id), (yyvsp[0].id));}
1657 #line 1658 "deffilep.c" /* yacc.c:1646  */
1658     break;
1659 
1660   case 44:
1661 #line 221 "deffilep.y" /* yacc.c:1646  */
1662     { (yyval.number) = (yyvsp[-2].number) | (yyvsp[0].number); }
1663 #line 1664 "deffilep.c" /* yacc.c:1646  */
1664     break;
1665 
1666   case 45:
1667 #line 222 "deffilep.y" /* yacc.c:1646  */
1668     { (yyval.number) = (yyvsp[0].number); }
1669 #line 1670 "deffilep.c" /* yacc.c:1646  */
1670     break;
1671 
1672   case 48:
1673 #line 229 "deffilep.y" /* yacc.c:1646  */
1674     { (yyval.number)=(yyvsp[0].number);}
1675 #line 1676 "deffilep.c" /* yacc.c:1646  */
1676     break;
1677 
1678   case 49:
1679 #line 230 "deffilep.y" /* yacc.c:1646  */
1680     { (yyval.number)=-1;}
1681 #line 1682 "deffilep.c" /* yacc.c:1646  */
1682     break;
1683 
1684   case 50:
1685 #line 234 "deffilep.y" /* yacc.c:1646  */
1686     { (yyval.number) = 1;}
1687 #line 1688 "deffilep.c" /* yacc.c:1646  */
1688     break;
1689 
1690   case 51:
1691 #line 235 "deffilep.y" /* yacc.c:1646  */
1692     { (yyval.number) = 2;}
1693 #line 1694 "deffilep.c" /* yacc.c:1646  */
1694     break;
1695 
1696   case 52:
1697 #line 236 "deffilep.y" /* yacc.c:1646  */
1698     { (yyval.number)=4;}
1699 #line 1700 "deffilep.c" /* yacc.c:1646  */
1700     break;
1701 
1702   case 53:
1703 #line 237 "deffilep.y" /* yacc.c:1646  */
1704     { (yyval.number)=8;}
1705 #line 1706 "deffilep.c" /* yacc.c:1646  */
1706     break;
1707 
1708   case 54:
1709 #line 241 "deffilep.y" /* yacc.c:1646  */
1710     { (yyval.id_const) = "BASE"; }
1711 #line 1712 "deffilep.c" /* yacc.c:1646  */
1712     break;
1713 
1714   case 55:
1715 #line 242 "deffilep.y" /* yacc.c:1646  */
1716     { (yyval.id_const) = "CODE"; }
1717 #line 1718 "deffilep.c" /* yacc.c:1646  */
1718     break;
1719 
1720   case 56:
1721 #line 243 "deffilep.y" /* yacc.c:1646  */
1722     { (yyval.id_const) = "CONSTANT"; }
1723 #line 1724 "deffilep.c" /* yacc.c:1646  */
1724     break;
1725 
1726   case 57:
1727 #line 244 "deffilep.y" /* yacc.c:1646  */
1728     { (yyval.id_const) = "constant"; }
1729 #line 1730 "deffilep.c" /* yacc.c:1646  */
1730     break;
1731 
1732   case 58:
1733 #line 245 "deffilep.y" /* yacc.c:1646  */
1734     { (yyval.id_const) = "DATA"; }
1735 #line 1736 "deffilep.c" /* yacc.c:1646  */
1736     break;
1737 
1738   case 59:
1739 #line 246 "deffilep.y" /* yacc.c:1646  */
1740     { (yyval.id_const) = "data"; }
1741 #line 1742 "deffilep.c" /* yacc.c:1646  */
1742     break;
1743 
1744   case 60:
1745 #line 247 "deffilep.y" /* yacc.c:1646  */
1746     { (yyval.id_const) = "DESCRIPTION"; }
1747 #line 1748 "deffilep.c" /* yacc.c:1646  */
1748     break;
1749 
1750   case 61:
1751 #line 248 "deffilep.y" /* yacc.c:1646  */
1752     { (yyval.id_const) = "DIRECTIVE"; }
1753 #line 1754 "deffilep.c" /* yacc.c:1646  */
1754     break;
1755 
1756   case 62:
1757 #line 249 "deffilep.y" /* yacc.c:1646  */
1758     { (yyval.id_const) = "EXECUTE"; }
1759 #line 1760 "deffilep.c" /* yacc.c:1646  */
1760     break;
1761 
1762   case 63:
1763 #line 250 "deffilep.y" /* yacc.c:1646  */
1764     { (yyval.id_const) = "EXPORTS"; }
1765 #line 1766 "deffilep.c" /* yacc.c:1646  */
1766     break;
1767 
1768   case 64:
1769 #line 251 "deffilep.y" /* yacc.c:1646  */
1770     { (yyval.id_const) = "HEAPSIZE"; }
1771 #line 1772 "deffilep.c" /* yacc.c:1646  */
1772     break;
1773 
1774   case 65:
1775 #line 252 "deffilep.y" /* yacc.c:1646  */
1776     { (yyval.id_const) = "IMPORTS"; }
1777 #line 1778 "deffilep.c" /* yacc.c:1646  */
1778     break;
1779 
1780   case 66:
1781 #line 259 "deffilep.y" /* yacc.c:1646  */
1782     { (yyval.id_const) = "NAME"; }
1783 #line 1784 "deffilep.c" /* yacc.c:1646  */
1784     break;
1785 
1786   case 67:
1787 #line 260 "deffilep.y" /* yacc.c:1646  */
1788     { (yyval.id_const) = "NONAME"; }
1789 #line 1790 "deffilep.c" /* yacc.c:1646  */
1790     break;
1791 
1792   case 68:
1793 #line 261 "deffilep.y" /* yacc.c:1646  */
1794     { (yyval.id_const) = "noname"; }
1795 #line 1796 "deffilep.c" /* yacc.c:1646  */
1796     break;
1797 
1798   case 69:
1799 #line 262 "deffilep.y" /* yacc.c:1646  */
1800     { (yyval.id_const) = "PRIVATE"; }
1801 #line 1802 "deffilep.c" /* yacc.c:1646  */
1802     break;
1803 
1804   case 70:
1805 #line 263 "deffilep.y" /* yacc.c:1646  */
1806     { (yyval.id_const) = "private"; }
1807 #line 1808 "deffilep.c" /* yacc.c:1646  */
1808     break;
1809 
1810   case 71:
1811 #line 264 "deffilep.y" /* yacc.c:1646  */
1812     { (yyval.id_const) = "READ"; }
1813 #line 1814 "deffilep.c" /* yacc.c:1646  */
1814     break;
1815 
1816   case 72:
1817 #line 265 "deffilep.y" /* yacc.c:1646  */
1818     { (yyval.id_const) = "SHARED"; }
1819 #line 1820 "deffilep.c" /* yacc.c:1646  */
1820     break;
1821 
1822   case 73:
1823 #line 266 "deffilep.y" /* yacc.c:1646  */
1824     { (yyval.id_const) = "STACKSIZE"; }
1825 #line 1826 "deffilep.c" /* yacc.c:1646  */
1826     break;
1827 
1828   case 74:
1829 #line 267 "deffilep.y" /* yacc.c:1646  */
1830     { (yyval.id_const) = "VERSION"; }
1831 #line 1832 "deffilep.c" /* yacc.c:1646  */
1832     break;
1833 
1834   case 75:
1835 #line 268 "deffilep.y" /* yacc.c:1646  */
1836     { (yyval.id_const) = "WRITE"; }
1837 #line 1838 "deffilep.c" /* yacc.c:1646  */
1838     break;
1839 
1840   case 76:
1841 #line 271 "deffilep.y" /* yacc.c:1646  */
1842     { (yyval.id) = (yyvsp[0].id); }
1843 #line 1844 "deffilep.c" /* yacc.c:1646  */
1844     break;
1845 
1846   case 77:
1847 #line 273 "deffilep.y" /* yacc.c:1646  */
1848     {
1849 	    char *name = xmalloc (strlen ((yyvsp[0].id_const)) + 2);
1850 	    sprintf (name, ".%s", (yyvsp[0].id_const));
1851 	    (yyval.id) = name;
1852 	  }
1853 #line 1854 "deffilep.c" /* yacc.c:1646  */
1854     break;
1855 
1856   case 78:
1857 #line 279 "deffilep.y" /* yacc.c:1646  */
1858     {
1859 	    char *name = def_pool_alloc (strlen ((yyvsp[0].id)) + 2);
1860 	    sprintf (name, ".%s", (yyvsp[0].id));
1861 	    (yyval.id) = name;
1862 	  }
1863 #line 1864 "deffilep.c" /* yacc.c:1646  */
1864     break;
1865 
1866   case 79:
1867 #line 285 "deffilep.y" /* yacc.c:1646  */
1868     {
1869 	    char *name = def_pool_alloc (strlen ((yyvsp[-2].id_const)) + 1 + strlen ((yyvsp[0].id)) + 1);
1870 	    sprintf (name, "%s.%s", (yyvsp[-2].id_const), (yyvsp[0].id));
1871 	    (yyval.id) = name;
1872 	  }
1873 #line 1874 "deffilep.c" /* yacc.c:1646  */
1874     break;
1875 
1876   case 80:
1877 #line 291 "deffilep.y" /* yacc.c:1646  */
1878     {
1879 	    char *name = def_pool_alloc (strlen ((yyvsp[-2].id)) + 1 + strlen ((yyvsp[0].id)) + 1);
1880 	    sprintf (name, "%s.%s", (yyvsp[-2].id), (yyvsp[0].id));
1881 	    (yyval.id) = name;
1882 	  }
1883 #line 1884 "deffilep.c" /* yacc.c:1646  */
1884     break;
1885 
1886   case 81:
1887 #line 298 "deffilep.y" /* yacc.c:1646  */
1888     { (yyval.id) = (yyvsp[0].id); }
1889 #line 1890 "deffilep.c" /* yacc.c:1646  */
1890     break;
1891 
1892   case 82:
1893 #line 299 "deffilep.y" /* yacc.c:1646  */
1894     { (yyval.id) = ""; }
1895 #line 1896 "deffilep.c" /* yacc.c:1646  */
1896     break;
1897 
1898   case 83:
1899 #line 302 "deffilep.y" /* yacc.c:1646  */
1900     { (yyval.id) = (yyvsp[0].id); }
1901 #line 1902 "deffilep.c" /* yacc.c:1646  */
1902     break;
1903 
1904   case 84:
1905 #line 303 "deffilep.y" /* yacc.c:1646  */
1906     { (yyval.id) = 0; }
1907 #line 1908 "deffilep.c" /* yacc.c:1646  */
1908     break;
1909 
1910   case 85:
1911 #line 307 "deffilep.y" /* yacc.c:1646  */
1912     { (yyval.number) = (yyvsp[0].number);}
1913 #line 1914 "deffilep.c" /* yacc.c:1646  */
1914     break;
1915 
1916   case 86:
1917 #line 308 "deffilep.y" /* yacc.c:1646  */
1918     { (yyval.number) = -1;}
1919 #line 1920 "deffilep.c" /* yacc.c:1646  */
1920     break;
1921 
1922   case 87:
1923 #line 312 "deffilep.y" /* yacc.c:1646  */
1924     { (yyval.id) = (yyvsp[0].id); }
1925 #line 1926 "deffilep.c" /* yacc.c:1646  */
1926     break;
1927 
1928   case 88:
1929 #line 313 "deffilep.y" /* yacc.c:1646  */
1930     { (yyval.id) =	0; }
1931 #line 1932 "deffilep.c" /* yacc.c:1646  */
1932     break;
1933 
1934   case 89:
1935 #line 316 "deffilep.y" /* yacc.c:1646  */
1936     { (yyval.vma) = (yyvsp[0].vma);}
1937 #line 1938 "deffilep.c" /* yacc.c:1646  */
1938     break;
1939 
1940   case 90:
1941 #line 317 "deffilep.y" /* yacc.c:1646  */
1942     { (yyval.vma) = (bfd_vma) -1;}
1943 #line 1944 "deffilep.c" /* yacc.c:1646  */
1944     break;
1945 
1946   case 91:
1947 #line 320 "deffilep.y" /* yacc.c:1646  */
1948     { (yyval.id) = (yyvsp[0].id); }
1949 #line 1950 "deffilep.c" /* yacc.c:1646  */
1950     break;
1951 
1952   case 92:
1953 #line 322 "deffilep.y" /* yacc.c:1646  */
1954     {
1955 	    char *id = def_pool_alloc (strlen ((yyvsp[0].id)) + 2);
1956 	    sprintf (id, ".%s", (yyvsp[0].id));
1957 	    (yyval.id) = id;
1958 	  }
1959 #line 1960 "deffilep.c" /* yacc.c:1646  */
1960     break;
1961 
1962   case 93:
1963 #line 328 "deffilep.y" /* yacc.c:1646  */
1964     {
1965 	    char *id = def_pool_alloc (strlen ((yyvsp[-3].id)) + 1 + strlen ((yyvsp[-1].digits)) + strlen ((yyvsp[0].id)) + 1);
1966 	    sprintf (id, "%s.%s%s", (yyvsp[-3].id), (yyvsp[-1].digits), (yyvsp[0].id));
1967 	    (yyval.id) = id;
1968 	  }
1969 #line 1970 "deffilep.c" /* yacc.c:1646  */
1970     break;
1971 
1972   case 94:
1973 #line 335 "deffilep.y" /* yacc.c:1646  */
1974     { (yyval.digits) = (yyvsp[0].digits); }
1975 #line 1976 "deffilep.c" /* yacc.c:1646  */
1976     break;
1977 
1978   case 95:
1979 #line 336 "deffilep.y" /* yacc.c:1646  */
1980     { (yyval.digits) = ""; }
1981 #line 1982 "deffilep.c" /* yacc.c:1646  */
1982     break;
1983 
1984   case 96:
1985 #line 339 "deffilep.y" /* yacc.c:1646  */
1986     { (yyval.id) = (yyvsp[0].id); }
1987 #line 1988 "deffilep.c" /* yacc.c:1646  */
1988     break;
1989 
1990   case 97:
1991 #line 340 "deffilep.y" /* yacc.c:1646  */
1992     { (yyval.id) = ""; }
1993 #line 1994 "deffilep.c" /* yacc.c:1646  */
1994     break;
1995 
1996   case 98:
1997 #line 343 "deffilep.y" /* yacc.c:1646  */
1998     { (yyval.number) = strtoul ((yyvsp[0].digits), 0, 0); }
1999 #line 2000 "deffilep.c" /* yacc.c:1646  */
2000     break;
2001 
2002   case 99:
2003 #line 345 "deffilep.y" /* yacc.c:1646  */
2004     { (yyval.vma) = (bfd_vma) strtoull ((yyvsp[0].digits), 0, 0); }
2005 #line 2006 "deffilep.c" /* yacc.c:1646  */
2006     break;
2007 
2008 
2009 #line 2010 "deffilep.c" /* yacc.c:1646  */
2010       default: break;
2011     }
2012   /* User semantic actions sometimes alter yychar, and that requires
2013      that yytoken be updated with the new translation.  We take the
2014      approach of translating immediately before every use of yytoken.
2015      One alternative is translating here after every semantic action,
2016      but that translation would be missed if the semantic action invokes
2017      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2018      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
2019      incorrect destructor might then be invoked immediately.  In the
2020      case of YYERROR or YYBACKUP, subsequent parser actions might lead
2021      to an incorrect destructor call or verbose syntax error message
2022      before the lookahead is translated.  */
2023   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2024 
2025   YYPOPSTACK (yylen);
2026   yylen = 0;
2027   YY_STACK_PRINT (yyss, yyssp);
2028 
2029   *++yyvsp = yyval;
2030 
2031   /* Now 'shift' the result of the reduction.  Determine what state
2032      that goes to, based on the state we popped back to and the rule
2033      number reduced by.  */
2034 
2035   yyn = yyr1[yyn];
2036 
2037   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2038   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2039     yystate = yytable[yystate];
2040   else
2041     yystate = yydefgoto[yyn - YYNTOKENS];
2042 
2043   goto yynewstate;
2044 
2045 
2046 /*--------------------------------------.
2047 | yyerrlab -- here on detecting error.  |
2048 `--------------------------------------*/
2049 yyerrlab:
2050   /* Make sure we have latest lookahead translation.  See comments at
2051      user semantic actions for why this is necessary.  */
2052   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2053 
2054   /* If not already recovering from an error, report this error.  */
2055   if (!yyerrstatus)
2056     {
2057       ++yynerrs;
2058 #if ! YYERROR_VERBOSE
2059       yyerror (YY_("syntax error"));
2060 #else
2061 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2062                                         yyssp, yytoken)
2063       {
2064         char const *yymsgp = YY_("syntax error");
2065         int yysyntax_error_status;
2066         yysyntax_error_status = YYSYNTAX_ERROR;
2067         if (yysyntax_error_status == 0)
2068           yymsgp = yymsg;
2069         else if (yysyntax_error_status == 1)
2070           {
2071             if (yymsg != yymsgbuf)
2072               YYSTACK_FREE (yymsg);
2073             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2074             if (!yymsg)
2075               {
2076                 yymsg = yymsgbuf;
2077                 yymsg_alloc = sizeof yymsgbuf;
2078                 yysyntax_error_status = 2;
2079               }
2080             else
2081               {
2082                 yysyntax_error_status = YYSYNTAX_ERROR;
2083                 yymsgp = yymsg;
2084               }
2085           }
2086         yyerror (yymsgp);
2087         if (yysyntax_error_status == 2)
2088           goto yyexhaustedlab;
2089       }
2090 # undef YYSYNTAX_ERROR
2091 #endif
2092     }
2093 
2094 
2095 
2096   if (yyerrstatus == 3)
2097     {
2098       /* If just tried and failed to reuse lookahead token after an
2099          error, discard it.  */
2100 
2101       if (yychar <= YYEOF)
2102         {
2103           /* Return failure if at end of input.  */
2104           if (yychar == YYEOF)
2105             YYABORT;
2106         }
2107       else
2108         {
2109           yydestruct ("Error: discarding",
2110                       yytoken, &yylval);
2111           yychar = YYEMPTY;
2112         }
2113     }
2114 
2115   /* Else will try to reuse lookahead token after shifting the error
2116      token.  */
2117   goto yyerrlab1;
2118 
2119 
2120 /*---------------------------------------------------.
2121 | yyerrorlab -- error raised explicitly by YYERROR.  |
2122 `---------------------------------------------------*/
2123 yyerrorlab:
2124 
2125   /* Pacify compilers like GCC when the user code never invokes
2126      YYERROR and the label yyerrorlab therefore never appears in user
2127      code.  */
2128   if (/*CONSTCOND*/ 0)
2129      goto yyerrorlab;
2130 
2131   /* Do not reclaim the symbols of the rule whose action triggered
2132      this YYERROR.  */
2133   YYPOPSTACK (yylen);
2134   yylen = 0;
2135   YY_STACK_PRINT (yyss, yyssp);
2136   yystate = *yyssp;
2137   goto yyerrlab1;
2138 
2139 
2140 /*-------------------------------------------------------------.
2141 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
2142 `-------------------------------------------------------------*/
2143 yyerrlab1:
2144   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
2145 
2146   for (;;)
2147     {
2148       yyn = yypact[yystate];
2149       if (!yypact_value_is_default (yyn))
2150         {
2151           yyn += YYTERROR;
2152           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2153             {
2154               yyn = yytable[yyn];
2155               if (0 < yyn)
2156                 break;
2157             }
2158         }
2159 
2160       /* Pop the current state because it cannot handle the error token.  */
2161       if (yyssp == yyss)
2162         YYABORT;
2163 
2164 
2165       yydestruct ("Error: popping",
2166                   yystos[yystate], yyvsp);
2167       YYPOPSTACK (1);
2168       yystate = *yyssp;
2169       YY_STACK_PRINT (yyss, yyssp);
2170     }
2171 
2172   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2173   *++yyvsp = yylval;
2174   YY_IGNORE_MAYBE_UNINITIALIZED_END
2175 
2176 
2177   /* Shift the error token.  */
2178   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2179 
2180   yystate = yyn;
2181   goto yynewstate;
2182 
2183 
2184 /*-------------------------------------.
2185 | yyacceptlab -- YYACCEPT comes here.  |
2186 `-------------------------------------*/
2187 yyacceptlab:
2188   yyresult = 0;
2189   goto yyreturn;
2190 
2191 /*-----------------------------------.
2192 | yyabortlab -- YYABORT comes here.  |
2193 `-----------------------------------*/
2194 yyabortlab:
2195   yyresult = 1;
2196   goto yyreturn;
2197 
2198 #if !defined yyoverflow || YYERROR_VERBOSE
2199 /*-------------------------------------------------.
2200 | yyexhaustedlab -- memory exhaustion comes here.  |
2201 `-------------------------------------------------*/
2202 yyexhaustedlab:
2203   yyerror (YY_("memory exhausted"));
2204   yyresult = 2;
2205   /* Fall through.  */
2206 #endif
2207 
2208 yyreturn:
2209   if (yychar != YYEMPTY)
2210     {
2211       /* Make sure we have latest lookahead translation.  See comments at
2212          user semantic actions for why this is necessary.  */
2213       yytoken = YYTRANSLATE (yychar);
2214       yydestruct ("Cleanup: discarding lookahead",
2215                   yytoken, &yylval);
2216     }
2217   /* Do not reclaim the symbols of the rule whose action triggered
2218      this YYABORT or YYACCEPT.  */
2219   YYPOPSTACK (yylen);
2220   YY_STACK_PRINT (yyss, yyssp);
2221   while (yyssp != yyss)
2222     {
2223       yydestruct ("Cleanup: popping",
2224                   yystos[*yyssp], yyvsp);
2225       YYPOPSTACK (1);
2226     }
2227 #ifndef yyoverflow
2228   if (yyss != yyssa)
2229     YYSTACK_FREE (yyss);
2230 #endif
2231 #if YYERROR_VERBOSE
2232   if (yymsg != yymsgbuf)
2233     YYSTACK_FREE (yymsg);
2234 #endif
2235   return yyresult;
2236 }
2237 #line 347 "deffilep.y" /* yacc.c:1906  */
2238 
2239 
2240 /*****************************************************************************
2241  API
2242  *****************************************************************************/
2243 
2244 static FILE *the_file;
2245 static const char *def_filename;
2246 static int linenumber;
2247 static def_file *def;
2248 static int saw_newline;
2249 
2250 struct directive
2251   {
2252     struct directive *next;
2253     char *name;
2254     int len;
2255   };
2256 
2257 static struct directive *directives = 0;
2258 
2259 def_file *
2260 def_file_empty (void)
2261 {
2262   def_file *rv = xmalloc (sizeof (def_file));
2263   memset (rv, 0, sizeof (def_file));
2264   rv->is_dll = -1;
2265   rv->base_address = (bfd_vma) -1;
2266   rv->stack_reserve = rv->stack_commit = -1;
2267   rv->heap_reserve = rv->heap_commit = -1;
2268   rv->version_major = rv->version_minor = -1;
2269   return rv;
2270 }
2271 
2272 def_file *
2273 def_file_parse (const char *filename, def_file *add_to)
2274 {
2275   struct directive *d;
2276 
2277   the_file = fopen (filename, "r");
2278   def_filename = filename;
2279   linenumber = 1;
2280   if (!the_file)
2281     {
2282       perror (filename);
2283       return 0;
2284     }
2285   if (add_to)
2286     {
2287       def = add_to;
2288     }
2289   else
2290     {
2291       def = def_file_empty ();
2292     }
2293 
2294   saw_newline = 1;
2295   if (def_parse ())
2296     {
2297       def_file_free (def);
2298       fclose (the_file);
2299       def_pool_free ();
2300       return 0;
2301     }
2302 
2303   fclose (the_file);
2304 
2305   while ((d = directives) != NULL)
2306     {
2307 #if TRACE
2308       printf ("Adding directive %08x `%s'\n", d->name, d->name);
2309 #endif
2310       def_file_add_directive (def, d->name, d->len);
2311       directives = d->next;
2312       free (d->name);
2313       free (d);
2314     }
2315   def_pool_free ();
2316 
2317   return def;
2318 }
2319 
2320 void
2321 def_file_free (def_file *fdef)
2322 {
2323   int i;
2324 
2325   if (!fdef)
2326     return;
2327   if (fdef->name)
2328     free (fdef->name);
2329   if (fdef->description)
2330     free (fdef->description);
2331 
2332   if (fdef->section_defs)
2333     {
2334       for (i = 0; i < fdef->num_section_defs; i++)
2335 	{
2336 	  if (fdef->section_defs[i].name)
2337 	    free (fdef->section_defs[i].name);
2338 	  if (fdef->section_defs[i].class)
2339 	    free (fdef->section_defs[i].class);
2340 	}
2341       free (fdef->section_defs);
2342     }
2343 
2344   if (fdef->exports)
2345     {
2346       for (i = 0; i < fdef->num_exports; i++)
2347 	{
2348 	  if (fdef->exports[i].internal_name
2349 	      && fdef->exports[i].internal_name != fdef->exports[i].name)
2350 	    free (fdef->exports[i].internal_name);
2351 	  if (fdef->exports[i].name)
2352 	    free (fdef->exports[i].name);
2353 	  if (fdef->exports[i].its_name)
2354 	    free (fdef->exports[i].its_name);
2355 	}
2356       free (fdef->exports);
2357     }
2358 
2359   if (fdef->imports)
2360     {
2361       for (i = 0; i < fdef->num_imports; i++)
2362 	{
2363 	  if (fdef->imports[i].internal_name
2364 	      && fdef->imports[i].internal_name != fdef->imports[i].name)
2365 	    free (fdef->imports[i].internal_name);
2366 	  if (fdef->imports[i].name)
2367 	    free (fdef->imports[i].name);
2368 	  if (fdef->imports[i].its_name)
2369 	    free (fdef->imports[i].its_name);
2370 	}
2371       free (fdef->imports);
2372     }
2373 
2374   while (fdef->modules)
2375     {
2376       def_file_module *m = fdef->modules;
2377 
2378       fdef->modules = fdef->modules->next;
2379       free (m);
2380     }
2381 
2382   while (fdef->aligncomms)
2383     {
2384       def_file_aligncomm *c = fdef->aligncomms;
2385 
2386       fdef->aligncomms = fdef->aligncomms->next;
2387       free (c->symbol_name);
2388       free (c);
2389     }
2390 
2391   free (fdef);
2392 }
2393 
2394 #ifdef DEF_FILE_PRINT
2395 void
2396 def_file_print (FILE *file, def_file *fdef)
2397 {
2398   int i;
2399 
2400   fprintf (file, ">>>> def_file at 0x%08x\n", fdef);
2401   if (fdef->name)
2402     fprintf (file, "  name: %s\n", fdef->name ? fdef->name : "(unspecified)");
2403   if (fdef->is_dll != -1)
2404     fprintf (file, "  is dll: %s\n", fdef->is_dll ? "yes" : "no");
2405   if (fdef->base_address != (bfd_vma) -1)
2406     {
2407       fprintf (file, "  base address: 0x");
2408       fprintf_vma (file, fdef->base_address);
2409       fprintf (file, "\n");
2410     }
2411   if (fdef->description)
2412     fprintf (file, "  description: `%s'\n", fdef->description);
2413   if (fdef->stack_reserve != -1)
2414     fprintf (file, "  stack reserve: 0x%08x\n", fdef->stack_reserve);
2415   if (fdef->stack_commit != -1)
2416     fprintf (file, "  stack commit: 0x%08x\n", fdef->stack_commit);
2417   if (fdef->heap_reserve != -1)
2418     fprintf (file, "  heap reserve: 0x%08x\n", fdef->heap_reserve);
2419   if (fdef->heap_commit != -1)
2420     fprintf (file, "  heap commit: 0x%08x\n", fdef->heap_commit);
2421 
2422   if (fdef->num_section_defs > 0)
2423     {
2424       fprintf (file, "  section defs:\n");
2425 
2426       for (i = 0; i < fdef->num_section_defs; i++)
2427 	{
2428 	  fprintf (file, "    name: `%s', class: `%s', flags:",
2429 		   fdef->section_defs[i].name, fdef->section_defs[i].class);
2430 	  if (fdef->section_defs[i].flag_read)
2431 	    fprintf (file, " R");
2432 	  if (fdef->section_defs[i].flag_write)
2433 	    fprintf (file, " W");
2434 	  if (fdef->section_defs[i].flag_execute)
2435 	    fprintf (file, " X");
2436 	  if (fdef->section_defs[i].flag_shared)
2437 	    fprintf (file, " S");
2438 	  fprintf (file, "\n");
2439 	}
2440     }
2441 
2442   if (fdef->num_exports > 0)
2443     {
2444       fprintf (file, "  exports:\n");
2445 
2446       for (i = 0; i < fdef->num_exports; i++)
2447 	{
2448 	  fprintf (file, "    name: `%s', int: `%s', ordinal: %d, flags:",
2449 		   fdef->exports[i].name, fdef->exports[i].internal_name,
2450 		   fdef->exports[i].ordinal);
2451 	  if (fdef->exports[i].flag_private)
2452 	    fprintf (file, " P");
2453 	  if (fdef->exports[i].flag_constant)
2454 	    fprintf (file, " C");
2455 	  if (fdef->exports[i].flag_noname)
2456 	    fprintf (file, " N");
2457 	  if (fdef->exports[i].flag_data)
2458 	    fprintf (file, " D");
2459 	  fprintf (file, "\n");
2460 	}
2461     }
2462 
2463   if (fdef->num_imports > 0)
2464     {
2465       fprintf (file, "  imports:\n");
2466 
2467       for (i = 0; i < fdef->num_imports; i++)
2468 	{
2469 	  fprintf (file, "    int: %s, from: `%s', name: `%s', ordinal: %d\n",
2470 		   fdef->imports[i].internal_name,
2471 		   fdef->imports[i].module,
2472 		   fdef->imports[i].name,
2473 		   fdef->imports[i].ordinal);
2474 	}
2475     }
2476 
2477   if (fdef->version_major != -1)
2478     fprintf (file, "  version: %d.%d\n", fdef->version_major, fdef->version_minor);
2479 
2480   fprintf (file, "<<<< def_file at 0x%08x\n", fdef);
2481 }
2482 #endif
2483 
2484 /* Helper routine to check for identity of string pointers,
2485    which might be NULL.  */
2486 
2487 static int
2488 are_names_equal (const char *s1, const char *s2)
2489 {
2490   if (!s1 && !s2)
2491     return 0;
2492   if (!s1 || !s2)
2493     return (!s1 ? -1 : 1);
2494   return strcmp (s1, s2);
2495 }
2496 
2497 static int
2498 cmp_export_elem (const def_file_export *e, const char *ex_name,
2499 		 const char *in_name, const char *its_name,
2500 		 int ord)
2501 {
2502   int r;
2503 
2504   if ((r = are_names_equal (ex_name, e->name)) != 0)
2505     return r;
2506   if ((r = are_names_equal (in_name, e->internal_name)) != 0)
2507     return r;
2508   if ((r = are_names_equal (its_name, e->its_name)) != 0)
2509     return r;
2510   return (ord - e->ordinal);
2511 }
2512 
2513 /* Search the position of the identical element, or returns the position
2514    of the next higher element. If last valid element is smaller, then MAX
2515    is returned.  */
2516 
2517 static int
2518 find_export_in_list (def_file_export *b, int max,
2519 		     const char *ex_name, const char *in_name,
2520 		     const char *its_name, int ord, int *is_ident)
2521 {
2522   int e, l, r, p;
2523 
2524   *is_ident = 0;
2525   if (!max)
2526     return 0;
2527   if ((e = cmp_export_elem (b, ex_name, in_name, its_name, ord)) <= 0)
2528     {
2529       if (!e)
2530 	*is_ident = 1;
2531       return 0;
2532     }
2533   if (max == 1)
2534     return 1;
2535   if ((e = cmp_export_elem (b + (max - 1), ex_name, in_name, its_name, ord)) > 0)
2536     return max;
2537   else if (!e || max == 2)
2538     {
2539       if (!e)
2540 	*is_ident = 1;
2541       return max - 1;
2542     }
2543   l = 0; r = max - 1;
2544   while (l < r)
2545     {
2546       p = (l + r) / 2;
2547       e = cmp_export_elem (b + p, ex_name, in_name, its_name, ord);
2548       if (!e)
2549 	{
2550 	  *is_ident = 1;
2551 	  return p;
2552 	}
2553       else if (e < 0)
2554 	r = p - 1;
2555       else if (e > 0)
2556 	l = p + 1;
2557     }
2558   if ((e = cmp_export_elem (b + l, ex_name, in_name, its_name, ord)) > 0)
2559     ++l;
2560   else if (!e)
2561     *is_ident = 1;
2562   return l;
2563 }
2564 
2565 def_file_export *
2566 def_file_add_export (def_file *fdef,
2567 		     const char *external_name,
2568 		     const char *internal_name,
2569 		     int ordinal,
2570 		     const char *its_name,
2571 		     int *is_dup)
2572 {
2573   def_file_export *e;
2574   int pos;
2575   int max_exports = ROUND_UP(fdef->num_exports, 32);
2576 
2577   if (internal_name && !external_name)
2578     external_name = internal_name;
2579   if (external_name && !internal_name)
2580     internal_name = external_name;
2581 
2582   /* We need to avoid duplicates.  */
2583   *is_dup = 0;
2584   pos = find_export_in_list (fdef->exports, fdef->num_exports,
2585 		     external_name, internal_name,
2586 		     its_name, ordinal, is_dup);
2587 
2588   if (*is_dup != 0)
2589     return (fdef->exports + pos);
2590 
2591   if (fdef->num_exports >= max_exports)
2592     {
2593       max_exports = ROUND_UP(fdef->num_exports + 1, 32);
2594       if (fdef->exports)
2595 	fdef->exports = xrealloc (fdef->exports,
2596 				 max_exports * sizeof (def_file_export));
2597       else
2598 	fdef->exports = xmalloc (max_exports * sizeof (def_file_export));
2599     }
2600 
2601   e = fdef->exports + pos;
2602   if (pos != fdef->num_exports)
2603     memmove (&e[1], e, (sizeof (def_file_export) * (fdef->num_exports - pos)));
2604   memset (e, 0, sizeof (def_file_export));
2605   e->name = xstrdup (external_name);
2606   e->internal_name = xstrdup (internal_name);
2607   e->its_name = (its_name ? xstrdup (its_name) : NULL);
2608   e->ordinal = ordinal;
2609   fdef->num_exports++;
2610   return e;
2611 }
2612 
2613 def_file_module *
2614 def_get_module (def_file *fdef, const char *name)
2615 {
2616   def_file_module *s;
2617 
2618   for (s = fdef->modules; s; s = s->next)
2619     if (strcmp (s->name, name) == 0)
2620       return s;
2621 
2622   return NULL;
2623 }
2624 
2625 static def_file_module *
2626 def_stash_module (def_file *fdef, const char *name)
2627 {
2628   def_file_module *s;
2629 
2630   if ((s = def_get_module (fdef, name)) != NULL)
2631       return s;
2632   s = xmalloc (sizeof (def_file_module) + strlen (name));
2633   s->next = fdef->modules;
2634   fdef->modules = s;
2635   s->user_data = 0;
2636   strcpy (s->name, name);
2637   return s;
2638 }
2639 
2640 static int
2641 cmp_import_elem (const def_file_import *e, const char *ex_name,
2642 		 const char *in_name, const char *module,
2643 		 int ord)
2644 {
2645   int r;
2646 
2647   if ((r = are_names_equal (module, (e->module ? e->module->name : NULL))))
2648     return r;
2649   if ((r = are_names_equal (ex_name, e->name)) != 0)
2650     return r;
2651   if ((r = are_names_equal (in_name, e->internal_name)) != 0)
2652     return r;
2653   if (ord != e->ordinal)
2654     return (ord < e->ordinal ? -1 : 1);
2655   return 0;
2656 }
2657 
2658 /* Search the position of the identical element, or returns the position
2659    of the next higher element. If last valid element is smaller, then MAX
2660    is returned.  */
2661 
2662 static int
2663 find_import_in_list (def_file_import *b, int max,
2664 		     const char *ex_name, const char *in_name,
2665 		     const char *module, int ord, int *is_ident)
2666 {
2667   int e, l, r, p;
2668 
2669   *is_ident = 0;
2670   if (!max)
2671     return 0;
2672   if ((e = cmp_import_elem (b, ex_name, in_name, module, ord)) <= 0)
2673     {
2674       if (!e)
2675 	*is_ident = 1;
2676       return 0;
2677     }
2678   if (max == 1)
2679     return 1;
2680   if ((e = cmp_import_elem (b + (max - 1), ex_name, in_name, module, ord)) > 0)
2681     return max;
2682   else if (!e || max == 2)
2683     {
2684       if (!e)
2685 	*is_ident = 1;
2686       return max - 1;
2687     }
2688   l = 0; r = max - 1;
2689   while (l < r)
2690     {
2691       p = (l + r) / 2;
2692       e = cmp_import_elem (b + p, ex_name, in_name, module, ord);
2693       if (!e)
2694 	{
2695 	  *is_ident = 1;
2696 	  return p;
2697 	}
2698       else if (e < 0)
2699 	r = p - 1;
2700       else if (e > 0)
2701 	l = p + 1;
2702     }
2703   if ((e = cmp_import_elem (b + l, ex_name, in_name, module, ord)) > 0)
2704     ++l;
2705   else if (!e)
2706     *is_ident = 1;
2707   return l;
2708 }
2709 
2710 static void
2711 fill_in_import (def_file_import *i,
2712 		const char *name,
2713 		def_file_module *module,
2714 		int ordinal,
2715 		const char *internal_name,
2716 		const char *its_name)
2717 {
2718   memset (i, 0, sizeof (def_file_import));
2719   if (name)
2720     i->name = xstrdup (name);
2721   i->module = module;
2722   i->ordinal = ordinal;
2723   if (internal_name)
2724     i->internal_name = xstrdup (internal_name);
2725   else
2726     i->internal_name = i->name;
2727   i->its_name = (its_name ? xstrdup (its_name) : NULL);
2728 }
2729 
2730 def_file_import *
2731 def_file_add_import (def_file *fdef,
2732 		     const char *name,
2733 		     const char *module,
2734 		     int ordinal,
2735 		     const char *internal_name,
2736 		     const char *its_name,
2737 		     int *is_dup)
2738 {
2739   def_file_import *i;
2740   int pos;
2741   int max_imports = ROUND_UP (fdef->num_imports, 16);
2742 
2743   /* We need to avoid here duplicates.  */
2744   *is_dup = 0;
2745   pos = find_import_in_list (fdef->imports, fdef->num_imports,
2746 			     name,
2747 			     (!internal_name ? name : internal_name),
2748 			     module, ordinal, is_dup);
2749   if (*is_dup != 0)
2750     return fdef->imports + pos;
2751 
2752   if (fdef->num_imports >= max_imports)
2753     {
2754       max_imports = ROUND_UP (fdef->num_imports+1, 16);
2755 
2756       if (fdef->imports)
2757 	fdef->imports = xrealloc (fdef->imports,
2758 				 max_imports * sizeof (def_file_import));
2759       else
2760 	fdef->imports = xmalloc (max_imports * sizeof (def_file_import));
2761     }
2762   i = fdef->imports + pos;
2763   if (pos != fdef->num_imports)
2764     memmove (i + 1, i, sizeof (def_file_import) * (fdef->num_imports - pos));
2765 
2766   fill_in_import (i, name, def_stash_module (fdef, module), ordinal,
2767 		  internal_name, its_name);
2768   fdef->num_imports++;
2769 
2770   return i;
2771 }
2772 
2773 int
2774 def_file_add_import_from (def_file *fdef,
2775 			  int num_imports,
2776 			  const char *name,
2777 			  const char *module,
2778 			  int ordinal,
2779 			  const char *internal_name,
2780 			  const char *its_name ATTRIBUTE_UNUSED)
2781 {
2782   def_file_import *i;
2783   int is_dup;
2784   int pos;
2785   int max_imports = ROUND_UP (fdef->num_imports, 16);
2786 
2787   /* We need to avoid here duplicates.  */
2788   is_dup = 0;
2789   pos = find_import_in_list (fdef->imports, fdef->num_imports,
2790 			     name, internal_name ? internal_name : name,
2791 			     module, ordinal, &is_dup);
2792   if (is_dup != 0)
2793     return -1;
2794   if (fdef->imports && pos != fdef->num_imports)
2795     {
2796       i = fdef->imports + pos;
2797       if (i->module && strcmp (i->module->name, module) == 0)
2798 	return -1;
2799     }
2800 
2801   if (fdef->num_imports + num_imports - 1 >= max_imports)
2802     {
2803       max_imports = ROUND_UP (fdef->num_imports + num_imports, 16);
2804 
2805       if (fdef->imports)
2806 	fdef->imports = xrealloc (fdef->imports,
2807 				 max_imports * sizeof (def_file_import));
2808       else
2809 	fdef->imports = xmalloc (max_imports * sizeof (def_file_import));
2810     }
2811   i = fdef->imports + pos;
2812   if (pos != fdef->num_imports)
2813     memmove (i + num_imports, i,
2814 	     sizeof (def_file_import) * (fdef->num_imports - pos));
2815 
2816   return pos;
2817 }
2818 
2819 def_file_import *
2820 def_file_add_import_at (def_file *fdef,
2821 			int pos,
2822 			const char *name,
2823 			const char *module,
2824 			int ordinal,
2825 			const char *internal_name,
2826 			const char *its_name)
2827 {
2828   def_file_import *i = fdef->imports + pos;
2829 
2830   fill_in_import (i, name, def_stash_module (fdef, module), ordinal,
2831 		  internal_name, its_name);
2832   fdef->num_imports++;
2833 
2834   return i;
2835 }
2836 
2837 struct
2838 {
2839   char *param;
2840   int token;
2841 }
2842 diropts[] =
2843 {
2844   { "-heap", HEAPSIZE },
2845   { "-stack", STACKSIZE_K },
2846   { "-attr", SECTIONS },
2847   { "-export", EXPORTS },
2848   { "-aligncomm", ALIGNCOMM },
2849   { 0, 0 }
2850 };
2851 
2852 void
2853 def_file_add_directive (def_file *my_def, const char *param, int len)
2854 {
2855   def_file *save_def = def;
2856   const char *pend = param + len;
2857   char * tend = (char *) param;
2858   int i;
2859 
2860   def = my_def;
2861 
2862   while (param < pend)
2863     {
2864       while (param < pend
2865 	     && (ISSPACE (*param) || *param == '\n' || *param == 0))
2866 	param++;
2867 
2868       if (param == pend)
2869 	break;
2870 
2871       /* Scan forward until we encounter any of:
2872 	  - the end of the buffer
2873 	  - the start of a new option
2874 	  - a newline separating options
2875 	  - a NUL separating options.  */
2876       for (tend = (char *) (param + 1);
2877 	   (tend < pend
2878 	    && !(ISSPACE (tend[-1]) && *tend == '-')
2879 	    && *tend != '\n' && *tend != 0);
2880 	   tend++)
2881 	;
2882 
2883       for (i = 0; diropts[i].param; i++)
2884 	{
2885 	  len = strlen (diropts[i].param);
2886 
2887 	  if (tend - param >= len
2888 	      && strncmp (param, diropts[i].param, len) == 0
2889 	      && (param[len] == ':' || param[len] == ' '))
2890 	    {
2891 	      lex_parse_string_end = tend;
2892 	      lex_parse_string = param + len + 1;
2893 	      lex_forced_token = diropts[i].token;
2894 	      saw_newline = 0;
2895 	      if (def_parse ())
2896 		continue;
2897 	      break;
2898 	    }
2899 	}
2900 
2901       if (!diropts[i].param)
2902 	{
2903 	  if (tend < pend)
2904 	    {
2905 	      char saved;
2906 
2907 	      saved = * tend;
2908 	      * tend = 0;
2909 	      /* xgettext:c-format */
2910 	      einfo (_("Warning: .drectve `%s' unrecognized\n"), param);
2911 	      * tend = saved;
2912 	    }
2913 	  else
2914 	    {
2915 	      einfo (_("Warning: corrupt .drectve at end of def file\n"));
2916 	    }
2917 	}
2918 
2919       lex_parse_string = 0;
2920       param = tend;
2921     }
2922 
2923   def = save_def;
2924   def_pool_free ();
2925 }
2926 
2927 /* Parser Callbacks.  */
2928 
2929 static void
2930 def_image_name (const char *name, bfd_vma base, int is_dll)
2931 {
2932   /* If a LIBRARY or NAME statement is specified without a name, there is nothing
2933      to do here.  We retain the output filename specified on command line.  */
2934   if (*name)
2935     {
2936       const char* image_name = lbasename (name);
2937 
2938       if (image_name != name)
2939 	einfo ("%s:%d: Warning: path components stripped from %s, '%s'\n",
2940 	       def_filename, linenumber, is_dll ? "LIBRARY" : "NAME",
2941 	       name);
2942       if (def->name)
2943 	free (def->name);
2944       /* Append the default suffix, if none specified.  */
2945       if (strchr (image_name, '.') == 0)
2946 	{
2947 	  const char * suffix = is_dll ? ".dll" : ".exe";
2948 
2949 	  def->name = xmalloc (strlen (image_name) + strlen (suffix) + 1);
2950 	  sprintf (def->name, "%s%s", image_name, suffix);
2951 	}
2952       else
2953 	def->name = xstrdup (image_name);
2954     }
2955 
2956   /* Honor a BASE address statement, even if LIBRARY string is empty.  */
2957   def->base_address = base;
2958   def->is_dll = is_dll;
2959 }
2960 
2961 static void
2962 def_description (const char *text)
2963 {
2964   int len = def->description ? strlen (def->description) : 0;
2965 
2966   len += strlen (text) + 1;
2967   if (def->description)
2968     {
2969       def->description = xrealloc (def->description, len);
2970       strcat (def->description, text);
2971     }
2972   else
2973     {
2974       def->description = xmalloc (len);
2975       strcpy (def->description, text);
2976     }
2977 }
2978 
2979 static void
2980 def_stacksize (int reserve, int commit)
2981 {
2982   def->stack_reserve = reserve;
2983   def->stack_commit = commit;
2984 }
2985 
2986 static void
2987 def_heapsize (int reserve, int commit)
2988 {
2989   def->heap_reserve = reserve;
2990   def->heap_commit = commit;
2991 }
2992 
2993 static void
2994 def_section (const char *name, int attr)
2995 {
2996   def_file_section *s;
2997   int max_sections = ROUND_UP (def->num_section_defs, 4);
2998 
2999   if (def->num_section_defs >= max_sections)
3000     {
3001       max_sections = ROUND_UP (def->num_section_defs+1, 4);
3002 
3003       if (def->section_defs)
3004 	def->section_defs = xrealloc (def->section_defs,
3005 				      max_sections * sizeof (def_file_import));
3006       else
3007 	def->section_defs = xmalloc (max_sections * sizeof (def_file_import));
3008     }
3009   s = def->section_defs + def->num_section_defs;
3010   memset (s, 0, sizeof (def_file_section));
3011   s->name = xstrdup (name);
3012   if (attr & 1)
3013     s->flag_read = 1;
3014   if (attr & 2)
3015     s->flag_write = 1;
3016   if (attr & 4)
3017     s->flag_execute = 1;
3018   if (attr & 8)
3019     s->flag_shared = 1;
3020 
3021   def->num_section_defs++;
3022 }
3023 
3024 static void
3025 def_section_alt (const char *name, const char *attr)
3026 {
3027   int aval = 0;
3028 
3029   for (; *attr; attr++)
3030     {
3031       switch (*attr)
3032 	{
3033 	case 'R':
3034 	case 'r':
3035 	  aval |= 1;
3036 	  break;
3037 	case 'W':
3038 	case 'w':
3039 	  aval |= 2;
3040 	  break;
3041 	case 'X':
3042 	case 'x':
3043 	  aval |= 4;
3044 	  break;
3045 	case 'S':
3046 	case 's':
3047 	  aval |= 8;
3048 	  break;
3049 	}
3050     }
3051   def_section (name, aval);
3052 }
3053 
3054 static void
3055 def_exports (const char *external_name,
3056 	     const char *internal_name,
3057 	     int ordinal,
3058 	     int flags,
3059 	     const char *its_name)
3060 {
3061   def_file_export *dfe;
3062   int is_dup = 0;
3063 
3064   if (!internal_name && external_name)
3065     internal_name = external_name;
3066 #if TRACE
3067   printf ("def_exports, ext=%s int=%s\n", external_name, internal_name);
3068 #endif
3069 
3070   dfe = def_file_add_export (def, external_name, internal_name, ordinal,
3071 			     its_name, &is_dup);
3072 
3073   /* We might check here for flag redefinition and warn.  For now we
3074      ignore duplicates silently.  */
3075   if (is_dup)
3076     return;
3077 
3078   if (flags & 1)
3079     dfe->flag_noname = 1;
3080   if (flags & 2)
3081     dfe->flag_constant = 1;
3082   if (flags & 4)
3083     dfe->flag_data = 1;
3084   if (flags & 8)
3085     dfe->flag_private = 1;
3086 }
3087 
3088 static void
3089 def_import (const char *internal_name,
3090 	    const char *module,
3091 	    const char *dllext,
3092 	    const char *name,
3093 	    int ordinal,
3094 	    const char *its_name)
3095 {
3096   char *buf = 0;
3097   const char *ext = dllext ? dllext : "dll";
3098   int is_dup = 0;
3099 
3100   buf = xmalloc (strlen (module) + strlen (ext) + 2);
3101   sprintf (buf, "%s.%s", module, ext);
3102   module = buf;
3103 
3104   def_file_add_import (def, name, module, ordinal, internal_name, its_name,
3105 		       &is_dup);
3106   free (buf);
3107 }
3108 
3109 static void
3110 def_version (int major, int minor)
3111 {
3112   def->version_major = major;
3113   def->version_minor = minor;
3114 }
3115 
3116 static void
3117 def_directive (char *str)
3118 {
3119   struct directive *d = xmalloc (sizeof (struct directive));
3120 
3121   d->next = directives;
3122   directives = d;
3123   d->name = xstrdup (str);
3124   d->len = strlen (str);
3125 }
3126 
3127 static void
3128 def_aligncomm (char *str, int align)
3129 {
3130   def_file_aligncomm *c, *p;
3131 
3132   p = NULL;
3133   c = def->aligncomms;
3134   while (c != NULL)
3135     {
3136       int e = strcmp (c->symbol_name, str);
3137       if (!e)
3138 	{
3139 	  /* Not sure if we want to allow here duplicates with
3140 	     different alignments, but for now we keep them.  */
3141 	  e = (int) c->alignment - align;
3142 	  if (!e)
3143 	    return;
3144 	}
3145       if (e > 0)
3146 	break;
3147       c = (p = c)->next;
3148     }
3149 
3150   c = xmalloc (sizeof (def_file_aligncomm));
3151   c->symbol_name = xstrdup (str);
3152   c->alignment = (unsigned int) align;
3153   if (!p)
3154     {
3155       c->next = def->aligncomms;
3156       def->aligncomms = c;
3157     }
3158   else
3159     {
3160       c->next = p->next;
3161       p->next = c;
3162     }
3163 }
3164 
3165 static int
3166 def_error (const char *err)
3167 {
3168   einfo ("%P: %s:%d: %s\n",
3169 	 def_filename ? def_filename : "<unknown-file>", linenumber, err);
3170   return 0;
3171 }
3172 
3173 
3174 /* Lexical Scanner.  */
3175 
3176 #undef TRACE
3177 #define TRACE 0
3178 
3179 /* Never freed, but always reused as needed, so no real leak.  */
3180 static char *buffer = 0;
3181 static int buflen = 0;
3182 static int bufptr = 0;
3183 
3184 static void
3185 put_buf (char c)
3186 {
3187   if (bufptr == buflen)
3188     {
3189       buflen += 50;		/* overly reasonable, eh?  */
3190       if (buffer)
3191 	buffer = xrealloc (buffer, buflen + 1);
3192       else
3193 	buffer = xmalloc (buflen + 1);
3194     }
3195   buffer[bufptr++] = c;
3196   buffer[bufptr] = 0;		/* not optimal, but very convenient.  */
3197 }
3198 
3199 static struct
3200 {
3201   char *name;
3202   int token;
3203 }
3204 tokens[] =
3205 {
3206   { "BASE", BASE },
3207   { "CODE", CODE },
3208   { "CONSTANT", CONSTANTU },
3209   { "constant", CONSTANTL },
3210   { "DATA", DATAU },
3211   { "data", DATAL },
3212   { "DESCRIPTION", DESCRIPTION },
3213   { "DIRECTIVE", DIRECTIVE },
3214   { "EXECUTE", EXECUTE },
3215   { "EXPORTS", EXPORTS },
3216   { "HEAPSIZE", HEAPSIZE },
3217   { "IMPORTS", IMPORTS },
3218   { "LIBRARY", LIBRARY },
3219   { "NAME", NAME },
3220   { "NONAME", NONAMEU },
3221   { "noname", NONAMEL },
3222   { "PRIVATE", PRIVATEU },
3223   { "private", PRIVATEL },
3224   { "READ", READ },
3225   { "SECTIONS", SECTIONS },
3226   { "SEGMENTS", SECTIONS },
3227   { "SHARED", SHARED },
3228   { "STACKSIZE", STACKSIZE_K },
3229   { "VERSION", VERSIONK },
3230   { "WRITE", WRITE },
3231   { 0, 0 }
3232 };
3233 
3234 static int
3235 def_getc (void)
3236 {
3237   int rv;
3238 
3239   if (lex_parse_string)
3240     {
3241       if (lex_parse_string >= lex_parse_string_end)
3242 	rv = EOF;
3243       else
3244 	rv = *lex_parse_string++;
3245     }
3246   else
3247     {
3248       rv = fgetc (the_file);
3249     }
3250   if (rv == '\n')
3251     saw_newline = 1;
3252   return rv;
3253 }
3254 
3255 static int
3256 def_ungetc (int c)
3257 {
3258   if (lex_parse_string)
3259     {
3260       lex_parse_string--;
3261       return c;
3262     }
3263   else
3264     return ungetc (c, the_file);
3265 }
3266 
3267 static int
3268 def_lex (void)
3269 {
3270   int c, i, q;
3271 
3272   if (lex_forced_token)
3273     {
3274       i = lex_forced_token;
3275       lex_forced_token = 0;
3276 #if TRACE
3277       printf ("lex: forcing token %d\n", i);
3278 #endif
3279       return i;
3280     }
3281 
3282   c = def_getc ();
3283 
3284   /* Trim leading whitespace.  */
3285   while (c != EOF && (c == ' ' || c == '\t') && saw_newline)
3286     c = def_getc ();
3287 
3288   if (c == EOF)
3289     {
3290 #if TRACE
3291       printf ("lex: EOF\n");
3292 #endif
3293       return 0;
3294     }
3295 
3296   if (saw_newline && c == ';')
3297     {
3298       do
3299 	{
3300 	  c = def_getc ();
3301 	}
3302       while (c != EOF && c != '\n');
3303       if (c == '\n')
3304 	return def_lex ();
3305       return 0;
3306     }
3307 
3308   /* Must be something else.  */
3309   saw_newline = 0;
3310 
3311   if (ISDIGIT (c))
3312     {
3313       bufptr = 0;
3314       while (c != EOF && (ISXDIGIT (c) || (c == 'x')))
3315 	{
3316 	  put_buf (c);
3317 	  c = def_getc ();
3318 	}
3319       if (c != EOF)
3320 	def_ungetc (c);
3321       yylval.digits = def_pool_strdup (buffer);
3322 #if TRACE
3323       printf ("lex: `%s' returns DIGITS\n", buffer);
3324 #endif
3325       return DIGITS;
3326     }
3327 
3328   if (ISALPHA (c) || strchr ("$:-_?@", c))
3329     {
3330       bufptr = 0;
3331       q = c;
3332       put_buf (c);
3333       c = def_getc ();
3334 
3335       if (q == '@')
3336 	{
3337 	  if (ISBLANK (c) ) /* '@' followed by whitespace.  */
3338 	    return (q);
3339 	  else if (ISDIGIT (c)) /* '@' followed by digit.  */
3340 	    {
3341 	      def_ungetc (c);
3342 	      return (q);
3343 	    }
3344 #if TRACE
3345 	  printf ("lex: @ returns itself\n");
3346 #endif
3347 	}
3348 
3349       while (c != EOF && (ISALNUM (c) || strchr ("$:-_?/@<>", c)))
3350 	{
3351 	  put_buf (c);
3352 	  c = def_getc ();
3353 	}
3354       if (c != EOF)
3355 	def_ungetc (c);
3356       if (ISALPHA (q)) /* Check for tokens.  */
3357 	{
3358 	  for (i = 0; tokens[i].name; i++)
3359 	    if (strcmp (tokens[i].name, buffer) == 0)
3360 	      {
3361 #if TRACE
3362 	        printf ("lex: `%s' is a string token\n", buffer);
3363 #endif
3364 	        return tokens[i].token;
3365 	      }
3366 	}
3367 #if TRACE
3368       printf ("lex: `%s' returns ID\n", buffer);
3369 #endif
3370       yylval.id = def_pool_strdup (buffer);
3371       return ID;
3372     }
3373 
3374   if (c == '\'' || c == '"')
3375     {
3376       q = c;
3377       c = def_getc ();
3378       bufptr = 0;
3379 
3380       while (c != EOF && c != q)
3381 	{
3382 	  put_buf (c);
3383 	  c = def_getc ();
3384 	}
3385       yylval.id = def_pool_strdup (buffer);
3386 #if TRACE
3387       printf ("lex: `%s' returns ID\n", buffer);
3388 #endif
3389       return ID;
3390     }
3391 
3392   if ( c == '=')
3393     {
3394       c = def_getc ();
3395       if (c == '=')
3396 	{
3397 #if TRACE
3398 	  printf ("lex: `==' returns EQUAL\n");
3399 #endif
3400 	  return EQUAL;
3401 	}
3402       def_ungetc (c);
3403 #if TRACE
3404       printf ("lex: `=' returns itself\n");
3405 #endif
3406       return '=';
3407     }
3408   if (c == '.' || c == ',')
3409     {
3410 #if TRACE
3411       printf ("lex: `%c' returns itself\n", c);
3412 #endif
3413       return c;
3414     }
3415 
3416   if (c == '\n')
3417     {
3418       linenumber++;
3419       saw_newline = 1;
3420     }
3421 
3422   /*printf ("lex: 0x%02x ignored\n", c); */
3423   return def_lex ();
3424 }
3425 
3426 static char *
3427 def_pool_alloc (size_t sz)
3428 {
3429   def_pool_str *e;
3430 
3431   e = (def_pool_str *) xmalloc (sizeof (def_pool_str) + sz);
3432   e->next = pool_strs;
3433   pool_strs = e;
3434   return e->data;
3435 }
3436 
3437 static char *
3438 def_pool_strdup (const char *str)
3439 {
3440   char *s;
3441   size_t len;
3442   if (!str)
3443     return NULL;
3444   len = strlen (str) + 1;
3445   s = def_pool_alloc (len);
3446   memcpy (s, str, len);
3447   return s;
3448 }
3449 
3450 static void
3451 def_pool_free (void)
3452 {
3453   def_pool_str *p;
3454   while ((p = pool_strs) != NULL)
3455     {
3456       pool_strs = p->next;
3457       free (p);
3458     }
3459 }
3460