1/* A Bison parser, made by GNU Bison 2.3. */ 2 3/* Skeleton implementation for Bison's Yacc-like parsers in C 4 5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 6 Free Software Foundation, Inc. 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2, or (at your option) 11 any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 Boston, MA 02110-1301, USA. */ 22 23/* As a special exception, you may create a larger work that contains 24 part or all of the Bison parser skeleton and distribute that work 25 under terms of your choice, so long as that work isn't itself a 26 parser generator using the skeleton or a modified version thereof 27 as a parser skeleton. Alternatively, if you modify or redistribute 28 the parser skeleton itself, you may (at your option) remove this 29 special exception, which will cause the skeleton and the resulting 30 Bison output files to be licensed under the GNU General Public 31 License without this special exception. 32 33 This special exception was added by the Free Software Foundation in 34 version 2.2 of Bison. */ 35 36/* C LALR(1) parser skeleton written by Richard Stallman, by 37 simplifying the original so-called "semantic" parser. */ 38 39/* All symbols defined below should begin with yy or YY, to avoid 40 infringing on user name space. This should be done even for local 41 variables, as they might otherwise be expanded by user macros. 42 There are some unavoidable exceptions within include files to 43 define necessary library symbols; they are noted "INFRINGES ON 44 USER NAME SPACE" below. */ 45 46/* Identify Bison output. */ 47#define YYBISON 1 48 49/* Bison version. */ 50#define YYBISON_VERSION "2.3" 51 52/* Skeleton name. */ 53#define YYSKELETON_NAME "yacc.c" 54 55/* Pure parsers. */ 56#define YYPURE 0 57 58/* Using locations. */ 59#define YYLSP_NEEDED 0 60 61/* Substitute the variable and function names. */ 62#define yyparse ldparse 63#define yylex ldlex 64#define yyerror lderror 65#define yylval ldlval 66#define yychar ldchar 67#define yydebug lddebug 68#define yynerrs ldnerrs 69 70 71/* Tokens. */ 72#ifndef YYTOKENTYPE 73# define YYTOKENTYPE 74 /* Put the tokens into the symbol table, so that GDB and other debuggers 75 know about them. */ 76 enum yytokentype { 77 kADD_OP = 258, 78 kALIGN = 259, 79 kAS_NEEDED = 260, 80 kENTRY = 261, 81 kEXCLUDE_FILE = 262, 82 kFILENAME = 263, 83 kGLOBAL = 264, 84 kGROUP = 265, 85 kID = 266, 86 kINPUT = 267, 87 kINTERP = 268, 88 kKEEP = 269, 89 kLOCAL = 270, 90 kMODE = 271, 91 kMUL_OP = 272, 92 kNUM = 273, 93 kOUTPUT_FORMAT = 274, 94 kPAGESIZE = 275, 95 kPROVIDE = 276, 96 kSEARCH_DIR = 277, 97 kSEGMENT = 278, 98 kSIZEOF_HEADERS = 279, 99 kSORT = 280, 100 kVERSION = 281, 101 kVERSION_SCRIPT = 282, 102 ADD_OP = 283, 103 MUL_OP = 284 104 }; 105#endif 106/* Tokens. */ 107#define kADD_OP 258 108#define kALIGN 259 109#define kAS_NEEDED 260 110#define kENTRY 261 111#define kEXCLUDE_FILE 262 112#define kFILENAME 263 113#define kGLOBAL 264 114#define kGROUP 265 115#define kID 266 116#define kINPUT 267 117#define kINTERP 268 118#define kKEEP 269 119#define kLOCAL 270 120#define kMODE 271 121#define kMUL_OP 272 122#define kNUM 273 123#define kOUTPUT_FORMAT 274 124#define kPAGESIZE 275 125#define kPROVIDE 276 126#define kSEARCH_DIR 277 127#define kSEGMENT 278 128#define kSIZEOF_HEADERS 279 129#define kSORT 280 130#define kVERSION 281 131#define kVERSION_SCRIPT 282 132#define ADD_OP 283 133#define MUL_OP 284 134 135 136 137 138/* Copy the first part of user declarations. */ 139#line 1 "ldscript.y" 140 141/* Parser for linker scripts. 142 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc. 143 This file is part of Red Hat elfutils. 144 Written by Ulrich Drepper <drepper@redhat.com>, 2001. 145 146 Red Hat elfutils is free software; you can redistribute it and/or modify 147 it under the terms of the GNU General Public License as published by the 148 Free Software Foundation; version 2 of the License. 149 150 Red Hat elfutils is distributed in the hope that it will be useful, but 151 WITHOUT ANY WARRANTY; without even the implied warranty of 152 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 153 General Public License for more details. 154 155 You should have received a copy of the GNU General Public License along 156 with Red Hat elfutils; if not, write to the Free Software Foundation, 157 Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. 158 159 Red Hat elfutils is an included package of the Open Invention Network. 160 An included package of the Open Invention Network is a package for which 161 Open Invention Network licensees cross-license their patents. No patent 162 license is granted, either expressly or impliedly, by designation as an 163 included package. Should you wish to participate in the Open Invention 164 Network licensing program, please visit www.openinventionnetwork.com 165 <http://www.openinventionnetwork.com>. */ 166 167#ifdef HAVE_CONFIG_H 168# include <config.h> 169#endif 170 171#include <assert.h> 172#include <error.h> 173#include <libintl.h> 174#include <stdbool.h> 175#include <stdint.h> 176#include <stdio.h> 177#include <stdlib.h> 178#include <string.h> 179 180#include <system.h> 181#include <ld.h> 182 183/* The error handler. */ 184static void yyerror (const char *s); 185 186/* Some helper functions we need to construct the data structures 187 describing information from the file. */ 188static struct expression *new_expr (int tag); 189static struct input_section_name *new_input_section_name (const char *name, 190 bool sort_flag); 191static struct input_rule *new_input_rule (int tag); 192static struct output_rule *new_output_rule (int tag); 193static struct assignment *new_assignment (const char *variable, 194 struct expression *expression, 195 bool provide_flag); 196static void new_segment (int mode, struct output_rule *output_rule); 197static struct filename_list *new_filename_listelem (const char *string); 198static void add_inputfiles (struct filename_list *fnames); 199static struct id_list *new_id_listelem (const char *str); 200 static struct filename_list *mark_as_needed (struct filename_list *listp); 201static struct version *new_version (struct id_list *local, 202 struct id_list *global); 203static struct version *merge_versions (struct version *one, 204 struct version *two); 205static void add_versions (struct version *versions); 206 207extern int yylex (void); 208 209 210/* Enabling traces. */ 211#ifndef YYDEBUG 212# define YYDEBUG 0 213#endif 214 215/* Enabling verbose error messages. */ 216#ifdef YYERROR_VERBOSE 217# undef YYERROR_VERBOSE 218# define YYERROR_VERBOSE 1 219#else 220# define YYERROR_VERBOSE 0 221#endif 222 223/* Enabling the token table. */ 224#ifndef YYTOKEN_TABLE 225# define YYTOKEN_TABLE 0 226#endif 227 228#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 229typedef union YYSTYPE 230#line 71 "ldscript.y" 231{ 232 uintmax_t num; 233 enum expression_tag op; 234 char *str; 235 struct expression *expr; 236 struct input_section_name *sectionname; 237 struct filemask_section_name *filemask_section_name; 238 struct input_rule *input_rule; 239 struct output_rule *output_rule; 240 struct assignment *assignment; 241 struct filename_list *filename_list; 242 struct version *version; 243 struct id_list *id_list; 244} 245/* Line 187 of yacc.c. */ 246#line 247 "ldscript.c" 247 YYSTYPE; 248# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 249# define YYSTYPE_IS_DECLARED 1 250# define YYSTYPE_IS_TRIVIAL 1 251#endif 252 253 254 255/* Copy the second part of user declarations. */ 256 257 258/* Line 216 of yacc.c. */ 259#line 260 "ldscript.c" 260 261#ifdef short 262# undef short 263#endif 264 265#ifdef YYTYPE_UINT8 266typedef YYTYPE_UINT8 yytype_uint8; 267#else 268typedef unsigned char yytype_uint8; 269#endif 270 271#ifdef YYTYPE_INT8 272typedef YYTYPE_INT8 yytype_int8; 273#elif (defined __STDC__ || defined __C99__FUNC__ \ 274 || defined __cplusplus || defined _MSC_VER) 275typedef signed char yytype_int8; 276#else 277typedef short int yytype_int8; 278#endif 279 280#ifdef YYTYPE_UINT16 281typedef YYTYPE_UINT16 yytype_uint16; 282#else 283typedef unsigned short int yytype_uint16; 284#endif 285 286#ifdef YYTYPE_INT16 287typedef YYTYPE_INT16 yytype_int16; 288#else 289typedef short int yytype_int16; 290#endif 291 292#ifndef YYSIZE_T 293# ifdef __SIZE_TYPE__ 294# define YYSIZE_T __SIZE_TYPE__ 295# elif defined size_t 296# define YYSIZE_T size_t 297# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ 298 || defined __cplusplus || defined _MSC_VER) 299# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 300# define YYSIZE_T size_t 301# else 302# define YYSIZE_T unsigned int 303# endif 304#endif 305 306#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) 307 308#ifndef YY_ 309# if YYENABLE_NLS 310# if ENABLE_NLS 311# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ 312# define YY_(msgid) dgettext ("bison-runtime", msgid) 313# endif 314# endif 315# ifndef YY_ 316# define YY_(msgid) msgid 317# endif 318#endif 319 320/* Suppress unused-variable warnings by "using" E. */ 321#if ! defined lint || defined __GNUC__ 322# define YYUSE(e) ((void) (e)) 323#else 324# define YYUSE(e) /* empty */ 325#endif 326 327/* Identity function, used to suppress warnings about constant conditions. */ 328#ifndef lint 329# define YYID(n) (n) 330#else 331#if (defined __STDC__ || defined __C99__FUNC__ \ 332 || defined __cplusplus || defined _MSC_VER) 333static int 334YYID (int i) 335#else 336static int 337YYID (i) 338 int i; 339#endif 340{ 341 return i; 342} 343#endif 344 345#if ! defined yyoverflow || YYERROR_VERBOSE 346 347/* The parser invokes alloca or malloc; define the necessary symbols. */ 348 349# ifdef YYSTACK_USE_ALLOCA 350# if YYSTACK_USE_ALLOCA 351# ifdef __GNUC__ 352# define YYSTACK_ALLOC __builtin_alloca 353# elif defined __BUILTIN_VA_ARG_INCR 354# include <alloca.h> /* INFRINGES ON USER NAME SPACE */ 355# elif defined _AIX 356# define YYSTACK_ALLOC __alloca 357# elif defined _MSC_VER 358# include <malloc.h> /* INFRINGES ON USER NAME SPACE */ 359# define alloca _alloca 360# else 361# define YYSTACK_ALLOC alloca 362# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 363 || defined __cplusplus || defined _MSC_VER) 364# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 365# ifndef _STDLIB_H 366# define _STDLIB_H 1 367# endif 368# endif 369# endif 370# endif 371# endif 372 373# ifdef YYSTACK_ALLOC 374 /* Pacify GCC's `empty if-body' warning. */ 375# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) 376# ifndef YYSTACK_ALLOC_MAXIMUM 377 /* The OS might guarantee only one guard page at the bottom of the stack, 378 and a page size can be as small as 4096 bytes. So we cannot safely 379 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number 380 to allow for a few compiler-allocated temporary stack slots. */ 381# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ 382# endif 383# else 384# define YYSTACK_ALLOC YYMALLOC 385# define YYSTACK_FREE YYFREE 386# ifndef YYSTACK_ALLOC_MAXIMUM 387# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM 388# endif 389# if (defined __cplusplus && ! defined _STDLIB_H \ 390 && ! ((defined YYMALLOC || defined malloc) \ 391 && (defined YYFREE || defined free))) 392# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 393# ifndef _STDLIB_H 394# define _STDLIB_H 1 395# endif 396# endif 397# ifndef YYMALLOC 398# define YYMALLOC malloc 399# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 400 || defined __cplusplus || defined _MSC_VER) 401void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ 402# endif 403# endif 404# ifndef YYFREE 405# define YYFREE free 406# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 407 || defined __cplusplus || defined _MSC_VER) 408void free (void *); /* INFRINGES ON USER NAME SPACE */ 409# endif 410# endif 411# endif 412#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ 413 414 415#if (! defined yyoverflow \ 416 && (! defined __cplusplus \ 417 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) 418 419/* A type that is properly aligned for any stack member. */ 420union yyalloc 421{ 422 yytype_int16 yyss; 423 YYSTYPE yyvs; 424 }; 425 426/* The size of the maximum gap between one aligned stack and the next. */ 427# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) 428 429/* The size of an array large to enough to hold all stacks, each with 430 N elements. */ 431# define YYSTACK_BYTES(N) \ 432 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ 433 + YYSTACK_GAP_MAXIMUM) 434 435/* Copy COUNT objects from FROM to TO. The source and destination do 436 not overlap. */ 437# ifndef YYCOPY 438# if defined __GNUC__ && 1 < __GNUC__ 439# define YYCOPY(To, From, Count) \ 440 __builtin_memcpy (To, From, (Count) * sizeof (*(From))) 441# else 442# define YYCOPY(To, From, Count) \ 443 do \ 444 { \ 445 YYSIZE_T yyi; \ 446 for (yyi = 0; yyi < (Count); yyi++) \ 447 (To)[yyi] = (From)[yyi]; \ 448 } \ 449 while (YYID (0)) 450# endif 451# endif 452 453/* Relocate STACK from its old location to the new one. The 454 local variables YYSIZE and YYSTACKSIZE give the old and new number of 455 elements in the stack, and YYPTR gives the new location of the 456 stack. Advance YYPTR to a properly aligned location for the next 457 stack. */ 458# define YYSTACK_RELOCATE(Stack) \ 459 do \ 460 { \ 461 YYSIZE_T yynewbytes; \ 462 YYCOPY (&yyptr->Stack, Stack, yysize); \ 463 Stack = &yyptr->Stack; \ 464 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ 465 yyptr += yynewbytes / sizeof (*yyptr); \ 466 } \ 467 while (YYID (0)) 468 469#endif 470 471/* YYFINAL -- State number of the termination state. */ 472#define YYFINAL 32 473/* YYLAST -- Last index in YYTABLE. */ 474#define YYLAST 226 475 476/* YYNTOKENS -- Number of terminals. */ 477#define YYNTOKENS 40 478/* YYNNTS -- Number of nonterminals. */ 479#define YYNNTS 23 480/* YYNRULES -- Number of rules. */ 481#define YYNRULES 66 482/* YYNRULES -- Number of states. */ 483#define YYNSTATES 159 484 485/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 486#define YYUNDEFTOK 2 487#define YYMAXUTOK 284 488 489#define YYTRANSLATE(YYX) \ 490 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) 491 492/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ 493static const yytype_uint8 yytranslate[] = 494{ 495 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 496 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 497 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 498 2, 2, 2, 2, 2, 2, 2, 2, 29, 2, 499 33, 34, 31, 2, 39, 2, 2, 2, 2, 2, 500 2, 2, 2, 2, 2, 2, 2, 2, 2, 35, 501 2, 38, 2, 2, 2, 2, 2, 2, 2, 2, 502 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 503 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 504 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 505 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 506 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 507 2, 2, 2, 36, 28, 37, 2, 2, 2, 2, 508 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 510 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 511 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 512 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 513 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 514 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 515 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 516 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 519 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 520 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 521 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 522 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 523 25, 26, 27, 30, 32 524}; 525 526#if YYDEBUG 527/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in 528 YYRHS. */ 529static const yytype_uint8 yyprhs[] = 530{ 531 0, 0, 3, 5, 8, 11, 13, 19, 25, 31, 532 37, 43, 49, 54, 59, 64, 69, 74, 77, 79, 533 82, 87, 90, 94, 101, 104, 106, 108, 113, 116, 534 122, 124, 129, 134, 135, 140, 144, 148, 152, 156, 535 160, 164, 166, 168, 170, 172, 176, 178, 180, 181, 536 186, 191, 193, 196, 198, 203, 209, 216, 219, 221, 537 224, 227, 231, 234, 236, 238, 240 538}; 539 540/* YYRHS -- A `-1'-separated list of the rules' RHS. */ 541static const yytype_int8 yyrhs[] = 542{ 543 41, 0, -1, 42, -1, 27, 56, -1, 42, 43, 544 -1, 43, -1, 6, 33, 11, 34, 35, -1, 22, 545 33, 61, 34, 35, -1, 20, 33, 18, 34, 35, 546 -1, 13, 33, 61, 34, 35, -1, 23, 16, 36, 547 44, 37, -1, 23, 1, 36, 44, 37, -1, 10, 548 33, 53, 34, -1, 12, 33, 53, 34, -1, 5, 549 33, 53, 34, -1, 26, 36, 56, 37, -1, 19, 550 33, 61, 34, -1, 44, 45, -1, 45, -1, 46, 551 35, -1, 11, 36, 47, 37, -1, 11, 35, -1, 552 11, 38, 52, -1, 21, 33, 11, 38, 52, 34, 553 -1, 47, 48, -1, 48, -1, 49, -1, 14, 33, 554 49, 34, -1, 46, 35, -1, 62, 33, 51, 50, 555 34, -1, 11, -1, 25, 33, 11, 34, -1, 7, 556 33, 61, 34, -1, -1, 4, 33, 52, 34, -1, 557 33, 52, 34, -1, 52, 31, 52, -1, 52, 17, 558 52, -1, 52, 3, 52, -1, 52, 29, 52, -1, 559 52, 28, 52, -1, 18, -1, 11, -1, 24, -1, 560 20, -1, 53, 54, 55, -1, 55, -1, 39, -1, 561 -1, 10, 33, 53, 34, -1, 5, 33, 53, 34, 562 -1, 61, -1, 56, 57, -1, 57, -1, 36, 58, 563 37, 35, -1, 61, 36, 58, 37, 35, -1, 61, 564 36, 58, 37, 61, 35, -1, 58, 59, -1, 59, 565 -1, 9, 60, -1, 15, 60, -1, 60, 62, 35, 566 -1, 62, 35, -1, 8, -1, 11, -1, 61, -1, 567 31, -1 568}; 569 570/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 571static const yytype_uint16 yyrline[] = 572{ 573 0, 143, 143, 144, 148, 149, 152, 157, 161, 166, 574 172, 176, 182, 193, 195, 197, 199, 203, 208, 212, 575 217, 229, 253, 255, 259, 264, 268, 273, 280, 287, 576 298, 300, 304, 307, 310, 315, 317, 323, 329, 335, 577 341, 347, 352, 357, 359, 363, 368, 372, 373, 376, 578 387, 389, 394, 399, 403, 409, 415, 424, 426, 430, 579 432, 437, 443, 447, 449, 453, 455 580}; 581#endif 582 583#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE 584/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. 585 First, the terminals, then, starting at YYNTOKENS, nonterminals. */ 586static const char *const yytname[] = 587{ 588 "$end", "error", "$undefined", "kADD_OP", "kALIGN", "kAS_NEEDED", 589 "kENTRY", "kEXCLUDE_FILE", "kFILENAME", "kGLOBAL", "kGROUP", "kID", 590 "kINPUT", "kINTERP", "kKEEP", "kLOCAL", "kMODE", "kMUL_OP", "kNUM", 591 "kOUTPUT_FORMAT", "kPAGESIZE", "kPROVIDE", "kSEARCH_DIR", "kSEGMENT", 592 "kSIZEOF_HEADERS", "kSORT", "kVERSION", "kVERSION_SCRIPT", "'|'", "'&'", 593 "ADD_OP", "'*'", "MUL_OP", "'('", "')'", "';'", "'{'", "'}'", "'='", 594 "','", "$accept", "script_or_version", "file", "content", 595 "outputsections", "outputsection", "assignment", "inputsections", 596 "inputsection", "sectionname", "sort_opt_name", "exclude_opt", "expr", 597 "filename_id_list", "comma_opt", "filename_id_listelem", "versionlist", 598 "version", "version_stmt_list", "version_stmt", "filename_id_star_list", 599 "filename_id", "filename_id_star", 0 600}; 601#endif 602 603# ifdef YYPRINT 604/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to 605 token YYLEX-NUM. */ 606static const yytype_uint16 yytoknum[] = 607{ 608 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 609 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 610 275, 276, 277, 278, 279, 280, 281, 282, 124, 38, 611 283, 42, 284, 40, 41, 59, 123, 125, 61, 44 612}; 613# endif 614 615/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 616static const yytype_uint8 yyr1[] = 617{ 618 0, 40, 41, 41, 42, 42, 43, 43, 43, 43, 619 43, 43, 43, 43, 43, 43, 43, 44, 44, 45, 620 45, 45, 46, 46, 47, 47, 48, 48, 48, 49, 621 50, 50, 51, 51, 52, 52, 52, 52, 52, 52, 622 52, 52, 52, 52, 52, 53, 53, 54, 54, 55, 623 55, 55, 56, 56, 57, 57, 57, 58, 58, 59, 624 59, 60, 60, 61, 61, 62, 62 625}; 626 627/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 628static const yytype_uint8 yyr2[] = 629{ 630 0, 2, 1, 2, 2, 1, 5, 5, 5, 5, 631 5, 5, 4, 4, 4, 4, 4, 2, 1, 2, 632 4, 2, 3, 6, 2, 1, 1, 4, 2, 5, 633 1, 4, 4, 0, 4, 3, 3, 3, 3, 3, 634 3, 1, 1, 1, 1, 3, 1, 1, 0, 4, 635 4, 1, 2, 1, 4, 5, 6, 2, 1, 2, 636 2, 3, 2, 1, 1, 1, 1 637}; 638 639/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state 640 STATE-NUM when YYTABLE doesn't specify something else to do. Zero 641 means the default is an error. */ 642static const yytype_uint8 yydefact[] = 643{ 644 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 645 0, 0, 0, 2, 5, 0, 0, 0, 0, 0, 646 0, 0, 0, 0, 0, 0, 63, 64, 0, 3, 647 53, 0, 1, 4, 0, 0, 48, 46, 51, 0, 648 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 649 0, 0, 58, 52, 0, 0, 0, 14, 47, 0, 650 0, 12, 13, 0, 16, 0, 0, 0, 0, 0, 651 18, 0, 0, 15, 66, 59, 65, 0, 60, 0, 652 57, 0, 48, 48, 45, 6, 9, 8, 7, 21, 653 0, 0, 0, 11, 17, 19, 10, 0, 62, 54, 654 0, 50, 49, 64, 0, 0, 0, 25, 26, 0, 655 0, 42, 41, 44, 43, 0, 22, 0, 61, 55, 656 0, 0, 28, 20, 24, 33, 0, 0, 0, 0, 657 0, 0, 0, 0, 56, 0, 0, 0, 0, 35, 658 38, 37, 40, 39, 36, 0, 27, 0, 30, 0, 659 0, 34, 23, 0, 0, 29, 32, 0, 31 660}; 661 662/* YYDEFGOTO[NTERM-NUM]. */ 663static const yytype_int16 yydefgoto[] = 664{ 665 -1, 12, 13, 14, 69, 70, 71, 106, 107, 108, 666 150, 137, 116, 36, 59, 37, 29, 30, 51, 52, 667 75, 76, 109 668}; 669 670/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 671 STATE-NUM. */ 672#define YYPACT_NINF -86 673static const yytype_int16 yypact[] = 674{ 675 111, -18, -14, 23, 45, 70, 75, 85, 92, 97, 676 91, 19, 128, 134, -86, 162, 96, 162, 162, 5, 677 5, 123, 5, 93, 99, 19, -86, -86, 117, 19, 678 -86, 115, -86, -86, 125, 144, 71, -86, -86, 145, 679 116, 135, 147, 148, 149, 150, 101, 101, 14, 83, 680 83, 55, -86, -86, 117, 162, 162, -86, -86, 162, 681 133, -86, -86, 143, -86, 151, 152, 107, 155, 63, 682 -86, 154, 74, -86, -86, 83, -86, 156, 83, 157, 683 -86, 56, 137, 141, -86, -86, -86, -86, -86, -86, 684 88, 48, 174, -86, -86, -86, -86, 158, -86, -86, 685 69, -86, -86, 159, 161, 160, 12, -86, -86, 163, 686 165, -86, -86, -86, -86, 48, 59, 164, -86, -86, 687 166, 83, -86, -86, -86, 183, 48, 0, 48, 48, 688 48, 48, 48, 48, -86, 169, 167, 90, 7, -86, 689 59, 59, 44, 66, 103, 29, -86, 5, -86, 171, 690 172, -86, -86, 173, 188, -86, -86, 175, -86 691}; 692 693/* YYPGOTO[NTERM-NUM]. */ 694static const yytype_int16 yypgoto[] = 695{ 696 -86, -86, -86, 192, 168, 80, -85, -86, 102, 89, 697 -86, -86, 33, -16, -86, 153, 186, 38, 170, -39, 698 176, -11, 4 699}; 700 701/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 702 positive, shift that token. If negative, reduce the rule which 703 number is the opposite. If zero, do what YYDEFACT says. 704 If YYTABLE_NINF, syntax error. */ 705#define YYTABLE_NINF -1 706static const yytype_uint8 yytable[] = 707{ 708 31, 40, 41, 128, 38, 105, 38, 38, 42, 43, 709 128, 45, 80, 26, 31, 15, 27, 129, 31, 16, 710 26, 105, 26, 103, 129, 27, 104, 26, 130, 131, 711 27, 132, 128, 68, 139, 130, 131, 31, 132, 82, 712 83, 151, 80, 74, 38, 38, 129, 128, 38, 123, 713 28, 73, 110, 77, 77, 28, 17, 130, 131, 111, 714 132, 129, 128, 152, 49, 49, 112, 53, 113, 128, 715 50, 50, 114, 131, 67, 132, 129, 26, 18, 97, 716 27, 115, 97, 129, 68, 67, 53, 130, 131, 120, 717 132, 26, 79, 100, 27, 68, 26, 132, 23, 103, 718 93, 148, 104, 19, 119, 57, 128, 39, 20, 68, 719 58, 96, 67, 24, 74, 149, 1, 2, 21, 74, 720 129, 3, 68, 4, 5, 22, 49, 25, 32, 46, 721 6, 7, 50, 8, 9, 47, 153, 10, 11, 1, 722 2, 44, 89, 90, 3, 91, 4, 5, 127, 94, 723 61, 54, 94, 6, 7, 58, 8, 9, 55, 138, 724 10, 140, 141, 142, 143, 144, 145, 34, 85, 62, 725 26, 101, 35, 27, 58, 102, 58, 56, 86, 60, 726 58, 63, 64, 65, 66, 117, 87, 88, 92, 95, 727 136, 98, 99, 118, 121, 122, 125, 91, 126, 157, 728 147, 134, 133, 146, 154, 33, 155, 156, 124, 158, 729 135, 48, 84, 0, 0, 72, 0, 0, 0, 0, 730 0, 0, 0, 0, 81, 0, 78 731}; 732 733static const yytype_int16 yycheck[] = 734{ 735 11, 17, 18, 3, 15, 90, 17, 18, 19, 20, 736 3, 22, 51, 8, 25, 33, 11, 17, 29, 33, 737 8, 106, 8, 11, 17, 11, 14, 8, 28, 29, 738 11, 31, 3, 21, 34, 28, 29, 48, 31, 55, 739 56, 34, 81, 31, 55, 56, 17, 3, 59, 37, 740 36, 37, 4, 49, 50, 36, 33, 28, 29, 11, 741 31, 17, 3, 34, 9, 9, 18, 29, 20, 3, 742 15, 15, 24, 29, 11, 31, 17, 8, 33, 75, 743 11, 33, 78, 17, 21, 11, 48, 28, 29, 100, 744 31, 8, 37, 37, 11, 21, 8, 31, 1, 11, 745 37, 11, 14, 33, 35, 34, 3, 11, 33, 21, 746 39, 37, 11, 16, 31, 25, 5, 6, 33, 31, 747 17, 10, 21, 12, 13, 33, 9, 36, 0, 36, 748 19, 20, 15, 22, 23, 36, 147, 26, 27, 5, 749 6, 18, 35, 36, 10, 38, 12, 13, 115, 69, 750 34, 36, 72, 19, 20, 39, 22, 23, 33, 126, 751 26, 128, 129, 130, 131, 132, 133, 5, 35, 34, 752 8, 34, 10, 11, 39, 34, 39, 33, 35, 34, 753 39, 34, 34, 34, 34, 11, 35, 35, 33, 35, 754 7, 35, 35, 35, 33, 35, 33, 38, 33, 11, 755 33, 35, 38, 34, 33, 13, 34, 34, 106, 34, 756 121, 25, 59, -1, -1, 47, -1, -1, -1, -1, 757 -1, -1, -1, -1, 54, -1, 50 758}; 759 760/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing 761 symbol of state STATE-NUM. */ 762static const yytype_uint8 yystos[] = 763{ 764 0, 5, 6, 10, 12, 13, 19, 20, 22, 23, 765 26, 27, 41, 42, 43, 33, 33, 33, 33, 33, 766 33, 33, 33, 1, 16, 36, 8, 11, 36, 56, 767 57, 61, 0, 43, 5, 10, 53, 55, 61, 11, 768 53, 53, 61, 61, 18, 61, 36, 36, 56, 9, 769 15, 58, 59, 57, 36, 33, 33, 34, 39, 54, 770 34, 34, 34, 34, 34, 34, 34, 11, 21, 44, 771 45, 46, 44, 37, 31, 60, 61, 62, 60, 37, 772 59, 58, 53, 53, 55, 35, 35, 35, 35, 35, 773 36, 38, 33, 37, 45, 35, 37, 62, 35, 35, 774 37, 34, 34, 11, 14, 46, 47, 48, 49, 62, 775 4, 11, 18, 20, 24, 33, 52, 11, 35, 35, 776 61, 33, 35, 37, 48, 33, 33, 52, 3, 17, 777 28, 29, 31, 38, 35, 49, 7, 51, 52, 34, 778 52, 52, 52, 52, 52, 52, 34, 33, 11, 25, 779 50, 34, 34, 61, 33, 34, 34, 11, 34 780}; 781 782#define yyerrok (yyerrstatus = 0) 783#define yyclearin (yychar = YYEMPTY) 784#define YYEMPTY (-2) 785#define YYEOF 0 786 787#define YYACCEPT goto yyacceptlab 788#define YYABORT goto yyabortlab 789#define YYERROR goto yyerrorlab 790 791 792/* Like YYERROR except do call yyerror. This remains here temporarily 793 to ease the transition to the new meaning of YYERROR, for GCC. 794 Once GCC version 2 has supplanted version 1, this can go. */ 795 796#define YYFAIL goto yyerrlab 797 798#define YYRECOVERING() (!!yyerrstatus) 799 800#define YYBACKUP(Token, Value) \ 801do \ 802 if (yychar == YYEMPTY && yylen == 1) \ 803 { \ 804 yychar = (Token); \ 805 yylval = (Value); \ 806 yytoken = YYTRANSLATE (yychar); \ 807 YYPOPSTACK (1); \ 808 goto yybackup; \ 809 } \ 810 else \ 811 { \ 812 yyerror (YY_("syntax error: cannot back up")); \ 813 YYERROR; \ 814 } \ 815while (YYID (0)) 816 817 818#define YYTERROR 1 819#define YYERRCODE 256 820 821 822/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. 823 If N is 0, then set CURRENT to the empty location which ends 824 the previous symbol: RHS[0] (always defined). */ 825 826#define YYRHSLOC(Rhs, K) ((Rhs)[K]) 827#ifndef YYLLOC_DEFAULT 828# define YYLLOC_DEFAULT(Current, Rhs, N) \ 829 do \ 830 if (YYID (N)) \ 831 { \ 832 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ 833 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ 834 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ 835 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ 836 } \ 837 else \ 838 { \ 839 (Current).first_line = (Current).last_line = \ 840 YYRHSLOC (Rhs, 0).last_line; \ 841 (Current).first_column = (Current).last_column = \ 842 YYRHSLOC (Rhs, 0).last_column; \ 843 } \ 844 while (YYID (0)) 845#endif 846 847 848/* YY_LOCATION_PRINT -- Print the location on the stream. 849 This macro was not mandated originally: define only if we know 850 we won't break user code: when these are the locations we know. */ 851 852#ifndef YY_LOCATION_PRINT 853# if YYLTYPE_IS_TRIVIAL 854# define YY_LOCATION_PRINT(File, Loc) \ 855 fprintf (File, "%d.%d-%d.%d", \ 856 (Loc).first_line, (Loc).first_column, \ 857 (Loc).last_line, (Loc).last_column) 858# else 859# define YY_LOCATION_PRINT(File, Loc) ((void) 0) 860# endif 861#endif 862 863 864/* YYLEX -- calling `yylex' with the right arguments. */ 865 866#ifdef YYLEX_PARAM 867# define YYLEX yylex (YYLEX_PARAM) 868#else 869# define YYLEX yylex () 870#endif 871 872/* Enable debugging if requested. */ 873#if YYDEBUG 874 875# ifndef YYFPRINTF 876# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ 877# define YYFPRINTF fprintf 878# endif 879 880# define YYDPRINTF(Args) \ 881do { \ 882 if (yydebug) \ 883 YYFPRINTF Args; \ 884} while (YYID (0)) 885 886# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ 887do { \ 888 if (yydebug) \ 889 { \ 890 YYFPRINTF (stderr, "%s ", Title); \ 891 yy_symbol_print (stderr, \ 892 Type, Value); \ 893 YYFPRINTF (stderr, "\n"); \ 894 } \ 895} while (YYID (0)) 896 897 898/*--------------------------------. 899| Print this symbol on YYOUTPUT. | 900`--------------------------------*/ 901 902/*ARGSUSED*/ 903#if (defined __STDC__ || defined __C99__FUNC__ \ 904 || defined __cplusplus || defined _MSC_VER) 905static void 906yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) 907#else 908static void 909yy_symbol_value_print (yyoutput, yytype, yyvaluep) 910 FILE *yyoutput; 911 int yytype; 912 YYSTYPE const * const yyvaluep; 913#endif 914{ 915 if (!yyvaluep) 916 return; 917# ifdef YYPRINT 918 if (yytype < YYNTOKENS) 919 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); 920# else 921 YYUSE (yyoutput); 922# endif 923 switch (yytype) 924 { 925 default: 926 break; 927 } 928} 929 930 931/*--------------------------------. 932| Print this symbol on YYOUTPUT. | 933`--------------------------------*/ 934 935#if (defined __STDC__ || defined __C99__FUNC__ \ 936 || defined __cplusplus || defined _MSC_VER) 937static void 938yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) 939#else 940static void 941yy_symbol_print (yyoutput, yytype, yyvaluep) 942 FILE *yyoutput; 943 int yytype; 944 YYSTYPE const * const yyvaluep; 945#endif 946{ 947 if (yytype < YYNTOKENS) 948 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); 949 else 950 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); 951 952 yy_symbol_value_print (yyoutput, yytype, yyvaluep); 953 YYFPRINTF (yyoutput, ")"); 954} 955 956/*------------------------------------------------------------------. 957| yy_stack_print -- Print the state stack from its BOTTOM up to its | 958| TOP (included). | 959`------------------------------------------------------------------*/ 960 961#if (defined __STDC__ || defined __C99__FUNC__ \ 962 || defined __cplusplus || defined _MSC_VER) 963static void 964yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) 965#else 966static void 967yy_stack_print (bottom, top) 968 yytype_int16 *bottom; 969 yytype_int16 *top; 970#endif 971{ 972 YYFPRINTF (stderr, "Stack now"); 973 for (; bottom <= top; ++bottom) 974 YYFPRINTF (stderr, " %d", *bottom); 975 YYFPRINTF (stderr, "\n"); 976} 977 978# define YY_STACK_PRINT(Bottom, Top) \ 979do { \ 980 if (yydebug) \ 981 yy_stack_print ((Bottom), (Top)); \ 982} while (YYID (0)) 983 984 985/*------------------------------------------------. 986| Report that the YYRULE is going to be reduced. | 987`------------------------------------------------*/ 988 989#if (defined __STDC__ || defined __C99__FUNC__ \ 990 || defined __cplusplus || defined _MSC_VER) 991static void 992yy_reduce_print (YYSTYPE *yyvsp, int yyrule) 993#else 994static void 995yy_reduce_print (yyvsp, yyrule) 996 YYSTYPE *yyvsp; 997 int yyrule; 998#endif 999{ 1000 int yynrhs = yyr2[yyrule]; 1001 int yyi; 1002 unsigned long int yylno = yyrline[yyrule]; 1003 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", 1004 yyrule - 1, yylno); 1005 /* The symbols being reduced. */ 1006 for (yyi = 0; yyi < yynrhs; yyi++) 1007 { 1008 fprintf (stderr, " $%d = ", yyi + 1); 1009 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], 1010 &(yyvsp[(yyi + 1) - (yynrhs)]) 1011 ); 1012 fprintf (stderr, "\n"); 1013 } 1014} 1015 1016# define YY_REDUCE_PRINT(Rule) \ 1017do { \ 1018 if (yydebug) \ 1019 yy_reduce_print (yyvsp, Rule); \ 1020} while (YYID (0)) 1021 1022/* Nonzero means print parse trace. It is left uninitialized so that 1023 multiple parsers can coexist. */ 1024int yydebug; 1025#else /* !YYDEBUG */ 1026# define YYDPRINTF(Args) 1027# define YY_SYMBOL_PRINT(Title, Type, Value, Location) 1028# define YY_STACK_PRINT(Bottom, Top) 1029# define YY_REDUCE_PRINT(Rule) 1030#endif /* !YYDEBUG */ 1031 1032 1033/* YYINITDEPTH -- initial size of the parser's stacks. */ 1034#ifndef YYINITDEPTH 1035# define YYINITDEPTH 200 1036#endif 1037 1038/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only 1039 if the built-in stack extension method is used). 1040 1041 Do not make this value too large; the results are undefined if 1042 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) 1043 evaluated with infinite-precision integer arithmetic. */ 1044 1045#ifndef YYMAXDEPTH 1046# define YYMAXDEPTH 10000 1047#endif 1048 1049 1050 1051#if YYERROR_VERBOSE 1052 1053# ifndef yystrlen 1054# if defined __GLIBC__ && defined _STRING_H 1055# define yystrlen strlen 1056# else 1057/* Return the length of YYSTR. */ 1058#if (defined __STDC__ || defined __C99__FUNC__ \ 1059 || defined __cplusplus || defined _MSC_VER) 1060static YYSIZE_T 1061yystrlen (const char *yystr) 1062#else 1063static YYSIZE_T 1064yystrlen (yystr) 1065 const char *yystr; 1066#endif 1067{ 1068 YYSIZE_T yylen; 1069 for (yylen = 0; yystr[yylen]; yylen++) 1070 continue; 1071 return yylen; 1072} 1073# endif 1074# endif 1075 1076# ifndef yystpcpy 1077# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE 1078# define yystpcpy stpcpy 1079# else 1080/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in 1081 YYDEST. */ 1082#if (defined __STDC__ || defined __C99__FUNC__ \ 1083 || defined __cplusplus || defined _MSC_VER) 1084static char * 1085yystpcpy (char *yydest, const char *yysrc) 1086#else 1087static char * 1088yystpcpy (yydest, yysrc) 1089 char *yydest; 1090 const char *yysrc; 1091#endif 1092{ 1093 char *yyd = yydest; 1094 const char *yys = yysrc; 1095 1096 while ((*yyd++ = *yys++) != '\0') 1097 continue; 1098 1099 return yyd - 1; 1100} 1101# endif 1102# endif 1103 1104# ifndef yytnamerr 1105/* Copy to YYRES the contents of YYSTR after stripping away unnecessary 1106 quotes and backslashes, so that it's suitable for yyerror. The 1107 heuristic is that double-quoting is unnecessary unless the string 1108 contains an apostrophe, a comma, or backslash (other than 1109 backslash-backslash). YYSTR is taken from yytname. If YYRES is 1110 null, do not copy; instead, return the length of what the result 1111 would have been. */ 1112static YYSIZE_T 1113yytnamerr (char *yyres, const char *yystr) 1114{ 1115 if (*yystr == '"') 1116 { 1117 YYSIZE_T yyn = 0; 1118 char const *yyp = yystr; 1119 1120 for (;;) 1121 switch (*++yyp) 1122 { 1123 case '\'': 1124 case ',': 1125 goto do_not_strip_quotes; 1126 1127 case '\\': 1128 if (*++yyp != '\\') 1129 goto do_not_strip_quotes; 1130 /* Fall through. */ 1131 default: 1132 if (yyres) 1133 yyres[yyn] = *yyp; 1134 yyn++; 1135 break; 1136 1137 case '"': 1138 if (yyres) 1139 yyres[yyn] = '\0'; 1140 return yyn; 1141 } 1142 do_not_strip_quotes: ; 1143 } 1144 1145 if (! yyres) 1146 return yystrlen (yystr); 1147 1148 return yystpcpy (yyres, yystr) - yyres; 1149} 1150# endif 1151 1152/* Copy into YYRESULT an error message about the unexpected token 1153 YYCHAR while in state YYSTATE. Return the number of bytes copied, 1154 including the terminating null byte. If YYRESULT is null, do not 1155 copy anything; just return the number of bytes that would be 1156 copied. As a special case, return 0 if an ordinary "syntax error" 1157 message will do. Return YYSIZE_MAXIMUM if overflow occurs during 1158 size calculation. */ 1159static YYSIZE_T 1160yysyntax_error (char *yyresult, int yystate, int yychar) 1161{ 1162 int yyn = yypact[yystate]; 1163 1164 if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) 1165 return 0; 1166 else 1167 { 1168 int yytype = YYTRANSLATE (yychar); 1169 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); 1170 YYSIZE_T yysize = yysize0; 1171 YYSIZE_T yysize1; 1172 int yysize_overflow = 0; 1173 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; 1174 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; 1175 int yyx; 1176 1177# if 0 1178 /* This is so xgettext sees the translatable formats that are 1179 constructed on the fly. */ 1180 YY_("syntax error, unexpected %s"); 1181 YY_("syntax error, unexpected %s, expecting %s"); 1182 YY_("syntax error, unexpected %s, expecting %s or %s"); 1183 YY_("syntax error, unexpected %s, expecting %s or %s or %s"); 1184 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); 1185# endif 1186 char *yyfmt; 1187 char const *yyf; 1188 static char const yyunexpected[] = "syntax error, unexpected %s"; 1189 static char const yyexpecting[] = ", expecting %s"; 1190 static char const yyor[] = " or %s"; 1191 char yyformat[sizeof yyunexpected 1192 + sizeof yyexpecting - 1 1193 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) 1194 * (sizeof yyor - 1))]; 1195 char const *yyprefix = yyexpecting; 1196 1197 /* Start YYX at -YYN if negative to avoid negative indexes in 1198 YYCHECK. */ 1199 int yyxbegin = yyn < 0 ? -yyn : 0; 1200 1201 /* Stay within bounds of both yycheck and yytname. */ 1202 int yychecklim = YYLAST - yyn + 1; 1203 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; 1204 int yycount = 1; 1205 1206 yyarg[0] = yytname[yytype]; 1207 yyfmt = yystpcpy (yyformat, yyunexpected); 1208 1209 for (yyx = yyxbegin; yyx < yyxend; ++yyx) 1210 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 1211 { 1212 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) 1213 { 1214 yycount = 1; 1215 yysize = yysize0; 1216 yyformat[sizeof yyunexpected - 1] = '\0'; 1217 break; 1218 } 1219 yyarg[yycount++] = yytname[yyx]; 1220 yysize1 = yysize + yytnamerr (0, yytname[yyx]); 1221 yysize_overflow |= (yysize1 < yysize); 1222 yysize = yysize1; 1223 yyfmt = yystpcpy (yyfmt, yyprefix); 1224 yyprefix = yyor; 1225 } 1226 1227 yyf = YY_(yyformat); 1228 yysize1 = yysize + yystrlen (yyf); 1229 yysize_overflow |= (yysize1 < yysize); 1230 yysize = yysize1; 1231 1232 if (yysize_overflow) 1233 return YYSIZE_MAXIMUM; 1234 1235 if (yyresult) 1236 { 1237 /* Avoid sprintf, as that infringes on the user's name space. 1238 Don't have undefined behavior even if the translation 1239 produced a string with the wrong number of "%s"s. */ 1240 char *yyp = yyresult; 1241 int yyi = 0; 1242 while ((*yyp = *yyf) != '\0') 1243 { 1244 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) 1245 { 1246 yyp += yytnamerr (yyp, yyarg[yyi++]); 1247 yyf += 2; 1248 } 1249 else 1250 { 1251 yyp++; 1252 yyf++; 1253 } 1254 } 1255 } 1256 return yysize; 1257 } 1258} 1259#endif /* YYERROR_VERBOSE */ 1260 1261 1262/*-----------------------------------------------. 1263| Release the memory associated to this symbol. | 1264`-----------------------------------------------*/ 1265 1266/*ARGSUSED*/ 1267#if (defined __STDC__ || defined __C99__FUNC__ \ 1268 || defined __cplusplus || defined _MSC_VER) 1269static void 1270yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) 1271#else 1272static void 1273yydestruct (yymsg, yytype, yyvaluep) 1274 const char *yymsg; 1275 int yytype; 1276 YYSTYPE *yyvaluep; 1277#endif 1278{ 1279 YYUSE (yyvaluep); 1280 1281 if (!yymsg) 1282 yymsg = "Deleting"; 1283 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); 1284 1285 switch (yytype) 1286 { 1287 1288 default: 1289 break; 1290 } 1291} 1292 1293 1294/* Prevent warnings from -Wmissing-prototypes. */ 1295 1296#ifdef YYPARSE_PARAM 1297#if defined __STDC__ || defined __cplusplus 1298int yyparse (void *YYPARSE_PARAM); 1299#else 1300int yyparse (); 1301#endif 1302#else /* ! YYPARSE_PARAM */ 1303#if defined __STDC__ || defined __cplusplus 1304int yyparse (void); 1305#else 1306int yyparse (); 1307#endif 1308#endif /* ! YYPARSE_PARAM */ 1309 1310 1311 1312/* The look-ahead symbol. */ 1313int yychar; 1314 1315/* The semantic value of the look-ahead symbol. */ 1316YYSTYPE yylval; 1317 1318/* Number of syntax errors so far. */ 1319int yynerrs; 1320 1321 1322 1323/*----------. 1324| yyparse. | 1325`----------*/ 1326 1327#ifdef YYPARSE_PARAM 1328#if (defined __STDC__ || defined __C99__FUNC__ \ 1329 || defined __cplusplus || defined _MSC_VER) 1330int 1331yyparse (void *YYPARSE_PARAM) 1332#else 1333int 1334yyparse (YYPARSE_PARAM) 1335 void *YYPARSE_PARAM; 1336#endif 1337#else /* ! YYPARSE_PARAM */ 1338#if (defined __STDC__ || defined __C99__FUNC__ \ 1339 || defined __cplusplus || defined _MSC_VER) 1340int 1341yyparse (void) 1342#else 1343int 1344yyparse () 1345 1346#endif 1347#endif 1348{ 1349 1350 int yystate; 1351 int yyn; 1352 int yyresult; 1353 /* Number of tokens to shift before error messages enabled. */ 1354 int yyerrstatus; 1355 /* Look-ahead token as an internal (translated) token number. */ 1356 int yytoken = 0; 1357#if YYERROR_VERBOSE 1358 /* Buffer for error messages, and its allocated size. */ 1359 char yymsgbuf[128]; 1360 char *yymsg = yymsgbuf; 1361 YYSIZE_T yymsg_alloc = sizeof yymsgbuf; 1362#endif 1363 1364 /* Three stacks and their tools: 1365 `yyss': related to states, 1366 `yyvs': related to semantic values, 1367 `yyls': related to locations. 1368 1369 Refer to the stacks thru separate pointers, to allow yyoverflow 1370 to reallocate them elsewhere. */ 1371 1372 /* The state stack. */ 1373 yytype_int16 yyssa[YYINITDEPTH]; 1374 yytype_int16 *yyss = yyssa; 1375 yytype_int16 *yyssp; 1376 1377 /* The semantic value stack. */ 1378 YYSTYPE yyvsa[YYINITDEPTH]; 1379 YYSTYPE *yyvs = yyvsa; 1380 YYSTYPE *yyvsp; 1381 1382 1383 1384#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) 1385 1386 YYSIZE_T yystacksize = YYINITDEPTH; 1387 1388 /* The variables used to return semantic value and location from the 1389 action routines. */ 1390 YYSTYPE yyval; 1391 1392 1393 /* The number of symbols on the RHS of the reduced rule. 1394 Keep to zero when no symbol should be popped. */ 1395 int yylen = 0; 1396 1397 YYDPRINTF ((stderr, "Starting parse\n")); 1398 1399 yystate = 0; 1400 yyerrstatus = 0; 1401 yynerrs = 0; 1402 yychar = YYEMPTY; /* Cause a token to be read. */ 1403 1404 /* Initialize stack pointers. 1405 Waste one element of value and location stack 1406 so that they stay on the same level as the state stack. 1407 The wasted elements are never initialized. */ 1408 1409 yyssp = yyss; 1410 yyvsp = yyvs; 1411 1412 goto yysetstate; 1413 1414/*------------------------------------------------------------. 1415| yynewstate -- Push a new state, which is found in yystate. | 1416`------------------------------------------------------------*/ 1417 yynewstate: 1418 /* In all cases, when you get here, the value and location stacks 1419 have just been pushed. So pushing a state here evens the stacks. */ 1420 yyssp++; 1421 1422 yysetstate: 1423 *yyssp = yystate; 1424 1425 if (yyss + yystacksize - 1 <= yyssp) 1426 { 1427 /* Get the current used size of the three stacks, in elements. */ 1428 YYSIZE_T yysize = yyssp - yyss + 1; 1429 1430#ifdef yyoverflow 1431 { 1432 /* Give user a chance to reallocate the stack. Use copies of 1433 these so that the &'s don't force the real ones into 1434 memory. */ 1435 YYSTYPE *yyvs1 = yyvs; 1436 yytype_int16 *yyss1 = yyss; 1437 1438 1439 /* Each stack pointer address is followed by the size of the 1440 data in use in that stack, in bytes. This used to be a 1441 conditional around just the two extra args, but that might 1442 be undefined if yyoverflow is a macro. */ 1443 yyoverflow (YY_("memory exhausted"), 1444 &yyss1, yysize * sizeof (*yyssp), 1445 &yyvs1, yysize * sizeof (*yyvsp), 1446 1447 &yystacksize); 1448 1449 yyss = yyss1; 1450 yyvs = yyvs1; 1451 } 1452#else /* no yyoverflow */ 1453# ifndef YYSTACK_RELOCATE 1454 goto yyexhaustedlab; 1455# else 1456 /* Extend the stack our own way. */ 1457 if (YYMAXDEPTH <= yystacksize) 1458 goto yyexhaustedlab; 1459 yystacksize *= 2; 1460 if (YYMAXDEPTH < yystacksize) 1461 yystacksize = YYMAXDEPTH; 1462 1463 { 1464 yytype_int16 *yyss1 = yyss; 1465 union yyalloc *yyptr = 1466 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 1467 if (! yyptr) 1468 goto yyexhaustedlab; 1469 YYSTACK_RELOCATE (yyss); 1470 YYSTACK_RELOCATE (yyvs); 1471 1472# undef YYSTACK_RELOCATE 1473 if (yyss1 != yyssa) 1474 YYSTACK_FREE (yyss1); 1475 } 1476# endif 1477#endif /* no yyoverflow */ 1478 1479 yyssp = yyss + yysize - 1; 1480 yyvsp = yyvs + yysize - 1; 1481 1482 1483 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 1484 (unsigned long int) yystacksize)); 1485 1486 if (yyss + yystacksize - 1 <= yyssp) 1487 YYABORT; 1488 } 1489 1490 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 1491 1492 goto yybackup; 1493 1494/*-----------. 1495| yybackup. | 1496`-----------*/ 1497yybackup: 1498 1499 /* Do appropriate processing given the current state. Read a 1500 look-ahead token if we need one and don't already have one. */ 1501 1502 /* First try to decide what to do without reference to look-ahead token. */ 1503 yyn = yypact[yystate]; 1504 if (yyn == YYPACT_NINF) 1505 goto yydefault; 1506 1507 /* Not known => get a look-ahead token if don't already have one. */ 1508 1509 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ 1510 if (yychar == YYEMPTY) 1511 { 1512 YYDPRINTF ((stderr, "Reading a token: ")); 1513 yychar = YYLEX; 1514 } 1515 1516 if (yychar <= YYEOF) 1517 { 1518 yychar = yytoken = YYEOF; 1519 YYDPRINTF ((stderr, "Now at end of input.\n")); 1520 } 1521 else 1522 { 1523 yytoken = YYTRANSLATE (yychar); 1524 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); 1525 } 1526 1527 /* If the proper action on seeing token YYTOKEN is to reduce or to 1528 detect an error, take that action. */ 1529 yyn += yytoken; 1530 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 1531 goto yydefault; 1532 yyn = yytable[yyn]; 1533 if (yyn <= 0) 1534 { 1535 if (yyn == 0 || yyn == YYTABLE_NINF) 1536 goto yyerrlab; 1537 yyn = -yyn; 1538 goto yyreduce; 1539 } 1540 1541 if (yyn == YYFINAL) 1542 YYACCEPT; 1543 1544 /* Count tokens shifted since error; after three, turn off error 1545 status. */ 1546 if (yyerrstatus) 1547 yyerrstatus--; 1548 1549 /* Shift the look-ahead token. */ 1550 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 1551 1552 /* Discard the shifted token unless it is eof. */ 1553 if (yychar != YYEOF) 1554 yychar = YYEMPTY; 1555 1556 yystate = yyn; 1557 *++yyvsp = yylval; 1558 1559 goto yynewstate; 1560 1561 1562/*-----------------------------------------------------------. 1563| yydefault -- do the default action for the current state. | 1564`-----------------------------------------------------------*/ 1565yydefault: 1566 yyn = yydefact[yystate]; 1567 if (yyn == 0) 1568 goto yyerrlab; 1569 goto yyreduce; 1570 1571 1572/*-----------------------------. 1573| yyreduce -- Do a reduction. | 1574`-----------------------------*/ 1575yyreduce: 1576 /* yyn is the number of a rule to reduce with. */ 1577 yylen = yyr2[yyn]; 1578 1579 /* If YYLEN is nonzero, implement the default value of the action: 1580 `$$ = $1'. 1581 1582 Otherwise, the following line sets YYVAL to garbage. 1583 This behavior is undocumented and Bison 1584 users should not rely upon it. Assigning to YYVAL 1585 unconditionally makes the parser a bit smaller, and it avoids a 1586 GCC warning that YYVAL may be used uninitialized. */ 1587 yyval = yyvsp[1-yylen]; 1588 1589 1590 YY_REDUCE_PRINT (yyn); 1591 switch (yyn) 1592 { 1593 case 3: 1594#line 145 "ldscript.y" 1595 { add_versions ((yyvsp[(2) - (2)].version)); } 1596 break; 1597 1598 case 6: 1599#line 153 "ldscript.y" 1600 { 1601 if (likely (ld_state.entry == NULL)) 1602 ld_state.entry = (yyvsp[(3) - (5)].str); 1603 } 1604 break; 1605 1606 case 7: 1607#line 158 "ldscript.y" 1608 { 1609 ld_new_searchdir ((yyvsp[(3) - (5)].str)); 1610 } 1611 break; 1612 1613 case 8: 1614#line 162 "ldscript.y" 1615 { 1616 if (likely (ld_state.pagesize == 0)) 1617 ld_state.pagesize = (yyvsp[(3) - (5)].num); 1618 } 1619 break; 1620 1621 case 9: 1622#line 167 "ldscript.y" 1623 { 1624 if (likely (ld_state.interp == NULL) 1625 && ld_state.file_type != dso_file_type) 1626 ld_state.interp = (yyvsp[(3) - (5)].str); 1627 } 1628 break; 1629 1630 case 10: 1631#line 173 "ldscript.y" 1632 { 1633 new_segment ((yyvsp[(2) - (5)].num), (yyvsp[(4) - (5)].output_rule)); 1634 } 1635 break; 1636 1637 case 11: 1638#line 177 "ldscript.y" 1639 { 1640 fputs_unlocked (gettext ("mode for segment invalid\n"), 1641 stderr); 1642 new_segment (0, (yyvsp[(4) - (5)].output_rule)); 1643 } 1644 break; 1645 1646 case 12: 1647#line 183 "ldscript.y" 1648 { 1649 /* First little optimization. If there is only one 1650 file in the group don't do anything. */ 1651 if ((yyvsp[(3) - (4)].filename_list) != (yyvsp[(3) - (4)].filename_list)->next) 1652 { 1653 (yyvsp[(3) - (4)].filename_list)->next->group_start = 1; 1654 (yyvsp[(3) - (4)].filename_list)->group_end = 1; 1655 } 1656 add_inputfiles ((yyvsp[(3) - (4)].filename_list)); 1657 } 1658 break; 1659 1660 case 13: 1661#line 194 "ldscript.y" 1662 { add_inputfiles ((yyvsp[(3) - (4)].filename_list)); } 1663 break; 1664 1665 case 14: 1666#line 196 "ldscript.y" 1667 { add_inputfiles (mark_as_needed ((yyvsp[(3) - (4)].filename_list))); } 1668 break; 1669 1670 case 15: 1671#line 198 "ldscript.y" 1672 { add_versions ((yyvsp[(3) - (4)].version)); } 1673 break; 1674 1675 case 16: 1676#line 200 "ldscript.y" 1677 { /* XXX TODO */ } 1678 break; 1679 1680 case 17: 1681#line 204 "ldscript.y" 1682 { 1683 (yyvsp[(2) - (2)].output_rule)->next = (yyvsp[(1) - (2)].output_rule)->next; 1684 (yyval.output_rule) = (yyvsp[(1) - (2)].output_rule)->next = (yyvsp[(2) - (2)].output_rule); 1685 } 1686 break; 1687 1688 case 18: 1689#line 209 "ldscript.y" 1690 { (yyval.output_rule) = (yyvsp[(1) - (1)].output_rule); } 1691 break; 1692 1693 case 19: 1694#line 213 "ldscript.y" 1695 { 1696 (yyval.output_rule) = new_output_rule (output_assignment); 1697 (yyval.output_rule)->val.assignment = (yyvsp[(1) - (2)].assignment); 1698 } 1699 break; 1700 1701 case 20: 1702#line 218 "ldscript.y" 1703 { 1704 (yyval.output_rule) = new_output_rule (output_section); 1705 (yyval.output_rule)->val.section.name = (yyvsp[(1) - (4)].str); 1706 (yyval.output_rule)->val.section.input = (yyvsp[(3) - (4)].input_rule)->next; 1707 if (ld_state.strip == strip_debug 1708 && ebl_debugscn_p (ld_state.ebl, (yyvsp[(1) - (4)].str))) 1709 (yyval.output_rule)->val.section.ignored = true; 1710 else 1711 (yyval.output_rule)->val.section.ignored = false; 1712 (yyvsp[(3) - (4)].input_rule)->next = NULL; 1713 } 1714 break; 1715 1716 case 21: 1717#line 230 "ldscript.y" 1718 { 1719 /* This is a short cut for "ID { *(ID) }". */ 1720 (yyval.output_rule) = new_output_rule (output_section); 1721 (yyval.output_rule)->val.section.name = (yyvsp[(1) - (2)].str); 1722 (yyval.output_rule)->val.section.input = new_input_rule (input_section); 1723 (yyval.output_rule)->val.section.input->next = NULL; 1724 (yyval.output_rule)->val.section.input->val.section = 1725 (struct filemask_section_name *) 1726 obstack_alloc (&ld_state.smem, 1727 sizeof (struct filemask_section_name)); 1728 (yyval.output_rule)->val.section.input->val.section->filemask = NULL; 1729 (yyval.output_rule)->val.section.input->val.section->excludemask = NULL; 1730 (yyval.output_rule)->val.section.input->val.section->section_name = 1731 new_input_section_name ((yyvsp[(1) - (2)].str), false); 1732 (yyval.output_rule)->val.section.input->val.section->keep_flag = false; 1733 if (ld_state.strip == strip_debug 1734 && ebl_debugscn_p (ld_state.ebl, (yyvsp[(1) - (2)].str))) 1735 (yyval.output_rule)->val.section.ignored = true; 1736 else 1737 (yyval.output_rule)->val.section.ignored = false; 1738 } 1739 break; 1740 1741 case 22: 1742#line 254 "ldscript.y" 1743 { (yyval.assignment) = new_assignment ((yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].expr), false); } 1744 break; 1745 1746 case 23: 1747#line 256 "ldscript.y" 1748 { (yyval.assignment) = new_assignment ((yyvsp[(3) - (6)].str), (yyvsp[(5) - (6)].expr), true); } 1749 break; 1750 1751 case 24: 1752#line 260 "ldscript.y" 1753 { 1754 (yyvsp[(2) - (2)].input_rule)->next = (yyvsp[(1) - (2)].input_rule)->next; 1755 (yyval.input_rule) = (yyvsp[(1) - (2)].input_rule)->next = (yyvsp[(2) - (2)].input_rule); 1756 } 1757 break; 1758 1759 case 25: 1760#line 265 "ldscript.y" 1761 { (yyval.input_rule) = (yyvsp[(1) - (1)].input_rule); } 1762 break; 1763 1764 case 26: 1765#line 269 "ldscript.y" 1766 { 1767 (yyval.input_rule) = new_input_rule (input_section); 1768 (yyval.input_rule)->val.section = (yyvsp[(1) - (1)].filemask_section_name); 1769 } 1770 break; 1771 1772 case 27: 1773#line 274 "ldscript.y" 1774 { 1775 (yyvsp[(3) - (4)].filemask_section_name)->keep_flag = true; 1776 1777 (yyval.input_rule) = new_input_rule (input_section); 1778 (yyval.input_rule)->val.section = (yyvsp[(3) - (4)].filemask_section_name); 1779 } 1780 break; 1781 1782 case 28: 1783#line 281 "ldscript.y" 1784 { 1785 (yyval.input_rule) = new_input_rule (input_assignment); 1786 (yyval.input_rule)->val.assignment = (yyvsp[(1) - (2)].assignment); 1787 } 1788 break; 1789 1790 case 29: 1791#line 288 "ldscript.y" 1792 { 1793 (yyval.filemask_section_name) = (struct filemask_section_name *) 1794 obstack_alloc (&ld_state.smem, sizeof (*(yyval.filemask_section_name))); 1795 (yyval.filemask_section_name)->filemask = (yyvsp[(1) - (5)].str); 1796 (yyval.filemask_section_name)->excludemask = (yyvsp[(3) - (5)].str); 1797 (yyval.filemask_section_name)->section_name = (yyvsp[(4) - (5)].sectionname); 1798 (yyval.filemask_section_name)->keep_flag = false; 1799 } 1800 break; 1801 1802 case 30: 1803#line 299 "ldscript.y" 1804 { (yyval.sectionname) = new_input_section_name ((yyvsp[(1) - (1)].str), false); } 1805 break; 1806 1807 case 31: 1808#line 301 "ldscript.y" 1809 { (yyval.sectionname) = new_input_section_name ((yyvsp[(3) - (4)].str), true); } 1810 break; 1811 1812 case 32: 1813#line 305 "ldscript.y" 1814 { (yyval.str) = (yyvsp[(3) - (4)].str); } 1815 break; 1816 1817 case 33: 1818#line 307 "ldscript.y" 1819 { (yyval.str) = NULL; } 1820 break; 1821 1822 case 34: 1823#line 311 "ldscript.y" 1824 { 1825 (yyval.expr) = new_expr (exp_align); 1826 (yyval.expr)->val.child = (yyvsp[(3) - (4)].expr); 1827 } 1828 break; 1829 1830 case 35: 1831#line 316 "ldscript.y" 1832 { (yyval.expr) = (yyvsp[(2) - (3)].expr); } 1833 break; 1834 1835 case 36: 1836#line 318 "ldscript.y" 1837 { 1838 (yyval.expr) = new_expr (exp_mult); 1839 (yyval.expr)->val.binary.left = (yyvsp[(1) - (3)].expr); 1840 (yyval.expr)->val.binary.right = (yyvsp[(3) - (3)].expr); 1841 } 1842 break; 1843 1844 case 37: 1845#line 324 "ldscript.y" 1846 { 1847 (yyval.expr) = new_expr ((yyvsp[(2) - (3)].op)); 1848 (yyval.expr)->val.binary.left = (yyvsp[(1) - (3)].expr); 1849 (yyval.expr)->val.binary.right = (yyvsp[(3) - (3)].expr); 1850 } 1851 break; 1852 1853 case 38: 1854#line 330 "ldscript.y" 1855 { 1856 (yyval.expr) = new_expr ((yyvsp[(2) - (3)].op)); 1857 (yyval.expr)->val.binary.left = (yyvsp[(1) - (3)].expr); 1858 (yyval.expr)->val.binary.right = (yyvsp[(3) - (3)].expr); 1859 } 1860 break; 1861 1862 case 39: 1863#line 336 "ldscript.y" 1864 { 1865 (yyval.expr) = new_expr (exp_and); 1866 (yyval.expr)->val.binary.left = (yyvsp[(1) - (3)].expr); 1867 (yyval.expr)->val.binary.right = (yyvsp[(3) - (3)].expr); 1868 } 1869 break; 1870 1871 case 40: 1872#line 342 "ldscript.y" 1873 { 1874 (yyval.expr) = new_expr (exp_or); 1875 (yyval.expr)->val.binary.left = (yyvsp[(1) - (3)].expr); 1876 (yyval.expr)->val.binary.right = (yyvsp[(3) - (3)].expr); 1877 } 1878 break; 1879 1880 case 41: 1881#line 348 "ldscript.y" 1882 { 1883 (yyval.expr) = new_expr (exp_num); 1884 (yyval.expr)->val.num = (yyvsp[(1) - (1)].num); 1885 } 1886 break; 1887 1888 case 42: 1889#line 353 "ldscript.y" 1890 { 1891 (yyval.expr) = new_expr (exp_id); 1892 (yyval.expr)->val.str = (yyvsp[(1) - (1)].str); 1893 } 1894 break; 1895 1896 case 43: 1897#line 358 "ldscript.y" 1898 { (yyval.expr) = new_expr (exp_sizeof_headers); } 1899 break; 1900 1901 case 44: 1902#line 360 "ldscript.y" 1903 { (yyval.expr) = new_expr (exp_pagesize); } 1904 break; 1905 1906 case 45: 1907#line 364 "ldscript.y" 1908 { 1909 (yyvsp[(3) - (3)].filename_list)->next = (yyvsp[(1) - (3)].filename_list)->next; 1910 (yyval.filename_list) = (yyvsp[(1) - (3)].filename_list)->next = (yyvsp[(3) - (3)].filename_list); 1911 } 1912 break; 1913 1914 case 46: 1915#line 369 "ldscript.y" 1916 { (yyval.filename_list) = (yyvsp[(1) - (1)].filename_list); } 1917 break; 1918 1919 case 49: 1920#line 377 "ldscript.y" 1921 { 1922 /* First little optimization. If there is only one 1923 file in the group don't do anything. */ 1924 if ((yyvsp[(3) - (4)].filename_list) != (yyvsp[(3) - (4)].filename_list)->next) 1925 { 1926 (yyvsp[(3) - (4)].filename_list)->next->group_start = 1; 1927 (yyvsp[(3) - (4)].filename_list)->group_end = 1; 1928 } 1929 (yyval.filename_list) = (yyvsp[(3) - (4)].filename_list); 1930 } 1931 break; 1932 1933 case 50: 1934#line 388 "ldscript.y" 1935 { (yyval.filename_list) = mark_as_needed ((yyvsp[(3) - (4)].filename_list)); } 1936 break; 1937 1938 case 51: 1939#line 390 "ldscript.y" 1940 { (yyval.filename_list) = new_filename_listelem ((yyvsp[(1) - (1)].str)); } 1941 break; 1942 1943 case 52: 1944#line 395 "ldscript.y" 1945 { 1946 (yyvsp[(2) - (2)].version)->next = (yyvsp[(1) - (2)].version)->next; 1947 (yyval.version) = (yyvsp[(1) - (2)].version)->next = (yyvsp[(2) - (2)].version); 1948 } 1949 break; 1950 1951 case 53: 1952#line 400 "ldscript.y" 1953 { (yyval.version) = (yyvsp[(1) - (1)].version); } 1954 break; 1955 1956 case 54: 1957#line 404 "ldscript.y" 1958 { 1959 (yyvsp[(2) - (4)].version)->versionname = ""; 1960 (yyvsp[(2) - (4)].version)->parentname = NULL; 1961 (yyval.version) = (yyvsp[(2) - (4)].version); 1962 } 1963 break; 1964 1965 case 55: 1966#line 410 "ldscript.y" 1967 { 1968 (yyvsp[(3) - (5)].version)->versionname = (yyvsp[(1) - (5)].str); 1969 (yyvsp[(3) - (5)].version)->parentname = NULL; 1970 (yyval.version) = (yyvsp[(3) - (5)].version); 1971 } 1972 break; 1973 1974 case 56: 1975#line 416 "ldscript.y" 1976 { 1977 (yyvsp[(3) - (6)].version)->versionname = (yyvsp[(1) - (6)].str); 1978 (yyvsp[(3) - (6)].version)->parentname = (yyvsp[(5) - (6)].str); 1979 (yyval.version) = (yyvsp[(3) - (6)].version); 1980 } 1981 break; 1982 1983 case 57: 1984#line 425 "ldscript.y" 1985 { (yyval.version) = merge_versions ((yyvsp[(1) - (2)].version), (yyvsp[(2) - (2)].version)); } 1986 break; 1987 1988 case 58: 1989#line 427 "ldscript.y" 1990 { (yyval.version) = (yyvsp[(1) - (1)].version); } 1991 break; 1992 1993 case 59: 1994#line 431 "ldscript.y" 1995 { (yyval.version) = new_version (NULL, (yyvsp[(2) - (2)].id_list)); } 1996 break; 1997 1998 case 60: 1999#line 433 "ldscript.y" 2000 { (yyval.version) = new_version ((yyvsp[(2) - (2)].id_list), NULL); } 2001 break; 2002 2003 case 61: 2004#line 438 "ldscript.y" 2005 { 2006 struct id_list *newp = new_id_listelem ((yyvsp[(2) - (3)].str)); 2007 newp->next = (yyvsp[(1) - (3)].id_list)->next; 2008 (yyval.id_list) = (yyvsp[(1) - (3)].id_list)->next = newp; 2009 } 2010 break; 2011 2012 case 62: 2013#line 444 "ldscript.y" 2014 { (yyval.id_list) = new_id_listelem ((yyvsp[(1) - (2)].str)); } 2015 break; 2016 2017 case 63: 2018#line 448 "ldscript.y" 2019 { (yyval.str) = (yyvsp[(1) - (1)].str); } 2020 break; 2021 2022 case 64: 2023#line 450 "ldscript.y" 2024 { (yyval.str) = (yyvsp[(1) - (1)].str); } 2025 break; 2026 2027 case 65: 2028#line 454 "ldscript.y" 2029 { (yyval.str) = (yyvsp[(1) - (1)].str); } 2030 break; 2031 2032 case 66: 2033#line 456 "ldscript.y" 2034 { (yyval.str) = NULL; } 2035 break; 2036 2037 2038/* Line 1267 of yacc.c. */ 2039#line 2040 "ldscript.c" 2040 default: break; 2041 } 2042 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); 2043 2044 YYPOPSTACK (yylen); 2045 yylen = 0; 2046 YY_STACK_PRINT (yyss, yyssp); 2047 2048 *++yyvsp = yyval; 2049 2050 2051 /* Now `shift' the result of the reduction. Determine what state 2052 that goes to, based on the state we popped back to and the rule 2053 number reduced by. */ 2054 2055 yyn = yyr1[yyn]; 2056 2057 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; 2058 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) 2059 yystate = yytable[yystate]; 2060 else 2061 yystate = yydefgoto[yyn - YYNTOKENS]; 2062 2063 goto yynewstate; 2064 2065 2066/*------------------------------------. 2067| yyerrlab -- here on detecting error | 2068`------------------------------------*/ 2069yyerrlab: 2070 /* If not already recovering from an error, report this error. */ 2071 if (!yyerrstatus) 2072 { 2073 ++yynerrs; 2074#if ! YYERROR_VERBOSE 2075 yyerror (YY_("syntax error")); 2076#else 2077 { 2078 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); 2079 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) 2080 { 2081 YYSIZE_T yyalloc = 2 * yysize; 2082 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) 2083 yyalloc = YYSTACK_ALLOC_MAXIMUM; 2084 if (yymsg != yymsgbuf) 2085 YYSTACK_FREE (yymsg); 2086 yymsg = (char *) YYSTACK_ALLOC (yyalloc); 2087 if (yymsg) 2088 yymsg_alloc = yyalloc; 2089 else 2090 { 2091 yymsg = yymsgbuf; 2092 yymsg_alloc = sizeof yymsgbuf; 2093 } 2094 } 2095 2096 if (0 < yysize && yysize <= yymsg_alloc) 2097 { 2098 (void) yysyntax_error (yymsg, yystate, yychar); 2099 yyerror (yymsg); 2100 } 2101 else 2102 { 2103 yyerror (YY_("syntax error")); 2104 if (yysize != 0) 2105 goto yyexhaustedlab; 2106 } 2107 } 2108#endif 2109 } 2110 2111 2112 2113 if (yyerrstatus == 3) 2114 { 2115 /* If just tried and failed to reuse look-ahead token after an 2116 error, discard it. */ 2117 2118 if (yychar <= YYEOF) 2119 { 2120 /* Return failure if at end of input. */ 2121 if (yychar == YYEOF) 2122 YYABORT; 2123 } 2124 else 2125 { 2126 yydestruct ("Error: discarding", 2127 yytoken, &yylval); 2128 yychar = YYEMPTY; 2129 } 2130 } 2131 2132 /* Else will try to reuse look-ahead token after shifting the error 2133 token. */ 2134 goto yyerrlab1; 2135 2136 2137/*---------------------------------------------------. 2138| yyerrorlab -- error raised explicitly by YYERROR. | 2139`---------------------------------------------------*/ 2140yyerrorlab: 2141 2142 /* Pacify compilers like GCC when the user code never invokes 2143 YYERROR and the label yyerrorlab therefore never appears in user 2144 code. */ 2145 if (/*CONSTCOND*/ 0) 2146 goto yyerrorlab; 2147 2148 /* Do not reclaim the symbols of the rule which action triggered 2149 this YYERROR. */ 2150 YYPOPSTACK (yylen); 2151 yylen = 0; 2152 YY_STACK_PRINT (yyss, yyssp); 2153 yystate = *yyssp; 2154 goto yyerrlab1; 2155 2156 2157/*-------------------------------------------------------------. 2158| yyerrlab1 -- common code for both syntax error and YYERROR. | 2159`-------------------------------------------------------------*/ 2160yyerrlab1: 2161 yyerrstatus = 3; /* Each real token shifted decrements this. */ 2162 2163 for (;;) 2164 { 2165 yyn = yypact[yystate]; 2166 if (yyn != YYPACT_NINF) 2167 { 2168 yyn += YYTERROR; 2169 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 2170 { 2171 yyn = yytable[yyn]; 2172 if (0 < yyn) 2173 break; 2174 } 2175 } 2176 2177 /* Pop the current state because it cannot handle the error token. */ 2178 if (yyssp == yyss) 2179 YYABORT; 2180 2181 2182 yydestruct ("Error: popping", 2183 yystos[yystate], yyvsp); 2184 YYPOPSTACK (1); 2185 yystate = *yyssp; 2186 YY_STACK_PRINT (yyss, yyssp); 2187 } 2188 2189 if (yyn == YYFINAL) 2190 YYACCEPT; 2191 2192 *++yyvsp = yylval; 2193 2194 2195 /* Shift the error token. */ 2196 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); 2197 2198 yystate = yyn; 2199 goto yynewstate; 2200 2201 2202/*-------------------------------------. 2203| yyacceptlab -- YYACCEPT comes here. | 2204`-------------------------------------*/ 2205yyacceptlab: 2206 yyresult = 0; 2207 goto yyreturn; 2208 2209/*-----------------------------------. 2210| yyabortlab -- YYABORT comes here. | 2211`-----------------------------------*/ 2212yyabortlab: 2213 yyresult = 1; 2214 goto yyreturn; 2215 2216#ifndef yyoverflow 2217/*-------------------------------------------------. 2218| yyexhaustedlab -- memory exhaustion comes here. | 2219`-------------------------------------------------*/ 2220yyexhaustedlab: 2221 yyerror (YY_("memory exhausted")); 2222 yyresult = 2; 2223 /* Fall through. */ 2224#endif 2225 2226yyreturn: 2227 if (yychar != YYEOF && yychar != YYEMPTY) 2228 yydestruct ("Cleanup: discarding lookahead", 2229 yytoken, &yylval); 2230 /* Do not reclaim the symbols of the rule which action triggered 2231 this YYABORT or YYACCEPT. */ 2232 YYPOPSTACK (yylen); 2233 YY_STACK_PRINT (yyss, yyssp); 2234 while (yyssp != yyss) 2235 { 2236 yydestruct ("Cleanup: popping", 2237 yystos[*yyssp], yyvsp); 2238 YYPOPSTACK (1); 2239 } 2240#ifndef yyoverflow 2241 if (yyss != yyssa) 2242 YYSTACK_FREE (yyss); 2243#endif 2244#if YYERROR_VERBOSE 2245 if (yymsg != yymsgbuf) 2246 YYSTACK_FREE (yymsg); 2247#endif 2248 /* Make sure YYID is used. */ 2249 return YYID (yyresult); 2250} 2251 2252 2253#line 459 "ldscript.y" 2254 2255 2256static void 2257yyerror (const char *s) 2258{ 2259 error (0, 0, (ld_scan_version_script 2260 ? gettext ("while reading version script '%s': %s at line %d") 2261 : gettext ("while reading linker script '%s': %s at line %d")), 2262 ldin_fname, gettext (s), ldlineno); 2263} 2264 2265 2266static struct expression * 2267new_expr (int tag) 2268{ 2269 struct expression *newp = (struct expression *) 2270 obstack_alloc (&ld_state.smem, sizeof (*newp)); 2271 2272 newp->tag = tag; 2273 return newp; 2274} 2275 2276 2277static struct input_section_name * 2278new_input_section_name (const char *name, bool sort_flag) 2279{ 2280 struct input_section_name *newp = (struct input_section_name *) 2281 obstack_alloc (&ld_state.smem, sizeof (*newp)); 2282 2283 newp->name = name; 2284 newp->sort_flag = sort_flag; 2285 return newp; 2286} 2287 2288 2289static struct input_rule * 2290new_input_rule (int tag) 2291{ 2292 struct input_rule *newp = (struct input_rule *) 2293 obstack_alloc (&ld_state.smem, sizeof (*newp)); 2294 2295 newp->tag = tag; 2296 newp->next = newp; 2297 return newp; 2298} 2299 2300 2301static struct output_rule * 2302new_output_rule (int tag) 2303{ 2304 struct output_rule *newp = (struct output_rule *) 2305 memset (obstack_alloc (&ld_state.smem, sizeof (*newp)), 2306 '\0', sizeof (*newp)); 2307 2308 newp->tag = tag; 2309 newp->next = newp; 2310 return newp; 2311} 2312 2313 2314static struct assignment * 2315new_assignment (const char *variable, struct expression *expression, 2316 bool provide_flag) 2317{ 2318 struct assignment *newp = (struct assignment *) 2319 obstack_alloc (&ld_state.smem, sizeof (*newp)); 2320 2321 newp->variable = variable; 2322 newp->expression = expression; 2323 newp->sym = NULL; 2324 newp->provide_flag = provide_flag; 2325 2326 /* Insert the symbol into a hash table. We will later have to matc*/ 2327 return newp; 2328} 2329 2330 2331static void 2332new_segment (int mode, struct output_rule *output_rule) 2333{ 2334 struct output_segment *newp; 2335 2336 newp 2337 = (struct output_segment *) obstack_alloc (&ld_state.smem, sizeof (*newp)); 2338 newp->mode = mode; 2339 newp->next = newp; 2340 2341 newp->output_rules = output_rule->next; 2342 output_rule->next = NULL; 2343 2344 /* Enqueue the output segment description. */ 2345 if (ld_state.output_segments == NULL) 2346 ld_state.output_segments = newp; 2347 else 2348 { 2349 newp->next = ld_state.output_segments->next; 2350 ld_state.output_segments = ld_state.output_segments->next = newp; 2351 } 2352 2353 /* If the output file should be stripped of all symbol set the flag 2354 in the structures of all output sections. */ 2355 if (mode == 0 && ld_state.strip == strip_all) 2356 { 2357 struct output_rule *runp; 2358 2359 for (runp = newp->output_rules; runp != NULL; runp = runp->next) 2360 if (runp->tag == output_section) 2361 runp->val.section.ignored = true; 2362 } 2363} 2364 2365 2366static struct filename_list * 2367new_filename_listelem (const char *string) 2368{ 2369 struct filename_list *newp; 2370 2371 /* We use calloc and not the obstack since this object can be freed soon. */ 2372 newp = (struct filename_list *) xcalloc (1, sizeof (*newp)); 2373 newp->name = string; 2374 newp->next = newp; 2375 return newp; 2376} 2377 2378 2379static struct filename_list * 2380mark_as_needed (struct filename_list *listp) 2381{ 2382 struct filename_list *runp = listp; 2383 do 2384 { 2385 runp->as_needed = true; 2386 runp = runp->next; 2387 } 2388 while (runp != listp); 2389 2390 return listp; 2391} 2392 2393 2394static void 2395add_inputfiles (struct filename_list *fnames) 2396{ 2397 assert (fnames != NULL); 2398 2399 if (ld_state.srcfiles == NULL) 2400 ld_state.srcfiles = fnames; 2401 else 2402 { 2403 struct filename_list *first = ld_state.srcfiles->next; 2404 2405 ld_state.srcfiles->next = fnames->next; 2406 fnames->next = first; 2407 ld_state.srcfiles->next = fnames; 2408 } 2409} 2410 2411 2412static _Bool 2413special_char_p (const char *str) 2414{ 2415 while (*str != '\0') 2416 { 2417 if (__builtin_expect (*str == '*', 0) 2418 || __builtin_expect (*str == '?', 0) 2419 || __builtin_expect (*str == '[', 0)) 2420 return true; 2421 2422 ++str; 2423 } 2424 2425 return false; 2426} 2427 2428 2429static struct id_list * 2430new_id_listelem (const char *str) 2431{ 2432 struct id_list *newp; 2433 2434 newp = (struct id_list *) obstack_alloc (&ld_state.smem, sizeof (*newp)); 2435 if (str == NULL) 2436 newp->u.id_type = id_all; 2437 else if (__builtin_expect (special_char_p (str), false)) 2438 newp->u.id_type = id_wild; 2439 else 2440 newp->u.id_type = id_str; 2441 newp->id = str; 2442 newp->next = newp; 2443 2444 return newp; 2445} 2446 2447 2448static struct version * 2449new_version (struct id_list *local, struct id_list *global) 2450{ 2451 struct version *newp; 2452 2453 newp = (struct version *) obstack_alloc (&ld_state.smem, sizeof (*newp)); 2454 newp->next = newp; 2455 newp->local_names = local; 2456 newp->global_names = global; 2457 newp->versionname = NULL; 2458 newp->parentname = NULL; 2459 2460 return newp; 2461} 2462 2463 2464static struct version * 2465merge_versions (struct version *one, struct version *two) 2466{ 2467 assert (two->local_names == NULL || two->global_names == NULL); 2468 2469 if (two->local_names != NULL) 2470 { 2471 if (one->local_names == NULL) 2472 one->local_names = two->local_names; 2473 else 2474 { 2475 two->local_names->next = one->local_names->next; 2476 one->local_names = one->local_names->next = two->local_names; 2477 } 2478 } 2479 else 2480 { 2481 if (one->global_names == NULL) 2482 one->global_names = two->global_names; 2483 else 2484 { 2485 two->global_names->next = one->global_names->next; 2486 one->global_names = one->global_names->next = two->global_names; 2487 } 2488 } 2489 2490 return one; 2491} 2492 2493 2494static void 2495add_id_list (const char *versionname, struct id_list *runp, _Bool local) 2496{ 2497 struct id_list *lastp = runp; 2498 2499 if (runp == NULL) 2500 /* Nothing to do. */ 2501 return; 2502 2503 /* Convert into a simple single-linked list. */ 2504 runp = runp->next; 2505 assert (runp != NULL); 2506 lastp->next = NULL; 2507 2508 do 2509 if (runp->u.id_type == id_str) 2510 { 2511 struct id_list *curp; 2512 struct id_list *defp; 2513 unsigned long int hval = elf_hash (runp->id); 2514 2515 curp = runp; 2516 runp = runp->next; 2517 2518 defp = ld_version_str_tab_find (&ld_state.version_str_tab, hval, curp); 2519 if (defp != NULL) 2520 { 2521 /* There is already a version definition for this symbol. */ 2522 while (strcmp (defp->u.s.versionname, versionname) != 0) 2523 { 2524 if (defp->next == NULL) 2525 { 2526 /* No version like this so far. */ 2527 defp->next = curp; 2528 curp->u.s.local = local; 2529 curp->u.s.versionname = versionname; 2530 curp->next = NULL; 2531 defp = NULL; 2532 break; 2533 } 2534 2535 defp = defp->next; 2536 } 2537 2538 if (defp != NULL && defp->u.s.local != local) 2539 error (EXIT_FAILURE, 0, versionname[0] == '\0' 2540 ? gettext ("\ 2541symbol '%s' in declared both local and global for unnamed version") 2542 : gettext ("\ 2543symbol '%s' in declared both local and global for version '%s'"), 2544 runp->id, versionname); 2545 } 2546 else 2547 { 2548 /* This is the first version definition for this symbol. */ 2549 ld_version_str_tab_insert (&ld_state.version_str_tab, hval, curp); 2550 2551 curp->u.s.local = local; 2552 curp->u.s.versionname = versionname; 2553 curp->next = NULL; 2554 } 2555 } 2556 else if (runp->u.id_type == id_all) 2557 { 2558 if (local) 2559 { 2560 if (ld_state.default_bind_global) 2561 error (EXIT_FAILURE, 0, 2562 gettext ("default visibility set as local and global")); 2563 ld_state.default_bind_local = true; 2564 } 2565 else 2566 { 2567 if (ld_state.default_bind_local) 2568 error (EXIT_FAILURE, 0, 2569 gettext ("default visibility set as local and global")); 2570 ld_state.default_bind_global = true; 2571 } 2572 2573 runp = runp->next; 2574 } 2575 else 2576 { 2577 assert (runp->u.id_type == id_wild); 2578 /* XXX TBI */ 2579 abort (); 2580 } 2581 while (runp != NULL); 2582} 2583 2584 2585static void 2586add_versions (struct version *versions) 2587{ 2588 struct version *lastp = versions; 2589 2590 if (versions == NULL) 2591 return; 2592 2593 /* Convert into a simple single-linked list. */ 2594 versions = versions->next; 2595 assert (versions != NULL); 2596 lastp->next = NULL; 2597 2598 do 2599 { 2600 struct version *oldp; 2601 2602 add_id_list (versions->versionname, versions->local_names, true); 2603 add_id_list (versions->versionname, versions->global_names, false); 2604 2605 oldp = versions; 2606 versions = versions->next; 2607 } 2608 while (versions != NULL); 2609} 2610 2611