Subversion Repositories Kolibri OS

Rev

Rev 5199 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

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