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