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