3 /* Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 2000, 2001, 2002 Free Software Foundation, Inc.
6 This file is part of GLD, the Gnu Linker.
8 GLD is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GLD is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GLD; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 This was written by steve chamberlain
33 /* Prevent enum redefinition problems. */
34 #define TRUE_FALSE_ALREADY_DEFINED
39 #include "safe-ctype.h"
49 #include "libiberty.h"
51 /* The type of top-level parser input.
52 yylex and yyparse (indirectly) both check this. */
53 input_type parser_input;
55 /* Line number in the current input file.
56 (FIXME Actually, it doesn't appear to get reset for each file?) */
57 unsigned int lineno = 1;
59 /* The string we are currently lexing, or NULL if we are reading a
61 const char *lex_string = NULL;
63 /* Support for flex reading from more than one input file (stream).
64 `include_stack' is flex's input state for each open file;
65 `file_name_stack' is the file names. `lineno_stack' is the current
68 If `include_stack_ptr' is 0, we haven't started reading anything yet.
69 Otherwise, stack elements 0 through `include_stack_ptr - 1' are valid. */
72 #define YY_INPUT(buf,result,max_size) yy_input(buf, &result, max_size)
74 #define MAX_INCLUDE_DEPTH 10
75 static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
76 static const char *file_name_stack[MAX_INCLUDE_DEPTH];
77 static unsigned int lineno_stack[MAX_INCLUDE_DEPTH];
78 static unsigned int include_stack_ptr = 0;
79 static int vers_node_nesting = 0;
81 static YY_BUFFER_STATE yy_create_string_buffer PARAMS ((const char *string,
83 static void yy_input PARAMS ((char *, int *result, int max_size));
85 static void comment PARAMS ((void));
86 static void lex_warn_invalid PARAMS ((char *where, char *what));
89 EXPRESSION definitely in an expression
90 SCRIPT definitely in a script
91 BOTH either EXPRESSION or SCRIPT
92 DEFSYMEXP in an argument to -defsym
94 VERS_START starting a Sun style mapfile
95 VERS_SCRIPT a Sun style mapfile
96 VERS_NODE a node within a Sun style mapfile
98 #define RTOKEN(x) { yylval.token = x; return x; }
100 /* Some versions of flex want this. */
102 int yywrap () { return 1; }
109 CMDFILENAMECHAR [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\-\~]
110 CMDFILENAMECHAR1 [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\~]
111 FILENAMECHAR1 [_a-zA-Z\/\.\\\$\_\~]
112 SYMBOLCHARN [_a-zA-Z\/\.\\\$\_\~0-9]
113 FILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\=\$\:\[\]\\\,\~]
114 WILDCHAR [_a-zA-Z0-9\/\.\-\_\+\=\$\:\[\]\\\,\~\?\*]
117 NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~]
119 V_TAG [.$_a-zA-Z][._a-zA-Z0-9]*
120 V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^]([*?.$_a-zA-Z0-9\[\]\-\!\^]|::)*
132 if (parser_input != input_selected)
134 /* The first token of the input determines the initial parser state. */
135 input_type t = parser_input;
136 parser_input = input_selected;
139 case input_script: return INPUT_SCRIPT; break;
140 case input_mri_script: return INPUT_MRI_SCRIPT; break;
141 case input_version_script: return INPUT_VERSION_SCRIPT; break;
142 case input_defsym: return INPUT_DEFSYM; break;
147 <BOTH,SCRIPT,EXPRESSION,VERS_START,VERS_NODE,VERS_SCRIPT>"/*" { comment(); }
150 <DEFSYMEXP>"-" { RTOKEN('-');}
151 <DEFSYMEXP>"+" { RTOKEN('+');}
152 <DEFSYMEXP>{FILENAMECHAR1}{SYMBOLCHARN}* { yylval.name = xstrdup(yytext); return NAME; }
153 <DEFSYMEXP>"=" { RTOKEN('='); }
155 <MRI,EXPRESSION>"$"([0-9A-Fa-f])+ {
156 yylval.integer = bfd_scan_vma (yytext+1, 0,16);
157 yylval.bigint.str = (char *) 0;
161 <MRI,EXPRESSION>([0-9A-Fa-f])+(H|h|X|x|B|b|O|o|D|d) {
163 switch (yytext[yyleng-1]) {
181 yylval.integer = bfd_scan_vma (yytext, 0,
183 yylval.bigint.str = (char *) 0;
186 <SCRIPT,DEFSYMEXP,MRI,BOTH,EXPRESSION>((("$"|0[xX])([0-9A-Fa-f])+)|(([0-9])+))(M|K|m|k)? {
195 yylval.integer = bfd_scan_vma (s, 0, ibase);
196 yylval.bigint.str = (char *) 0;
197 if (yytext[yyleng-1] == 'M'
198 || yytext[yyleng-1] == 'm')
200 yylval.integer *= 1024 * 1024;
202 else if (yytext[yyleng-1] == 'K'
203 || yytext[yyleng-1]=='k')
205 yylval.integer *= 1024;
207 else if (yytext[0] == '0'
209 || yytext[1] == 'X'))
211 yylval.bigint.str = xstrdup (yytext + 2);
215 <BOTH,SCRIPT,EXPRESSION,MRI>"]" { RTOKEN(']');}
216 <BOTH,SCRIPT,EXPRESSION,MRI>"[" { RTOKEN('[');}
217 <BOTH,SCRIPT,EXPRESSION,MRI>"<<=" { RTOKEN(LSHIFTEQ);}
218 <BOTH,SCRIPT,EXPRESSION,MRI>">>=" { RTOKEN(RSHIFTEQ);}
219 <BOTH,SCRIPT,EXPRESSION,MRI>"||" { RTOKEN(OROR);}
220 <BOTH,SCRIPT,EXPRESSION,MRI>"==" { RTOKEN(EQ);}
221 <BOTH,SCRIPT,EXPRESSION,MRI>"!=" { RTOKEN(NE);}
222 <BOTH,SCRIPT,EXPRESSION,MRI>">=" { RTOKEN(GE);}
223 <BOTH,SCRIPT,EXPRESSION,MRI>"<=" { RTOKEN(LE);}
224 <BOTH,SCRIPT,EXPRESSION,MRI>"<<" { RTOKEN(LSHIFT);}
225 <BOTH,SCRIPT,EXPRESSION,MRI>">>" { RTOKEN(RSHIFT);}
226 <BOTH,SCRIPT,EXPRESSION,MRI>"+=" { RTOKEN(PLUSEQ);}
227 <BOTH,SCRIPT,EXPRESSION,MRI>"-=" { RTOKEN(MINUSEQ);}
228 <BOTH,SCRIPT,EXPRESSION,MRI>"*=" { RTOKEN(MULTEQ);}
229 <BOTH,SCRIPT,EXPRESSION,MRI>"/=" { RTOKEN(DIVEQ);}
230 <BOTH,SCRIPT,EXPRESSION,MRI>"&=" { RTOKEN(ANDEQ);}
231 <BOTH,SCRIPT,EXPRESSION,MRI>"|=" { RTOKEN(OREQ);}
232 <BOTH,SCRIPT,EXPRESSION,MRI>"&&" { RTOKEN(ANDAND);}
233 <BOTH,SCRIPT,EXPRESSION,MRI>">" { RTOKEN('>');}
234 <BOTH,SCRIPT,EXPRESSION,MRI>"," { RTOKEN(',');}
235 <BOTH,SCRIPT,EXPRESSION,MRI>"&" { RTOKEN('&');}
236 <BOTH,SCRIPT,EXPRESSION,MRI>"|" { RTOKEN('|');}
237 <BOTH,SCRIPT,EXPRESSION,MRI>"~" { RTOKEN('~');}
238 <BOTH,SCRIPT,EXPRESSION,MRI>"!" { RTOKEN('!');}
239 <BOTH,SCRIPT,EXPRESSION,MRI>"?" { RTOKEN('?');}
240 <BOTH,SCRIPT,EXPRESSION,MRI>"*" { RTOKEN('*');}
241 <BOTH,SCRIPT,EXPRESSION,MRI>"+" { RTOKEN('+');}
242 <BOTH,SCRIPT,EXPRESSION,MRI>"-" { RTOKEN('-');}
243 <BOTH,SCRIPT,EXPRESSION,MRI>"/" { RTOKEN('/');}
244 <BOTH,SCRIPT,EXPRESSION,MRI>"%" { RTOKEN('%');}
245 <BOTH,SCRIPT,EXPRESSION,MRI>"<" { RTOKEN('<');}
246 <BOTH,SCRIPT,EXPRESSION,MRI>"=" { RTOKEN('=');}
247 <BOTH,SCRIPT,EXPRESSION,MRI>"}" { RTOKEN('}') ; }
248 <BOTH,SCRIPT,EXPRESSION,MRI>"{" { RTOKEN('{'); }
249 <BOTH,SCRIPT,EXPRESSION,MRI>")" { RTOKEN(')');}
250 <BOTH,SCRIPT,EXPRESSION,MRI>"(" { RTOKEN('(');}
251 <BOTH,SCRIPT,EXPRESSION,MRI>":" { RTOKEN(':'); }
252 <BOTH,SCRIPT,EXPRESSION,MRI>";" { RTOKEN(';');}
253 <BOTH,SCRIPT>"MEMORY" { RTOKEN(MEMORY);}
254 <BOTH,SCRIPT>"ORIGIN" { RTOKEN(ORIGIN);}
255 <BOTH,SCRIPT>"VERSION" { RTOKEN(VERSIONK);}
256 <EXPRESSION,BOTH,SCRIPT>"BLOCK" { RTOKEN(BLOCK);}
257 <EXPRESSION,BOTH,SCRIPT>"BIND" { RTOKEN(BIND);}
258 <BOTH,SCRIPT>"LENGTH" { RTOKEN(LENGTH);}
259 <EXPRESSION,BOTH,SCRIPT>"ALIGN" { RTOKEN(ALIGN_K);}
260 <EXPRESSION,BOTH,SCRIPT>"DATA_SEGMENT_ALIGN" { RTOKEN(DATA_SEGMENT_ALIGN);}
261 <EXPRESSION,BOTH,SCRIPT>"DATA_SEGMENT_END" { RTOKEN(DATA_SEGMENT_END);}
262 <EXPRESSION,BOTH,SCRIPT>"ADDR" { RTOKEN(ADDR);}
263 <EXPRESSION,BOTH,SCRIPT>"LOADADDR" { RTOKEN(LOADADDR);}
264 <EXPRESSION,BOTH>"MAX" { RTOKEN(MAX_K); }
265 <EXPRESSION,BOTH>"MIN" { RTOKEN(MIN_K); }
266 <EXPRESSION,BOTH>"ASSERT" { RTOKEN(ASSERT_K); }
267 <BOTH,SCRIPT>"ENTRY" { RTOKEN(ENTRY);}
268 <BOTH,SCRIPT,MRI>"EXTERN" { RTOKEN(EXTERN);}
269 <EXPRESSION,BOTH,SCRIPT>"NEXT" { RTOKEN(NEXT);}
270 <EXPRESSION,BOTH,SCRIPT>"sizeof_headers" { RTOKEN(SIZEOF_HEADERS);}
271 <EXPRESSION,BOTH,SCRIPT>"SIZEOF_HEADERS" { RTOKEN(SIZEOF_HEADERS);}
272 <BOTH,SCRIPT>"MAP" { RTOKEN(MAP);}
273 <EXPRESSION,BOTH,SCRIPT>"SIZEOF" { RTOKEN(SIZEOF);}
274 <BOTH,SCRIPT>"TARGET" { RTOKEN(TARGET_K);}
275 <BOTH,SCRIPT>"SEARCH_DIR" { RTOKEN(SEARCH_DIR);}
276 <BOTH,SCRIPT>"OUTPUT" { RTOKEN(OUTPUT);}
277 <BOTH,SCRIPT>"INPUT" { RTOKEN(INPUT);}
278 <EXPRESSION,BOTH,SCRIPT>"GROUP" { RTOKEN(GROUP);}
279 <EXPRESSION,BOTH,SCRIPT>"DEFINED" { RTOKEN(DEFINED);}
280 <BOTH,SCRIPT>"CREATE_OBJECT_SYMBOLS" { RTOKEN(CREATE_OBJECT_SYMBOLS);}
281 <BOTH,SCRIPT>"CONSTRUCTORS" { RTOKEN( CONSTRUCTORS);}
282 <BOTH,SCRIPT>"FORCE_COMMON_ALLOCATION" { RTOKEN(FORCE_COMMON_ALLOCATION);}
283 <BOTH,SCRIPT>"INHIBIT_COMMON_ALLOCATION" { RTOKEN(INHIBIT_COMMON_ALLOCATION);}
284 <BOTH,SCRIPT>"SECTIONS" { RTOKEN(SECTIONS);}
285 <BOTH,SCRIPT>"FILL" { RTOKEN(FILL);}
286 <BOTH,SCRIPT>"STARTUP" { RTOKEN(STARTUP);}
287 <BOTH,SCRIPT>"OUTPUT_FORMAT" { RTOKEN(OUTPUT_FORMAT);}
288 <BOTH,SCRIPT>"OUTPUT_ARCH" { RTOKEN( OUTPUT_ARCH);}
289 <BOTH,SCRIPT>"HLL" { RTOKEN(HLL);}
290 <BOTH,SCRIPT>"SYSLIB" { RTOKEN(SYSLIB);}
291 <BOTH,SCRIPT>"FLOAT" { RTOKEN(FLOAT);}
292 <BOTH,SCRIPT>"QUAD" { RTOKEN( QUAD);}
293 <BOTH,SCRIPT>"SQUAD" { RTOKEN( SQUAD);}
294 <BOTH,SCRIPT>"LONG" { RTOKEN( LONG);}
295 <BOTH,SCRIPT>"SHORT" { RTOKEN( SHORT);}
296 <BOTH,SCRIPT>"BYTE" { RTOKEN( BYTE);}
297 <BOTH,SCRIPT>"NOFLOAT" { RTOKEN(NOFLOAT);}
298 <EXPRESSION,BOTH,SCRIPT>"NOCROSSREFS" { RTOKEN(NOCROSSREFS);}
299 <BOTH,SCRIPT>"OVERLAY" { RTOKEN(OVERLAY); }
300 <BOTH,SCRIPT>"SORT" { RTOKEN(SORT); }
301 <EXPRESSION,BOTH,SCRIPT>"NOLOAD" { RTOKEN(NOLOAD);}
302 <EXPRESSION,BOTH,SCRIPT>"DSECT" { RTOKEN(DSECT);}
303 <EXPRESSION,BOTH,SCRIPT>"COPY" { RTOKEN(COPY);}
304 <EXPRESSION,BOTH,SCRIPT>"INFO" { RTOKEN(INFO);}
305 <EXPRESSION,BOTH,SCRIPT>"OVERLAY" { RTOKEN(OVERLAY);}
306 <BOTH,SCRIPT>"o" { RTOKEN(ORIGIN);}
307 <BOTH,SCRIPT>"org" { RTOKEN(ORIGIN);}
308 <BOTH,SCRIPT>"l" { RTOKEN( LENGTH);}
309 <BOTH,SCRIPT>"len" { RTOKEN( LENGTH);}
310 <BOTH,SCRIPT>"INCLUDE" { RTOKEN(INCLUDE);}
311 <BOTH,SCRIPT>"PHDRS" { RTOKEN (PHDRS); }
312 <EXPRESSION,BOTH,SCRIPT>"AT" { RTOKEN(AT);}
313 <EXPRESSION,BOTH,SCRIPT>"PROVIDE" { RTOKEN(PROVIDE); }
314 <EXPRESSION,BOTH,SCRIPT>"KEEP" { RTOKEN(KEEP); }
315 <EXPRESSION,BOTH,SCRIPT>"EXCLUDE_FILE" { RTOKEN(EXCLUDE_FILE); }
316 <MRI>"#".*\n? { ++ lineno; }
317 <MRI>"\n" { ++ lineno; RTOKEN(NEWLINE); }
318 <MRI>"*".* { /* Mri comment line */ }
319 <MRI>";".* { /* Mri comment line */ }
320 <MRI>"END" { RTOKEN(ENDWORD); }
321 <MRI>"ALIGNMOD" { RTOKEN(ALIGNMOD);}
322 <MRI>"ALIGN" { RTOKEN(ALIGN_K);}
323 <MRI>"CHIP" { RTOKEN(CHIP); }
324 <MRI>"BASE" { RTOKEN(BASE); }
325 <MRI>"ALIAS" { RTOKEN(ALIAS); }
326 <MRI>"TRUNCATE" { RTOKEN(TRUNCATE); }
327 <MRI>"LOAD" { RTOKEN(LOAD); }
328 <MRI>"PUBLIC" { RTOKEN(PUBLIC); }
329 <MRI>"ORDER" { RTOKEN(ORDER); }
330 <MRI>"NAME" { RTOKEN(NAMEWORD); }
331 <MRI>"FORMAT" { RTOKEN(FORMAT); }
332 <MRI>"CASE" { RTOKEN(CASE); }
333 <MRI>"START" { RTOKEN(START); }
334 <MRI>"LIST".* { RTOKEN(LIST); /* LIST and ignore to end of line */ }
335 <MRI>"SECT" { RTOKEN(SECT); }
336 <EXPRESSION,BOTH,SCRIPT,MRI>"ABSOLUTE" { RTOKEN(ABSOLUTE); }
337 <MRI>"end" { RTOKEN(ENDWORD); }
338 <MRI>"alignmod" { RTOKEN(ALIGNMOD);}
339 <MRI>"align" { RTOKEN(ALIGN_K);}
340 <MRI>"chip" { RTOKEN(CHIP); }
341 <MRI>"base" { RTOKEN(BASE); }
342 <MRI>"alias" { RTOKEN(ALIAS); }
343 <MRI>"truncate" { RTOKEN(TRUNCATE); }
344 <MRI>"load" { RTOKEN(LOAD); }
345 <MRI>"public" { RTOKEN(PUBLIC); }
346 <MRI>"order" { RTOKEN(ORDER); }
347 <MRI>"name" { RTOKEN(NAMEWORD); }
348 <MRI>"format" { RTOKEN(FORMAT); }
349 <MRI>"case" { RTOKEN(CASE); }
350 <MRI>"extern" { RTOKEN(EXTERN); }
351 <MRI>"start" { RTOKEN(START); }
352 <MRI>"list".* { RTOKEN(LIST); /* LIST and ignore to end of line */ }
353 <MRI>"sect" { RTOKEN(SECT); }
354 <EXPRESSION,BOTH,SCRIPT,MRI>"absolute" { RTOKEN(ABSOLUTE); }
356 <MRI>{FILENAMECHAR1}{NOCFILENAMECHAR}* {
357 /* Filename without commas, needed to parse mri stuff */
358 yylval.name = xstrdup(yytext);
363 <BOTH,EXPRESSION>{FILENAMECHAR1}{FILENAMECHAR}* {
364 yylval.name = xstrdup(yytext);
367 <BOTH,EXPRESSION>"-l"{FILENAMECHAR}+ {
368 yylval.name = xstrdup (yytext + 2);
371 <SCRIPT>{WILDCHAR}* {
372 /* Annoyingly, this pattern can match comments, and we have
373 longest match issues to consider. So if the first two
374 characters are a comment opening, put the input back and
376 if (yytext[0] == '/' && yytext[1] == '*')
383 yylval.name = xstrdup(yytext);
388 <EXPRESSION,BOTH,SCRIPT,VERS_NODE>"\""[^\"]*"\"" {
389 /* No matter the state, quotes
390 give what's inside */
391 yylval.name = xstrdup(yytext+1);
392 yylval.name[yyleng-2] = 0;
395 <BOTH,SCRIPT,EXPRESSION>"\n" { lineno++;}
396 <MRI,BOTH,SCRIPT,EXPRESSION>[ \t\r]+ { }
398 <VERS_NODE,VERS_SCRIPT>[:,;] { return *yytext; }
400 <VERS_NODE>global { RTOKEN(GLOBAL); }
402 <VERS_NODE>local { RTOKEN(LOCAL); }
404 <VERS_NODE>extern { RTOKEN(EXTERN); }
406 <VERS_NODE>{V_IDENTIFIER} { yylval.name = xstrdup (yytext);
407 return VERS_IDENTIFIER; }
409 <VERS_SCRIPT>{V_TAG} { yylval.name = xstrdup (yytext);
412 <VERS_START>"{" { BEGIN(VERS_SCRIPT); return *yytext; }
414 <VERS_SCRIPT>"{" { BEGIN(VERS_NODE);
415 vers_node_nesting = 0;
418 <VERS_SCRIPT>"}" { return *yytext; }
419 <VERS_NODE>"{" { vers_node_nesting++; return *yytext; }
420 <VERS_NODE>"}" { if (--vers_node_nesting < 0)
425 <VERS_START,VERS_NODE,VERS_SCRIPT>[\n] { lineno++; }
427 <VERS_START,VERS_NODE,VERS_SCRIPT>#.* { /* Eat up comments */ }
429 <VERS_START,VERS_NODE,VERS_SCRIPT>[ \t\r]+ { /* Eat up whitespace */ }
434 if (include_stack_ptr == 0)
440 yy_switch_to_buffer(include_stack[include_stack_ptr]);
443 ldfile_input_filename = file_name_stack[include_stack_ptr - 1];
444 lineno = lineno_stack[include_stack_ptr];
449 <SCRIPT,MRI,VERS_START,VERS_SCRIPT,VERS_NODE>. lex_warn_invalid(" in script", yytext);
450 <EXPRESSION,DEFSYMEXP,BOTH>. lex_warn_invalid(" in expression", yytext);
455 /* Switch flex to reading script file NAME, open on FILE,
456 saving the current input info on the include stack. */
459 lex_push_file (file, name)
463 if (include_stack_ptr >= MAX_INCLUDE_DEPTH)
465 einfo("%F:includes nested too deeply\n");
467 file_name_stack[include_stack_ptr] = name;
468 lineno_stack[include_stack_ptr] = lineno;
469 include_stack[include_stack_ptr] = YY_CURRENT_BUFFER;
474 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
477 /* Return a newly created flex input buffer containing STRING,
478 which is SIZE bytes long. */
480 static YY_BUFFER_STATE
481 yy_create_string_buffer (string, size)
487 /* Calls to m-alloc get turned by sed into xm-alloc. */
488 b = (YY_BUFFER_STATE) malloc (sizeof (struct yy_buffer_state));
489 b->yy_input_file = 0;
490 b->yy_buf_size = size;
492 /* yy_ch_buf has to be 2 characters longer than the size given because
493 we need to put in 2 end-of-buffer characters. */
494 b->yy_ch_buf = (char *) malloc ((unsigned) (b->yy_buf_size + 3));
496 b->yy_ch_buf[0] = '\n';
497 strcpy (b->yy_ch_buf+1, string);
498 b->yy_ch_buf[size+1] = YY_END_OF_BUFFER_CHAR;
499 b->yy_ch_buf[size+2] = YY_END_OF_BUFFER_CHAR;
500 b->yy_n_chars = size+1;
501 b->yy_buf_pos = &b->yy_ch_buf[1];
503 b->yy_is_our_buffer = 1;
504 b->yy_is_interactive = 0;
506 b->yy_fill_buffer = 0;
508 /* flex 2.4.7 changed the interface. FIXME: We should not be using
509 a flex internal interface in the first place! */
511 b->yy_buffer_status = YY_BUFFER_NEW;
513 b->yy_eof_status = EOF_NOT_SEEN;
519 /* Switch flex to reading from STRING, saving the current input info
520 on the include stack. */
523 lex_redirect (string)
529 if (include_stack_ptr >= MAX_INCLUDE_DEPTH)
531 einfo("%F: macros nested too deeply\n");
533 file_name_stack[include_stack_ptr] = "redirect";
534 lineno_stack[include_stack_ptr] = lineno;
535 include_stack[include_stack_ptr] = YY_CURRENT_BUFFER;
538 tmp = yy_create_string_buffer (string, strlen (string));
539 yy_switch_to_buffer (tmp);
542 /* Functions to switch to a different flex start condition,
543 saving the current start condition on `state_stack'. */
545 static int state_stack[MAX_INCLUDE_DEPTH * 2];
546 static int *state_stack_p = state_stack;
551 *(state_stack_p)++ = yy_start;
558 *(state_stack_p)++ = yy_start;
563 ldlex_version_script ()
565 *(state_stack_p)++ = yy_start;
570 ldlex_version_file ()
572 *(state_stack_p)++ = yy_start;
579 *(state_stack_p)++ = yy_start;
586 *(state_stack_p)++ = yy_start;
593 *(state_stack_p)++ = yy_start;
600 yy_start = *(--state_stack_p);
604 /* Place up to MAX_SIZE characters in BUF and return in *RESULT
605 either the number of characters read, or 0 to indicate EOF. */
608 yy_input (buf, result, max_size)
614 if (YY_CURRENT_BUFFER->yy_input_file)
618 *result = fread ((char *) buf, 1, max_size, yyin);
619 if (*result < max_size && ferror (yyin))
620 einfo ("%F%P: read in flex scanner failed\n");
625 /* Eat the rest of a C-style comment. */
635 while (c != '*' && c != EOF)
648 break; /* found the end */
656 einfo( "%F%P: EOF in comment\n");
662 /* Warn the user about a garbage character WHAT in the input
666 lex_warn_invalid (where, what)
671 /* If we have found an input file whose format we do not recognize,
672 and we are therefore treating it as a linker script, and we find
673 an invalid character, then most likely this is a real object file
674 of some different format. Treat it as such. */
675 if (ldfile_assumed_script)
677 bfd_set_error (bfd_error_file_not_recognized);
678 einfo ("%F%s: file not recognized: %E\n", ldfile_input_filename);
681 if (! ISPRINT (*what))
683 sprintf (buf, "\\%03o", (unsigned int) *what);
687 einfo ("%P:%S: ignoring invalid character `%s'%s\n", what, where);