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