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 (at) 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. */ 184 static void yyerror (const char *s); 185 186 /* Some helper functions we need to construct the data structures 187 describing information from the file. */ 188 static struct expression *new_expr (int tag); 189 static struct input_section_name *new_input_section_name (const char *name, 190 bool sort_flag); 191 static struct input_rule *new_input_rule (int tag); 192 static struct output_rule *new_output_rule (int tag); 193 static struct assignment *new_assignment (const char *variable, 194 struct expression *expression, 195 bool provide_flag); 196 static void new_segment (int mode, struct output_rule *output_rule); 197 static struct filename_list *new_filename_listelem (const char *string); 198 static void add_inputfiles (struct filename_list *fnames); 199 static struct id_list *new_id_listelem (const char *str); 200 static struct filename_list *mark_as_needed (struct filename_list *listp); 201 static struct version *new_version (struct id_list *local, 202 struct id_list *global); 203 static struct version *merge_versions (struct version *one, 204 struct version *two); 205 static void add_versions (struct version *versions); 206 207 extern 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 229 typedef 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 266 typedef YYTYPE_UINT8 yytype_uint8; 267 #else 268 typedef unsigned char yytype_uint8; 269 #endif 270 271 #ifdef YYTYPE_INT8 272 typedef YYTYPE_INT8 yytype_int8; 273 #elif (defined __STDC__ || defined __C99__FUNC__ \ 274 || defined __cplusplus || defined _MSC_VER) 275 typedef signed char yytype_int8; 276 #else 277 typedef short int yytype_int8; 278 #endif 279 280 #ifdef YYTYPE_UINT16 281 typedef YYTYPE_UINT16 yytype_uint16; 282 #else 283 typedef unsigned short int yytype_uint16; 284 #endif 285 286 #ifdef YYTYPE_INT16 287 typedef YYTYPE_INT16 yytype_int16; 288 #else 289 typedef 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) 333 static int 334 YYID (int i) 335 #else 336 static int 337 YYID (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) 401 void *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) 408 void 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. */ 420 union 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. */ 493 static 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. */ 529 static 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. */ 541 static 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. */ 571 static 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. */ 586 static 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. */ 606 static 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. */ 616 static 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. */ 628 static 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. */ 642 static 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]. */ 663 static 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 673 static 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]. */ 694 static 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 706 static 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 733 static 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. */ 762 static 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) \ 801 do \ 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 } \ 815 while (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) \ 881 do { \ 882 if (yydebug) \ 883 YYFPRINTF Args; \ 884 } while (YYID (0)) 885 886 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ 887 do { \ 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) 905 static void 906 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) 907 #else 908 static void 909 yy_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) 937 static void 938 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) 939 #else 940 static void 941 yy_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) 963 static void 964 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) 965 #else 966 static void 967 yy_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) \ 979 do { \ 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) 991 static void 992 yy_reduce_print (YYSTYPE *yyvsp, int yyrule) 993 #else 994 static void 995 yy_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) \ 1017 do { \ 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. */ 1024 int 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 1052 #if YYERROR_VERBOSE 1053 1054 # ifndef yystrlen 1055 # if defined __GLIBC__ && defined _STRING_H 1056 # define yystrlen strlen 1057 # else 1058 /* Return the length of YYSTR. */ 1059 #if (defined __STDC__ || defined __C99__FUNC__ \ 1060 || defined __cplusplus || defined _MSC_VER) 1061 static YYSIZE_T 1062 yystrlen (const char *yystr) 1063 #else 1064 static YYSIZE_T 1065 yystrlen (yystr) 1066 const char *yystr; 1067 #endif 1068 { 1069 YYSIZE_T yylen; 1070 for (yylen = 0; yystr[yylen]; yylen++) 1071 continue; 1072 return yylen; 1073 } 1074 # endif 1075 # endif 1076 1077 # ifndef yystpcpy 1078 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE 1079 # define yystpcpy stpcpy 1080 # else 1081 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in 1082 YYDEST. */ 1083 #if (defined __STDC__ || defined __C99__FUNC__ \ 1084 || defined __cplusplus || defined _MSC_VER) 1085 static char * 1086 yystpcpy (char *yydest, const char *yysrc) 1087 #else 1088 static char * 1089 yystpcpy (yydest, yysrc) 1090 char *yydest; 1091 const char *yysrc; 1092 #endif 1093 { 1094 char *yyd = yydest; 1095 const char *yys = yysrc; 1096 1097 while ((*yyd++ = *yys++) != '\0') 1098 continue; 1099 1100 return yyd - 1; 1101 } 1102 # endif 1103 # endif 1104 1105 # ifndef yytnamerr 1106 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary 1107 quotes and backslashes, so that it's suitable for yyerror. The 1108 heuristic is that double-quoting is unnecessary unless the string 1109 contains an apostrophe, a comma, or backslash (other than 1110 backslash-backslash). YYSTR is taken from yytname. If YYRES is 1111 null, do not copy; instead, return the length of what the result 1112 would have been. */ 1113 static YYSIZE_T 1114 yytnamerr (char *yyres, const char *yystr) 1115 { 1116 if (*yystr == '"') 1117 { 1118 YYSIZE_T yyn = 0; 1119 char const *yyp = yystr; 1120 1121 for (;;) 1122 switch (*++yyp) 1123 { 1124 case '\'': 1125 case ',': 1126 goto do_not_strip_quotes; 1127 1128 case '\\': 1129 if (*++yyp != '\\') 1130 goto do_not_strip_quotes; 1131 /* Fall through. */ 1132 default: 1133 if (yyres) 1134 yyres[yyn] = *yyp; 1135 yyn++; 1136 break; 1137 1138 case '"': 1139 if (yyres) 1140 yyres[yyn] = '\0'; 1141 return yyn; 1142 } 1143 do_not_strip_quotes: ; 1144 } 1145 1146 if (! yyres) 1147 return yystrlen (yystr); 1148 1149 return yystpcpy (yyres, yystr) - yyres; 1150 } 1151 # endif 1152 1153 /* Copy into YYRESULT an error message about the unexpected token 1154 YYCHAR while in state YYSTATE. Return the number of bytes copied, 1155 including the terminating null byte. If YYRESULT is null, do not 1156 copy anything; just return the number of bytes that would be 1157 copied. As a special case, return 0 if an ordinary "syntax error" 1158 message will do. Return YYSIZE_MAXIMUM if overflow occurs during 1159 size calculation. */ 1160 static YYSIZE_T 1161 yysyntax_error (char *yyresult, int yystate, int yychar) 1162 { 1163 int yyn = yypact[yystate]; 1164 1165 if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) 1166 return 0; 1167 else 1168 { 1169 int yytype = YYTRANSLATE (yychar); 1170 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); 1171 YYSIZE_T yysize = yysize0; 1172 YYSIZE_T yysize1; 1173 int yysize_overflow = 0; 1174 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; 1175 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; 1176 int yyx; 1177 1178 # if 0 1179 /* This is so xgettext sees the translatable formats that are 1180 constructed on the fly. */ 1181 YY_("syntax error, unexpected %s"); 1182 YY_("syntax error, unexpected %s, expecting %s"); 1183 YY_("syntax error, unexpected %s, expecting %s or %s"); 1184 YY_("syntax error, unexpected %s, expecting %s or %s or %s"); 1185 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); 1186 # endif 1187 char *yyfmt; 1188 char const *yyf; 1189 static char const yyunexpected[] = "syntax error, unexpected %s"; 1190 static char const yyexpecting[] = ", expecting %s"; 1191 static char const yyor[] = " or %s"; 1192 char yyformat[sizeof yyunexpected 1193 + sizeof yyexpecting - 1 1194 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) 1195 * (sizeof yyor - 1))]; 1196 char const *yyprefix = yyexpecting; 1197 1198 /* Start YYX at -YYN if negative to avoid negative indexes in 1199 YYCHECK. */ 1200 int yyxbegin = yyn < 0 ? -yyn : 0; 1201 1202 /* Stay within bounds of both yycheck and yytname. */ 1203 int yychecklim = YYLAST - yyn + 1; 1204 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; 1205 int yycount = 1; 1206 1207 yyarg[0] = yytname[yytype]; 1208 yyfmt = yystpcpy (yyformat, yyunexpected); 1209 1210 for (yyx = yyxbegin; yyx < yyxend; ++yyx) 1211 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 1212 { 1213 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) 1214 { 1215 yycount = 1; 1216 yysize = yysize0; 1217 yyformat[sizeof yyunexpected - 1] = '\0'; 1218 break; 1219 } 1220 yyarg[yycount++] = yytname[yyx]; 1221 yysize1 = yysize + yytnamerr (0, yytname[yyx]); 1222 yysize_overflow |= (yysize1 < yysize); 1223 yysize = yysize1; 1224 yyfmt = yystpcpy (yyfmt, yyprefix); 1225 yyprefix = yyor; 1226 } 1227 1228 yyf = YY_(yyformat); 1229 yysize1 = yysize + yystrlen (yyf); 1230 yysize_overflow |= (yysize1 < yysize); 1231 yysize = yysize1; 1232 1233 if (yysize_overflow) 1234 return YYSIZE_MAXIMUM; 1235 1236 if (yyresult) 1237 { 1238 /* Avoid sprintf, as that infringes on the user's name space. 1239 Don't have undefined behavior even if the translation 1240 produced a string with the wrong number of "%s"s. */ 1241 char *yyp = yyresult; 1242 int yyi = 0; 1243 while ((*yyp = *yyf) != '\0') 1244 { 1245 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) 1246 { 1247 yyp += yytnamerr (yyp, yyarg[yyi++]); 1248 yyf += 2; 1249 } 1250 else 1251 { 1252 yyp++; 1253 yyf++; 1254 } 1255 } 1256 } 1257 return yysize; 1258 } 1259 } 1260 #endif /* YYERROR_VERBOSE */ 1261 1262 1264 /*-----------------------------------------------. 1265 | Release the memory associated to this symbol. | 1266 `-----------------------------------------------*/ 1267 1268 /*ARGSUSED*/ 1269 #if (defined __STDC__ || defined __C99__FUNC__ \ 1270 || defined __cplusplus || defined _MSC_VER) 1271 static void 1272 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) 1273 #else 1274 static void 1275 yydestruct (yymsg, yytype, yyvaluep) 1276 const char *yymsg; 1277 int yytype; 1278 YYSTYPE *yyvaluep; 1279 #endif 1280 { 1281 YYUSE (yyvaluep); 1282 1283 if (!yymsg) 1284 yymsg = "Deleting"; 1285 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); 1286 1287 switch (yytype) 1288 { 1289 1290 default: 1291 break; 1292 } 1293 } 1294 1295 1297 /* Prevent warnings from -Wmissing-prototypes. */ 1298 1299 #ifdef YYPARSE_PARAM 1300 #if defined __STDC__ || defined __cplusplus 1301 int yyparse (void *YYPARSE_PARAM); 1302 #else 1303 int yyparse (); 1304 #endif 1305 #else /* ! YYPARSE_PARAM */ 1306 #if defined __STDC__ || defined __cplusplus 1307 int yyparse (void); 1308 #else 1309 int yyparse (); 1310 #endif 1311 #endif /* ! YYPARSE_PARAM */ 1312 1313 1314 1315 /* The look-ahead symbol. */ 1316 int yychar; 1317 1318 /* The semantic value of the look-ahead symbol. */ 1319 YYSTYPE yylval; 1320 1321 /* Number of syntax errors so far. */ 1322 int yynerrs; 1323 1324 1325 1326 /*----------. 1327 | yyparse. | 1328 `----------*/ 1329 1330 #ifdef YYPARSE_PARAM 1331 #if (defined __STDC__ || defined __C99__FUNC__ \ 1332 || defined __cplusplus || defined _MSC_VER) 1333 int 1334 yyparse (void *YYPARSE_PARAM) 1335 #else 1336 int 1337 yyparse (YYPARSE_PARAM) 1338 void *YYPARSE_PARAM; 1339 #endif 1340 #else /* ! YYPARSE_PARAM */ 1341 #if (defined __STDC__ || defined __C99__FUNC__ \ 1342 || defined __cplusplus || defined _MSC_VER) 1343 int 1344 yyparse (void) 1345 #else 1346 int 1347 yyparse () 1348 1349 #endif 1350 #endif 1351 { 1352 1353 int yystate; 1354 int yyn; 1355 int yyresult; 1356 /* Number of tokens to shift before error messages enabled. */ 1357 int yyerrstatus; 1358 /* Look-ahead token as an internal (translated) token number. */ 1359 int yytoken = 0; 1360 #if YYERROR_VERBOSE 1361 /* Buffer for error messages, and its allocated size. */ 1362 char yymsgbuf[128]; 1363 char *yymsg = yymsgbuf; 1364 YYSIZE_T yymsg_alloc = sizeof yymsgbuf; 1365 #endif 1366 1367 /* Three stacks and their tools: 1368 `yyss': related to states, 1369 `yyvs': related to semantic values, 1370 `yyls': related to locations. 1371 1372 Refer to the stacks thru separate pointers, to allow yyoverflow 1373 to reallocate them elsewhere. */ 1374 1375 /* The state stack. */ 1376 yytype_int16 yyssa[YYINITDEPTH]; 1377 yytype_int16 *yyss = yyssa; 1378 yytype_int16 *yyssp; 1379 1380 /* The semantic value stack. */ 1381 YYSTYPE yyvsa[YYINITDEPTH]; 1382 YYSTYPE *yyvs = yyvsa; 1383 YYSTYPE *yyvsp; 1384 1385 1386 1387 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) 1388 1389 YYSIZE_T yystacksize = YYINITDEPTH; 1390 1391 /* The variables used to return semantic value and location from the 1392 action routines. */ 1393 YYSTYPE yyval; 1394 1395 1396 /* The number of symbols on the RHS of the reduced rule. 1397 Keep to zero when no symbol should be popped. */ 1398 int yylen = 0; 1399 1400 YYDPRINTF ((stderr, "Starting parse\n")); 1401 1402 yystate = 0; 1403 yyerrstatus = 0; 1404 yynerrs = 0; 1405 yychar = YYEMPTY; /* Cause a token to be read. */ 1406 1407 /* Initialize stack pointers. 1408 Waste one element of value and location stack 1409 so that they stay on the same level as the state stack. 1410 The wasted elements are never initialized. */ 1411 1412 yyssp = yyss; 1413 yyvsp = yyvs; 1414 1415 goto yysetstate; 1416 1417 /*------------------------------------------------------------. 1418 | yynewstate -- Push a new state, which is found in yystate. | 1419 `------------------------------------------------------------*/ 1420 yynewstate: 1421 /* In all cases, when you get here, the value and location stacks 1422 have just been pushed. So pushing a state here evens the stacks. */ 1423 yyssp++; 1424 1425 yysetstate: 1426 *yyssp = yystate; 1427 1428 if (yyss + yystacksize - 1 <= yyssp) 1429 { 1430 /* Get the current used size of the three stacks, in elements. */ 1431 YYSIZE_T yysize = yyssp - yyss + 1; 1432 1433 #ifdef yyoverflow 1434 { 1435 /* Give user a chance to reallocate the stack. Use copies of 1436 these so that the &'s don't force the real ones into 1437 memory. */ 1438 YYSTYPE *yyvs1 = yyvs; 1439 yytype_int16 *yyss1 = yyss; 1440 1441 1442 /* Each stack pointer address is followed by the size of the 1443 data in use in that stack, in bytes. This used to be a 1444 conditional around just the two extra args, but that might 1445 be undefined if yyoverflow is a macro. */ 1446 yyoverflow (YY_("memory exhausted"), 1447 &yyss1, yysize * sizeof (*yyssp), 1448 &yyvs1, yysize * sizeof (*yyvsp), 1449 1450 &yystacksize); 1451 1452 yyss = yyss1; 1453 yyvs = yyvs1; 1454 } 1455 #else /* no yyoverflow */ 1456 # ifndef YYSTACK_RELOCATE 1457 goto yyexhaustedlab; 1458 # else 1459 /* Extend the stack our own way. */ 1460 if (YYMAXDEPTH <= yystacksize) 1461 goto yyexhaustedlab; 1462 yystacksize *= 2; 1463 if (YYMAXDEPTH < yystacksize) 1464 yystacksize = YYMAXDEPTH; 1465 1466 { 1467 yytype_int16 *yyss1 = yyss; 1468 union yyalloc *yyptr = 1469 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 1470 if (! yyptr) 1471 goto yyexhaustedlab; 1472 YYSTACK_RELOCATE (yyss); 1473 YYSTACK_RELOCATE (yyvs); 1474 1475 # undef YYSTACK_RELOCATE 1476 if (yyss1 != yyssa) 1477 YYSTACK_FREE (yyss1); 1478 } 1479 # endif 1480 #endif /* no yyoverflow */ 1481 1482 yyssp = yyss + yysize - 1; 1483 yyvsp = yyvs + yysize - 1; 1484 1485 1486 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 1487 (unsigned long int) yystacksize)); 1488 1489 if (yyss + yystacksize - 1 <= yyssp) 1490 YYABORT; 1491 } 1492 1493 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 1494 1495 goto yybackup; 1496 1497 /*-----------. 1498 | yybackup. | 1499 `-----------*/ 1500 yybackup: 1501 1502 /* Do appropriate processing given the current state. Read a 1503 look-ahead token if we need one and don't already have one. */ 1504 1505 /* First try to decide what to do without reference to look-ahead token. */ 1506 yyn = yypact[yystate]; 1507 if (yyn == YYPACT_NINF) 1508 goto yydefault; 1509 1510 /* Not known => get a look-ahead token if don't already have one. */ 1511 1512 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ 1513 if (yychar == YYEMPTY) 1514 { 1515 YYDPRINTF ((stderr, "Reading a token: ")); 1516 yychar = YYLEX; 1517 } 1518 1519 if (yychar <= YYEOF) 1520 { 1521 yychar = yytoken = YYEOF; 1522 YYDPRINTF ((stderr, "Now at end of input.\n")); 1523 } 1524 else 1525 { 1526 yytoken = YYTRANSLATE (yychar); 1527 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); 1528 } 1529 1530 /* If the proper action on seeing token YYTOKEN is to reduce or to 1531 detect an error, take that action. */ 1532 yyn += yytoken; 1533 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 1534 goto yydefault; 1535 yyn = yytable[yyn]; 1536 if (yyn <= 0) 1537 { 1538 if (yyn == 0 || yyn == YYTABLE_NINF) 1539 goto yyerrlab; 1540 yyn = -yyn; 1541 goto yyreduce; 1542 } 1543 1544 if (yyn == YYFINAL) 1545 YYACCEPT; 1546 1547 /* Count tokens shifted since error; after three, turn off error 1548 status. */ 1549 if (yyerrstatus) 1550 yyerrstatus--; 1551 1552 /* Shift the look-ahead token. */ 1553 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 1554 1555 /* Discard the shifted token unless it is eof. */ 1556 if (yychar != YYEOF) 1557 yychar = YYEMPTY; 1558 1559 yystate = yyn; 1560 *++yyvsp = yylval; 1561 1562 goto yynewstate; 1563 1564 1565 /*-----------------------------------------------------------. 1566 | yydefault -- do the default action for the current state. | 1567 `-----------------------------------------------------------*/ 1568 yydefault: 1569 yyn = yydefact[yystate]; 1570 if (yyn == 0) 1571 goto yyerrlab; 1572 goto yyreduce; 1573 1574 1575 /*-----------------------------. 1576 | yyreduce -- Do a reduction. | 1577 `-----------------------------*/ 1578 yyreduce: 1579 /* yyn is the number of a rule to reduce with. */ 1580 yylen = yyr2[yyn]; 1581 1582 /* If YYLEN is nonzero, implement the default value of the action: 1583 `$$ = $1'. 1584 1585 Otherwise, the following line sets YYVAL to garbage. 1586 This behavior is undocumented and Bison 1587 users should not rely upon it. Assigning to YYVAL 1588 unconditionally makes the parser a bit smaller, and it avoids a 1589 GCC warning that YYVAL may be used uninitialized. */ 1590 yyval = yyvsp[1-yylen]; 1591 1592 1593 YY_REDUCE_PRINT (yyn); 1594 switch (yyn) 1595 { 1596 case 3: 1597 #line 145 "ldscript.y" 1598 { add_versions ((yyvsp[(2) - (2)].version)); } 1599 break; 1600 1601 case 6: 1602 #line 153 "ldscript.y" 1603 { 1604 if (likely (ld_state.entry == NULL)) 1605 ld_state.entry = (yyvsp[(3) - (5)].str); 1606 } 1607 break; 1608 1609 case 7: 1610 #line 158 "ldscript.y" 1611 { 1612 ld_new_searchdir ((yyvsp[(3) - (5)].str)); 1613 } 1614 break; 1615 1616 case 8: 1617 #line 162 "ldscript.y" 1618 { 1619 if (likely (ld_state.pagesize == 0)) 1620 ld_state.pagesize = (yyvsp[(3) - (5)].num); 1621 } 1622 break; 1623 1624 case 9: 1625 #line 167 "ldscript.y" 1626 { 1627 if (likely (ld_state.interp == NULL) 1628 && ld_state.file_type != dso_file_type) 1629 ld_state.interp = (yyvsp[(3) - (5)].str); 1630 } 1631 break; 1632 1633 case 10: 1634 #line 173 "ldscript.y" 1635 { 1636 new_segment ((yyvsp[(2) - (5)].num), (yyvsp[(4) - (5)].output_rule)); 1637 } 1638 break; 1639 1640 case 11: 1641 #line 177 "ldscript.y" 1642 { 1643 fputs_unlocked (gettext ("mode for segment invalid\n"), 1644 stderr); 1645 new_segment (0, (yyvsp[(4) - (5)].output_rule)); 1646 } 1647 break; 1648 1649 case 12: 1650 #line 183 "ldscript.y" 1651 { 1652 /* First little optimization. If there is only one 1653 file in the group don't do anything. */ 1654 if ((yyvsp[(3) - (4)].filename_list) != (yyvsp[(3) - (4)].filename_list)->next) 1655 { 1656 (yyvsp[(3) - (4)].filename_list)->next->group_start = 1; 1657 (yyvsp[(3) - (4)].filename_list)->group_end = 1; 1658 } 1659 add_inputfiles ((yyvsp[(3) - (4)].filename_list)); 1660 } 1661 break; 1662 1663 case 13: 1664 #line 194 "ldscript.y" 1665 { add_inputfiles ((yyvsp[(3) - (4)].filename_list)); } 1666 break; 1667 1668 case 14: 1669 #line 196 "ldscript.y" 1670 { add_inputfiles (mark_as_needed ((yyvsp[(3) - (4)].filename_list))); } 1671 break; 1672 1673 case 15: 1674 #line 198 "ldscript.y" 1675 { add_versions ((yyvsp[(3) - (4)].version)); } 1676 break; 1677 1678 case 16: 1679 #line 200 "ldscript.y" 1680 { /* XXX TODO */ } 1681 break; 1682 1683 case 17: 1684 #line 204 "ldscript.y" 1685 { 1686 (yyvsp[(2) - (2)].output_rule)->next = (yyvsp[(1) - (2)].output_rule)->next; 1687 (yyval.output_rule) = (yyvsp[(1) - (2)].output_rule)->next = (yyvsp[(2) - (2)].output_rule); 1688 } 1689 break; 1690 1691 case 18: 1692 #line 209 "ldscript.y" 1693 { (yyval.output_rule) = (yyvsp[(1) - (1)].output_rule); } 1694 break; 1695 1696 case 19: 1697 #line 213 "ldscript.y" 1698 { 1699 (yyval.output_rule) = new_output_rule (output_assignment); 1700 (yyval.output_rule)->val.assignment = (yyvsp[(1) - (2)].assignment); 1701 } 1702 break; 1703 1704 case 20: 1705 #line 218 "ldscript.y" 1706 { 1707 (yyval.output_rule) = new_output_rule (output_section); 1708 (yyval.output_rule)->val.section.name = (yyvsp[(1) - (4)].str); 1709 (yyval.output_rule)->val.section.input = (yyvsp[(3) - (4)].input_rule)->next; 1710 if (ld_state.strip == strip_debug 1711 && ebl_debugscn_p (ld_state.ebl, (yyvsp[(1) - (4)].str))) 1712 (yyval.output_rule)->val.section.ignored = true; 1713 else 1714 (yyval.output_rule)->val.section.ignored = false; 1715 (yyvsp[(3) - (4)].input_rule)->next = NULL; 1716 } 1717 break; 1718 1719 case 21: 1720 #line 230 "ldscript.y" 1721 { 1722 /* This is a short cut for "ID { *(ID) }". */ 1723 (yyval.output_rule) = new_output_rule (output_section); 1724 (yyval.output_rule)->val.section.name = (yyvsp[(1) - (2)].str); 1725 (yyval.output_rule)->val.section.input = new_input_rule (input_section); 1726 (yyval.output_rule)->val.section.input->next = NULL; 1727 (yyval.output_rule)->val.section.input->val.section = 1728 (struct filemask_section_name *) 1729 obstack_alloc (&ld_state.smem, 1730 sizeof (struct filemask_section_name)); 1731 (yyval.output_rule)->val.section.input->val.section->filemask = NULL; 1732 (yyval.output_rule)->val.section.input->val.section->excludemask = NULL; 1733 (yyval.output_rule)->val.section.input->val.section->section_name = 1734 new_input_section_name ((yyvsp[(1) - (2)].str), false); 1735 (yyval.output_rule)->val.section.input->val.section->keep_flag = false; 1736 if (ld_state.strip == strip_debug 1737 && ebl_debugscn_p (ld_state.ebl, (yyvsp[(1) - (2)].str))) 1738 (yyval.output_rule)->val.section.ignored = true; 1739 else 1740 (yyval.output_rule)->val.section.ignored = false; 1741 } 1742 break; 1743 1744 case 22: 1745 #line 254 "ldscript.y" 1746 { (yyval.assignment) = new_assignment ((yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].expr), false); } 1747 break; 1748 1749 case 23: 1750 #line 256 "ldscript.y" 1751 { (yyval.assignment) = new_assignment ((yyvsp[(3) - (6)].str), (yyvsp[(5) - (6)].expr), true); } 1752 break; 1753 1754 case 24: 1755 #line 260 "ldscript.y" 1756 { 1757 (yyvsp[(2) - (2)].input_rule)->next = (yyvsp[(1) - (2)].input_rule)->next; 1758 (yyval.input_rule) = (yyvsp[(1) - (2)].input_rule)->next = (yyvsp[(2) - (2)].input_rule); 1759 } 1760 break; 1761 1762 case 25: 1763 #line 265 "ldscript.y" 1764 { (yyval.input_rule) = (yyvsp[(1) - (1)].input_rule); } 1765 break; 1766 1767 case 26: 1768 #line 269 "ldscript.y" 1769 { 1770 (yyval.input_rule) = new_input_rule (input_section); 1771 (yyval.input_rule)->val.section = (yyvsp[(1) - (1)].filemask_section_name); 1772 } 1773 break; 1774 1775 case 27: 1776 #line 274 "ldscript.y" 1777 { 1778 (yyvsp[(3) - (4)].filemask_section_name)->keep_flag = true; 1779 1780 (yyval.input_rule) = new_input_rule (input_section); 1781 (yyval.input_rule)->val.section = (yyvsp[(3) - (4)].filemask_section_name); 1782 } 1783 break; 1784 1785 case 28: 1786 #line 281 "ldscript.y" 1787 { 1788 (yyval.input_rule) = new_input_rule (input_assignment); 1789 (yyval.input_rule)->val.assignment = (yyvsp[(1) - (2)].assignment); 1790 } 1791 break; 1792 1793 case 29: 1794 #line 288 "ldscript.y" 1795 { 1796 (yyval.filemask_section_name) = (struct filemask_section_name *) 1797 obstack_alloc (&ld_state.smem, sizeof (*(yyval.filemask_section_name))); 1798 (yyval.filemask_section_name)->filemask = (yyvsp[(1) - (5)].str); 1799 (yyval.filemask_section_name)->excludemask = (yyvsp[(3) - (5)].str); 1800 (yyval.filemask_section_name)->section_name = (yyvsp[(4) - (5)].sectionname); 1801 (yyval.filemask_section_name)->keep_flag = false; 1802 } 1803 break; 1804 1805 case 30: 1806 #line 299 "ldscript.y" 1807 { (yyval.sectionname) = new_input_section_name ((yyvsp[(1) - (1)].str), false); } 1808 break; 1809 1810 case 31: 1811 #line 301 "ldscript.y" 1812 { (yyval.sectionname) = new_input_section_name ((yyvsp[(3) - (4)].str), true); } 1813 break; 1814 1815 case 32: 1816 #line 305 "ldscript.y" 1817 { (yyval.str) = (yyvsp[(3) - (4)].str); } 1818 break; 1819 1820 case 33: 1821 #line 307 "ldscript.y" 1822 { (yyval.str) = NULL; } 1823 break; 1824 1825 case 34: 1826 #line 311 "ldscript.y" 1827 { 1828 (yyval.expr) = new_expr (exp_align); 1829 (yyval.expr)->val.child = (yyvsp[(3) - (4)].expr); 1830 } 1831 break; 1832 1833 case 35: 1834 #line 316 "ldscript.y" 1835 { (yyval.expr) = (yyvsp[(2) - (3)].expr); } 1836 break; 1837 1838 case 36: 1839 #line 318 "ldscript.y" 1840 { 1841 (yyval.expr) = new_expr (exp_mult); 1842 (yyval.expr)->val.binary.left = (yyvsp[(1) - (3)].expr); 1843 (yyval.expr)->val.binary.right = (yyvsp[(3) - (3)].expr); 1844 } 1845 break; 1846 1847 case 37: 1848 #line 324 "ldscript.y" 1849 { 1850 (yyval.expr) = new_expr ((yyvsp[(2) - (3)].op)); 1851 (yyval.expr)->val.binary.left = (yyvsp[(1) - (3)].expr); 1852 (yyval.expr)->val.binary.right = (yyvsp[(3) - (3)].expr); 1853 } 1854 break; 1855 1856 case 38: 1857 #line 330 "ldscript.y" 1858 { 1859 (yyval.expr) = new_expr ((yyvsp[(2) - (3)].op)); 1860 (yyval.expr)->val.binary.left = (yyvsp[(1) - (3)].expr); 1861 (yyval.expr)->val.binary.right = (yyvsp[(3) - (3)].expr); 1862 } 1863 break; 1864 1865 case 39: 1866 #line 336 "ldscript.y" 1867 { 1868 (yyval.expr) = new_expr (exp_and); 1869 (yyval.expr)->val.binary.left = (yyvsp[(1) - (3)].expr); 1870 (yyval.expr)->val.binary.right = (yyvsp[(3) - (3)].expr); 1871 } 1872 break; 1873 1874 case 40: 1875 #line 342 "ldscript.y" 1876 { 1877 (yyval.expr) = new_expr (exp_or); 1878 (yyval.expr)->val.binary.left = (yyvsp[(1) - (3)].expr); 1879 (yyval.expr)->val.binary.right = (yyvsp[(3) - (3)].expr); 1880 } 1881 break; 1882 1883 case 41: 1884 #line 348 "ldscript.y" 1885 { 1886 (yyval.expr) = new_expr (exp_num); 1887 (yyval.expr)->val.num = (yyvsp[(1) - (1)].num); 1888 } 1889 break; 1890 1891 case 42: 1892 #line 353 "ldscript.y" 1893 { 1894 (yyval.expr) = new_expr (exp_id); 1895 (yyval.expr)->val.str = (yyvsp[(1) - (1)].str); 1896 } 1897 break; 1898 1899 case 43: 1900 #line 358 "ldscript.y" 1901 { (yyval.expr) = new_expr (exp_sizeof_headers); } 1902 break; 1903 1904 case 44: 1905 #line 360 "ldscript.y" 1906 { (yyval.expr) = new_expr (exp_pagesize); } 1907 break; 1908 1909 case 45: 1910 #line 364 "ldscript.y" 1911 { 1912 (yyvsp[(3) - (3)].filename_list)->next = (yyvsp[(1) - (3)].filename_list)->next; 1913 (yyval.filename_list) = (yyvsp[(1) - (3)].filename_list)->next = (yyvsp[(3) - (3)].filename_list); 1914 } 1915 break; 1916 1917 case 46: 1918 #line 369 "ldscript.y" 1919 { (yyval.filename_list) = (yyvsp[(1) - (1)].filename_list); } 1920 break; 1921 1922 case 49: 1923 #line 377 "ldscript.y" 1924 { 1925 /* First little optimization. If there is only one 1926 file in the group don't do anything. */ 1927 if ((yyvsp[(3) - (4)].filename_list) != (yyvsp[(3) - (4)].filename_list)->next) 1928 { 1929 (yyvsp[(3) - (4)].filename_list)->next->group_start = 1; 1930 (yyvsp[(3) - (4)].filename_list)->group_end = 1; 1931 } 1932 (yyval.filename_list) = (yyvsp[(3) - (4)].filename_list); 1933 } 1934 break; 1935 1936 case 50: 1937 #line 388 "ldscript.y" 1938 { (yyval.filename_list) = mark_as_needed ((yyvsp[(3) - (4)].filename_list)); } 1939 break; 1940 1941 case 51: 1942 #line 390 "ldscript.y" 1943 { (yyval.filename_list) = new_filename_listelem ((yyvsp[(1) - (1)].str)); } 1944 break; 1945 1946 case 52: 1947 #line 395 "ldscript.y" 1948 { 1949 (yyvsp[(2) - (2)].version)->next = (yyvsp[(1) - (2)].version)->next; 1950 (yyval.version) = (yyvsp[(1) - (2)].version)->next = (yyvsp[(2) - (2)].version); 1951 } 1952 break; 1953 1954 case 53: 1955 #line 400 "ldscript.y" 1956 { (yyval.version) = (yyvsp[(1) - (1)].version); } 1957 break; 1958 1959 case 54: 1960 #line 404 "ldscript.y" 1961 { 1962 (yyvsp[(2) - (4)].version)->versionname = ""; 1963 (yyvsp[(2) - (4)].version)->parentname = NULL; 1964 (yyval.version) = (yyvsp[(2) - (4)].version); 1965 } 1966 break; 1967 1968 case 55: 1969 #line 410 "ldscript.y" 1970 { 1971 (yyvsp[(3) - (5)].version)->versionname = (yyvsp[(1) - (5)].str); 1972 (yyvsp[(3) - (5)].version)->parentname = NULL; 1973 (yyval.version) = (yyvsp[(3) - (5)].version); 1974 } 1975 break; 1976 1977 case 56: 1978 #line 416 "ldscript.y" 1979 { 1980 (yyvsp[(3) - (6)].version)->versionname = (yyvsp[(1) - (6)].str); 1981 (yyvsp[(3) - (6)].version)->parentname = (yyvsp[(5) - (6)].str); 1982 (yyval.version) = (yyvsp[(3) - (6)].version); 1983 } 1984 break; 1985 1986 case 57: 1987 #line 425 "ldscript.y" 1988 { (yyval.version) = merge_versions ((yyvsp[(1) - (2)].version), (yyvsp[(2) - (2)].version)); } 1989 break; 1990 1991 case 58: 1992 #line 427 "ldscript.y" 1993 { (yyval.version) = (yyvsp[(1) - (1)].version); } 1994 break; 1995 1996 case 59: 1997 #line 431 "ldscript.y" 1998 { (yyval.version) = new_version (NULL, (yyvsp[(2) - (2)].id_list)); } 1999 break; 2000 2001 case 60: 2002 #line 433 "ldscript.y" 2003 { (yyval.version) = new_version ((yyvsp[(2) - (2)].id_list), NULL); } 2004 break; 2005 2006 case 61: 2007 #line 438 "ldscript.y" 2008 { 2009 struct id_list *newp = new_id_listelem ((yyvsp[(2) - (3)].str)); 2010 newp->next = (yyvsp[(1) - (3)].id_list)->next; 2011 (yyval.id_list) = (yyvsp[(1) - (3)].id_list)->next = newp; 2012 } 2013 break; 2014 2015 case 62: 2016 #line 444 "ldscript.y" 2017 { (yyval.id_list) = new_id_listelem ((yyvsp[(1) - (2)].str)); } 2018 break; 2019 2020 case 63: 2021 #line 448 "ldscript.y" 2022 { (yyval.str) = (yyvsp[(1) - (1)].str); } 2023 break; 2024 2025 case 64: 2026 #line 450 "ldscript.y" 2027 { (yyval.str) = (yyvsp[(1) - (1)].str); } 2028 break; 2029 2030 case 65: 2031 #line 454 "ldscript.y" 2032 { (yyval.str) = (yyvsp[(1) - (1)].str); } 2033 break; 2034 2035 case 66: 2036 #line 456 "ldscript.y" 2037 { (yyval.str) = NULL; } 2038 break; 2039 2040 2041 /* Line 1267 of yacc.c. */ 2042 #line 2040 "ldscript.c" 2043 default: break; 2044 } 2045 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); 2046 2047 YYPOPSTACK (yylen); 2048 yylen = 0; 2049 YY_STACK_PRINT (yyss, yyssp); 2050 2051 *++yyvsp = yyval; 2052 2053 2054 /* Now `shift' the result of the reduction. Determine what state 2055 that goes to, based on the state we popped back to and the rule 2056 number reduced by. */ 2057 2058 yyn = yyr1[yyn]; 2059 2060 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; 2061 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) 2062 yystate = yytable[yystate]; 2063 else 2064 yystate = yydefgoto[yyn - YYNTOKENS]; 2065 2066 goto yynewstate; 2067 2068 2069 /*------------------------------------. 2070 | yyerrlab -- here on detecting error | 2071 `------------------------------------*/ 2072 yyerrlab: 2073 /* If not already recovering from an error, report this error. */ 2074 if (!yyerrstatus) 2075 { 2076 ++yynerrs; 2077 #if ! YYERROR_VERBOSE 2078 yyerror (YY_("syntax error")); 2079 #else 2080 { 2081 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); 2082 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) 2083 { 2084 YYSIZE_T yyalloc = 2 * yysize; 2085 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) 2086 yyalloc = YYSTACK_ALLOC_MAXIMUM; 2087 if (yymsg != yymsgbuf) 2088 YYSTACK_FREE (yymsg); 2089 yymsg = (char *) YYSTACK_ALLOC (yyalloc); 2090 if (yymsg) 2091 yymsg_alloc = yyalloc; 2092 else 2093 { 2094 yymsg = yymsgbuf; 2095 yymsg_alloc = sizeof yymsgbuf; 2096 } 2097 } 2098 2099 if (0 < yysize && yysize <= yymsg_alloc) 2100 { 2101 (void) yysyntax_error (yymsg, yystate, yychar); 2102 yyerror (yymsg); 2103 } 2104 else 2105 { 2106 yyerror (YY_("syntax error")); 2107 if (yysize != 0) 2108 goto yyexhaustedlab; 2109 } 2110 } 2111 #endif 2112 } 2113 2114 2115 2116 if (yyerrstatus == 3) 2117 { 2118 /* If just tried and failed to reuse look-ahead token after an 2119 error, discard it. */ 2120 2121 if (yychar <= YYEOF) 2122 { 2123 /* Return failure if at end of input. */ 2124 if (yychar == YYEOF) 2125 YYABORT; 2126 } 2127 else 2128 { 2129 yydestruct ("Error: discarding", 2130 yytoken, &yylval); 2131 yychar = YYEMPTY; 2132 } 2133 } 2134 2135 /* Else will try to reuse look-ahead token after shifting the error 2136 token. */ 2137 goto yyerrlab1; 2138 2139 2140 /*---------------------------------------------------. 2141 | yyerrorlab -- error raised explicitly by YYERROR. | 2142 `---------------------------------------------------*/ 2143 yyerrorlab: 2144 2145 /* Pacify compilers like GCC when the user code never invokes 2146 YYERROR and the label yyerrorlab therefore never appears in user 2147 code. */ 2148 if (/*CONSTCOND*/ 0) 2149 goto yyerrorlab; 2150 2151 /* Do not reclaim the symbols of the rule which action triggered 2152 this YYERROR. */ 2153 YYPOPSTACK (yylen); 2154 yylen = 0; 2155 YY_STACK_PRINT (yyss, yyssp); 2156 yystate = *yyssp; 2157 goto yyerrlab1; 2158 2159 2160 /*-------------------------------------------------------------. 2161 | yyerrlab1 -- common code for both syntax error and YYERROR. | 2162 `-------------------------------------------------------------*/ 2163 yyerrlab1: 2164 yyerrstatus = 3; /* Each real token shifted decrements this. */ 2165 2166 for (;;) 2167 { 2168 yyn = yypact[yystate]; 2169 if (yyn != YYPACT_NINF) 2170 { 2171 yyn += YYTERROR; 2172 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 2173 { 2174 yyn = yytable[yyn]; 2175 if (0 < yyn) 2176 break; 2177 } 2178 } 2179 2180 /* Pop the current state because it cannot handle the error token. */ 2181 if (yyssp == yyss) 2182 YYABORT; 2183 2184 2185 yydestruct ("Error: popping", 2186 yystos[yystate], yyvsp); 2187 YYPOPSTACK (1); 2188 yystate = *yyssp; 2189 YY_STACK_PRINT (yyss, yyssp); 2190 } 2191 2192 if (yyn == YYFINAL) 2193 YYACCEPT; 2194 2195 *++yyvsp = yylval; 2196 2197 2198 /* Shift the error token. */ 2199 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); 2200 2201 yystate = yyn; 2202 goto yynewstate; 2203 2204 2205 /*-------------------------------------. 2206 | yyacceptlab -- YYACCEPT comes here. | 2207 `-------------------------------------*/ 2208 yyacceptlab: 2209 yyresult = 0; 2210 goto yyreturn; 2211 2212 /*-----------------------------------. 2213 | yyabortlab -- YYABORT comes here. | 2214 `-----------------------------------*/ 2215 yyabortlab: 2216 yyresult = 1; 2217 goto yyreturn; 2218 2219 #ifndef yyoverflow 2220 /*-------------------------------------------------. 2221 | yyexhaustedlab -- memory exhaustion comes here. | 2222 `-------------------------------------------------*/ 2223 yyexhaustedlab: 2224 yyerror (YY_("memory exhausted")); 2225 yyresult = 2; 2226 /* Fall through. */ 2227 #endif 2228 2229 yyreturn: 2230 if (yychar != YYEOF && yychar != YYEMPTY) 2231 yydestruct ("Cleanup: discarding lookahead", 2232 yytoken, &yylval); 2233 /* Do not reclaim the symbols of the rule which action triggered 2234 this YYABORT or YYACCEPT. */ 2235 YYPOPSTACK (yylen); 2236 YY_STACK_PRINT (yyss, yyssp); 2237 while (yyssp != yyss) 2238 { 2239 yydestruct ("Cleanup: popping", 2240 yystos[*yyssp], yyvsp); 2241 YYPOPSTACK (1); 2242 } 2243 #ifndef yyoverflow 2244 if (yyss != yyssa) 2245 YYSTACK_FREE (yyss); 2246 #endif 2247 #if YYERROR_VERBOSE 2248 if (yymsg != yymsgbuf) 2249 YYSTACK_FREE (yymsg); 2250 #endif 2251 /* Make sure YYID is used. */ 2252 return YYID (yyresult); 2253 } 2254 2255 2256 #line 459 "ldscript.y" 2257 2258 2259 static void 2260 yyerror (const char *s) 2261 { 2262 error (0, 0, (ld_scan_version_script 2263 ? gettext ("while reading version script '%s': %s at line %d") 2264 : gettext ("while reading linker script '%s': %s at line %d")), 2265 ldin_fname, gettext (s), ldlineno); 2266 } 2267 2268 2269 static struct expression * 2270 new_expr (int tag) 2271 { 2272 struct expression *newp = (struct expression *) 2273 obstack_alloc (&ld_state.smem, sizeof (*newp)); 2274 2275 newp->tag = tag; 2276 return newp; 2277 } 2278 2279 2280 static struct input_section_name * 2281 new_input_section_name (const char *name, bool sort_flag) 2282 { 2283 struct input_section_name *newp = (struct input_section_name *) 2284 obstack_alloc (&ld_state.smem, sizeof (*newp)); 2285 2286 newp->name = name; 2287 newp->sort_flag = sort_flag; 2288 return newp; 2289 } 2290 2291 2292 static struct input_rule * 2293 new_input_rule (int tag) 2294 { 2295 struct input_rule *newp = (struct input_rule *) 2296 obstack_alloc (&ld_state.smem, sizeof (*newp)); 2297 2298 newp->tag = tag; 2299 newp->next = newp; 2300 return newp; 2301 } 2302 2303 2304 static struct output_rule * 2305 new_output_rule (int tag) 2306 { 2307 struct output_rule *newp = (struct output_rule *) 2308 memset (obstack_alloc (&ld_state.smem, sizeof (*newp)), 2309 '\0', sizeof (*newp)); 2310 2311 newp->tag = tag; 2312 newp->next = newp; 2313 return newp; 2314 } 2315 2316 2317 static struct assignment * 2318 new_assignment (const char *variable, struct expression *expression, 2319 bool provide_flag) 2320 { 2321 struct assignment *newp = (struct assignment *) 2322 obstack_alloc (&ld_state.smem, sizeof (*newp)); 2323 2324 newp->variable = variable; 2325 newp->expression = expression; 2326 newp->sym = NULL; 2327 newp->provide_flag = provide_flag; 2328 2329 /* Insert the symbol into a hash table. We will later have to matc*/ 2330 return newp; 2331 } 2332 2333 2334 static void 2335 new_segment (int mode, struct output_rule *output_rule) 2336 { 2337 struct output_segment *newp; 2338 2339 newp 2340 = (struct output_segment *) obstack_alloc (&ld_state.smem, sizeof (*newp)); 2341 newp->mode = mode; 2342 newp->next = newp; 2343 2344 newp->output_rules = output_rule->next; 2345 output_rule->next = NULL; 2346 2347 /* Enqueue the output segment description. */ 2348 if (ld_state.output_segments == NULL) 2349 ld_state.output_segments = newp; 2350 else 2351 { 2352 newp->next = ld_state.output_segments->next; 2353 ld_state.output_segments = ld_state.output_segments->next = newp; 2354 } 2355 2356 /* If the output file should be stripped of all symbol set the flag 2357 in the structures of all output sections. */ 2358 if (mode == 0 && ld_state.strip == strip_all) 2359 { 2360 struct output_rule *runp; 2361 2362 for (runp = newp->output_rules; runp != NULL; runp = runp->next) 2363 if (runp->tag == output_section) 2364 runp->val.section.ignored = true; 2365 } 2366 } 2367 2368 2369 static struct filename_list * 2370 new_filename_listelem (const char *string) 2371 { 2372 struct filename_list *newp; 2373 2374 /* We use calloc and not the obstack since this object can be freed soon. */ 2375 newp = (struct filename_list *) xcalloc (1, sizeof (*newp)); 2376 newp->name = string; 2377 newp->next = newp; 2378 return newp; 2379 } 2380 2381 2382 static struct filename_list * 2383 mark_as_needed (struct filename_list *listp) 2384 { 2385 struct filename_list *runp = listp; 2386 do 2387 { 2388 runp->as_needed = true; 2389 runp = runp->next; 2390 } 2391 while (runp != listp); 2392 2393 return listp; 2394 } 2395 2396 2397 static void 2398 add_inputfiles (struct filename_list *fnames) 2399 { 2400 assert (fnames != NULL); 2401 2402 if (ld_state.srcfiles == NULL) 2403 ld_state.srcfiles = fnames; 2404 else 2405 { 2406 struct filename_list *first = ld_state.srcfiles->next; 2407 2408 ld_state.srcfiles->next = fnames->next; 2409 fnames->next = first; 2410 ld_state.srcfiles->next = fnames; 2411 } 2412 } 2413 2414 2415 static _Bool 2416 special_char_p (const char *str) 2417 { 2418 while (*str != '\0') 2419 { 2420 if (__builtin_expect (*str == '*', 0) 2421 || __builtin_expect (*str == '?', 0) 2422 || __builtin_expect (*str == '[', 0)) 2423 return true; 2424 2425 ++str; 2426 } 2427 2428 return false; 2429 } 2430 2431 2432 static struct id_list * 2433 new_id_listelem (const char *str) 2434 { 2435 struct id_list *newp; 2436 2437 newp = (struct id_list *) obstack_alloc (&ld_state.smem, sizeof (*newp)); 2438 if (str == NULL) 2439 newp->u.id_type = id_all; 2440 else if (__builtin_expect (special_char_p (str), false)) 2441 newp->u.id_type = id_wild; 2442 else 2443 newp->u.id_type = id_str; 2444 newp->id = str; 2445 newp->next = newp; 2446 2447 return newp; 2448 } 2449 2450 2451 static struct version * 2452 new_version (struct id_list *local, struct id_list *global) 2453 { 2454 struct version *newp; 2455 2456 newp = (struct version *) obstack_alloc (&ld_state.smem, sizeof (*newp)); 2457 newp->next = newp; 2458 newp->local_names = local; 2459 newp->global_names = global; 2460 newp->versionname = NULL; 2461 newp->parentname = NULL; 2462 2463 return newp; 2464 } 2465 2466 2467 static struct version * 2468 merge_versions (struct version *one, struct version *two) 2469 { 2470 assert (two->local_names == NULL || two->global_names == NULL); 2471 2472 if (two->local_names != NULL) 2473 { 2474 if (one->local_names == NULL) 2475 one->local_names = two->local_names; 2476 else 2477 { 2478 two->local_names->next = one->local_names->next; 2479 one->local_names = one->local_names->next = two->local_names; 2480 } 2481 } 2482 else 2483 { 2484 if (one->global_names == NULL) 2485 one->global_names = two->global_names; 2486 else 2487 { 2488 two->global_names->next = one->global_names->next; 2489 one->global_names = one->global_names->next = two->global_names; 2490 } 2491 } 2492 2493 return one; 2494 } 2495 2496 2497 static void 2498 add_id_list (const char *versionname, struct id_list *runp, _Bool local) 2499 { 2500 struct id_list *lastp = runp; 2501 2502 if (runp == NULL) 2503 /* Nothing to do. */ 2504 return; 2505 2506 /* Convert into a simple single-linked list. */ 2507 runp = runp->next; 2508 assert (runp != NULL); 2509 lastp->next = NULL; 2510 2511 do 2512 if (runp->u.id_type == id_str) 2513 { 2514 struct id_list *curp; 2515 struct id_list *defp; 2516 unsigned long int hval = elf_hash (runp->id); 2517 2518 curp = runp; 2519 runp = runp->next; 2520 2521 defp = ld_version_str_tab_find (&ld_state.version_str_tab, hval, curp); 2522 if (defp != NULL) 2523 { 2524 /* There is already a version definition for this symbol. */ 2525 while (strcmp (defp->u.s.versionname, versionname) != 0) 2526 { 2527 if (defp->next == NULL) 2528 { 2529 /* No version like this so far. */ 2530 defp->next = curp; 2531 curp->u.s.local = local; 2532 curp->u.s.versionname = versionname; 2533 curp->next = NULL; 2534 defp = NULL; 2535 break; 2536 } 2537 2538 defp = defp->next; 2539 } 2540 2541 if (defp != NULL && defp->u.s.local != local) 2542 error (EXIT_FAILURE, 0, versionname[0] == '\0' 2543 ? gettext ("\ 2544 symbol '%s' in declared both local and global for unnamed version") 2545 : gettext ("\ 2546 symbol '%s' in declared both local and global for version '%s'"), 2547 runp->id, versionname); 2548 } 2549 else 2550 { 2551 /* This is the first version definition for this symbol. */ 2552 ld_version_str_tab_insert (&ld_state.version_str_tab, hval, curp); 2553 2554 curp->u.s.local = local; 2555 curp->u.s.versionname = versionname; 2556 curp->next = NULL; 2557 } 2558 } 2559 else if (runp->u.id_type == id_all) 2560 { 2561 if (local) 2562 { 2563 if (ld_state.default_bind_global) 2564 error (EXIT_FAILURE, 0, 2565 gettext ("default visibility set as local and global")); 2566 ld_state.default_bind_local = true; 2567 } 2568 else 2569 { 2570 if (ld_state.default_bind_local) 2571 error (EXIT_FAILURE, 0, 2572 gettext ("default visibility set as local and global")); 2573 ld_state.default_bind_global = true; 2574 } 2575 2576 runp = runp->next; 2577 } 2578 else 2579 { 2580 assert (runp->u.id_type == id_wild); 2581 /* XXX TBI */ 2582 abort (); 2583 } 2584 while (runp != NULL); 2585 } 2586 2587 2588 static void 2589 add_versions (struct version *versions) 2590 { 2591 struct version *lastp = versions; 2592 2593 if (versions == NULL) 2594 return; 2595 2596 /* Convert into a simple single-linked list. */ 2597 versions = versions->next; 2598 assert (versions != NULL); 2599 lastp->next = NULL; 2600 2601 do 2602 { 2603 struct version *oldp; 2604 2605 add_id_list (versions->versionname, versions->local_names, true); 2606 add_id_list (versions->versionname, versions->global_names, false); 2607 2608 oldp = versions; 2609 versions = versions->next; 2610 } 2611 while (versions != NULL); 2612 } 2613 2614