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