Add support for DragonFlyBSD target.
[binutils.git] / ld / ldlex.l
Commit [+]AuthorDateLineData
1be5f0e3
BE
Ben Elliston2009-11-19 05:06:33 +00001%option nounput
2
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +00003%{
4
3d9e60c6
AM
Alan Modra2011-01-13 13:34:53 +00005/* Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
6 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
a541e7f6 Alan Modra2007-04-26 14:47:00 +00007 Free Software Foundation, Inc.
ee5d4cc3 Nick Clifton2007-07-06 14:09:45 +00008 Written by Steve Chamberlain of Cygnus Support.
aa2289c2 Richard Henderson1999-05-03 07:29:11 +00009
ee5d4cc3 Nick Clifton2007-07-06 14:09:45 +000010 This file is part of the GNU Binutils.
aa2289c2 Richard Henderson1999-05-03 07:29:11 +000011
ee5d4cc3 Nick Clifton2007-07-06 14:09:45 +000012 This program is free software; you can redistribute it and/or modify
92c23ae7 Nick Clifton2004-11-19 09:31:55 +000013 it under the terms of the GNU General Public License as published by
ee5d4cc3
NC
Nick Clifton2007-07-06 14:09:45 +000014 the Free Software Foundation; either version 3 of the License, or
15 (at your option) any later version.
aa2289c2 Richard Henderson1999-05-03 07:29:11 +000016
ee5d4cc3 Nick Clifton2007-07-06 14:09:45 +000017 This program is distributed in the hope that it will be useful,
92c23ae7
NC
Nick Clifton2004-11-19 09:31:55 +000018 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
aa2289c2 Richard Henderson1999-05-03 07:29:11 +000021
92c23ae7 Nick Clifton2004-11-19 09:31:55 +000022 You should have received a copy of the GNU General Public License
ee5d4cc3
NC
Nick Clifton2007-07-06 14:09:45 +000023 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
25 MA 02110-1301, USA. */
aa2289c2 Richard Henderson1999-05-03 07:29:11 +000026
a541e7f6 Alan Modra2007-04-26 14:47:00 +000027#include "bfd.h"
75e56203 H.J. Lu2001-09-19 05:33:36 +000028#include "safe-ctype.h"
1cf322d9 Alan Modra2002-07-01 08:07:31 +000029#include "bfdlink.h"
aa2289c2 Richard Henderson1999-05-03 07:29:11 +000030#include "ld.h"
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +000031#include "ldmisc.h"
32#include "ldexp.h"
33#include "ldlang.h"
bb0e4f13 Daniel Jacobowitz2002-10-30 03:57:39 +000034#include <ldgram.h>
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +000035#include "ldfile.h"
36#include "ldlex.h"
37#include "ldmain.h"
8a0a249a H.J. Lu2001-05-02 16:42:55 +000038#include "libiberty.h"
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +000039
40/* The type of top-level parser input.
41 yylex and yyparse (indirectly) both check this. */
42input_type parser_input;
43
44/* Line number in the current input file.
45 (FIXME Actually, it doesn't appear to get reset for each file?) */
46unsigned int lineno = 1;
47
48/* The string we are currently lexing, or NULL if we are reading a
49 file. */
50const char *lex_string = NULL;
51
52/* Support for flex reading from more than one input file (stream).
53 `include_stack' is flex's input state for each open file;
54 `file_name_stack' is the file names. `lineno_stack' is the current
55 line numbers.
56
57 If `include_stack_ptr' is 0, we haven't started reading anything yet.
58 Otherwise, stack elements 0 through `include_stack_ptr - 1' are valid. */
59
60#undef YY_INPUT
0340e939 Andreas Schwab2009-10-14 10:54:27 +000061#define YY_INPUT(buf,result,max_size) result = yy_input (buf, max_size)
aa2289c2 Richard Henderson1999-05-03 07:29:11 +000062
9f9a0b1a Nick Clifton2011-03-28 11:18:20 +000063#ifndef YY_NO_UNPUT
c0cb87b2 Nick Clifton2005-02-15 14:36:19 +000064#define YY_NO_UNPUT
9f9a0b1a Nick Clifton2011-03-28 11:18:20 +000065#endif
c0cb87b2 Nick Clifton2005-02-15 14:36:19 +000066
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +000067#define MAX_INCLUDE_DEPTH 10
68static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
69static const char *file_name_stack[MAX_INCLUDE_DEPTH];
70static unsigned int lineno_stack[MAX_INCLUDE_DEPTH];
71static unsigned int include_stack_ptr = 0;
72static int vers_node_nesting = 0;
73
0340e939 Andreas Schwab2009-10-14 10:54:27 +000074static int yy_input (char *, int);
84c5e537
AM
Alan Modra2003-06-28 05:28:54 +000075static void comment (void);
76static void lex_warn_invalid (char *where, char *what);
aa2289c2 Richard Henderson1999-05-03 07:29:11 +000077
84c5e537 Alan Modra2003-06-28 05:28:54 +000078/* STATES
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +000079 EXPRESSION definitely in an expression
80 SCRIPT definitely in a script
81 BOTH either EXPRESSION or SCRIPT
82 DEFSYMEXP in an argument to -defsym
83 MRI in an MRI script
84 VERS_START starting a Sun style mapfile
85 VERS_SCRIPT a Sun style mapfile
86 VERS_NODE a node within a Sun style mapfile
87*/
88#define RTOKEN(x) { yylval.token = x; return x; }
89
90/* Some versions of flex want this. */
91#ifndef yywrap
84c5e537 Alan Modra2003-06-28 05:28:54 +000092int yywrap (void) { return 1; }
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +000093#endif
94%}
95
96%a 4000
97%o 5000
98
99CMDFILENAMECHAR [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\-\~]
100CMDFILENAMECHAR1 [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\~]
101FILENAMECHAR1 [_a-zA-Z\/\.\\\$\_\~]
102SYMBOLCHARN [_a-zA-Z\/\.\\\$\_\~0-9]
103FILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\=\$\:\[\]\\\,\~]
3bfb18fb Nick Clifton2010-08-31 16:08:22 +0000104WILDCHAR [_a-zA-Z0-9\/\.\-\_\+\=\$\:\[\]\\\,\~\?\*\^\!]
84c5e537 Alan Modra2003-06-28 05:28:54 +0000105WHITE [ \t\n\r]+
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000106
107NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~]
108
109V_TAG [.$_a-zA-Z][._a-zA-Z0-9]*
acec4d0b H.J. Lu2003-10-24 14:55:14 +0000110V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000111
112%s SCRIPT
113%s EXPRESSION
114%s BOTH
115%s DEFSYMEXP
116%s MRI
117%s VERS_START
118%s VERS_SCRIPT
119%s VERS_NODE
120%%
121
122 if (parser_input != input_selected)
123 {
124 /* The first token of the input determines the initial parser state. */
125 input_type t = parser_input;
126 parser_input = input_selected;
127 switch (t)
128 {
129 case input_script: return INPUT_SCRIPT; break;
130 case input_mri_script: return INPUT_MRI_SCRIPT; break;
131 case input_version_script: return INPUT_VERSION_SCRIPT; break;
32fd2193 H.J. Lu2006-09-07 17:16:34 +0000132 case input_dynamic_list: return INPUT_DYNAMIC_LIST; break;
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000133 case input_defsym: return INPUT_DEFSYM; break;
134 default: abort ();
135 }
136 }
137
84c5e537 Alan Modra2003-06-28 05:28:54 +0000138<BOTH,SCRIPT,EXPRESSION,VERS_START,VERS_NODE,VERS_SCRIPT>"/*" { comment (); }
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000139
140
141<DEFSYMEXP>"-" { RTOKEN('-');}
142<DEFSYMEXP>"+" { RTOKEN('+');}
84c5e537 Alan Modra2003-06-28 05:28:54 +0000143<DEFSYMEXP>{FILENAMECHAR1}{SYMBOLCHARN}* { yylval.name = xstrdup (yytext); return NAME; }
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000144<DEFSYMEXP>"=" { RTOKEN('='); }
145
146<MRI,EXPRESSION>"$"([0-9A-Fa-f])+ {
84c5e537
AM
Alan Modra2003-06-28 05:28:54 +0000147 yylval.integer = bfd_scan_vma (yytext + 1, 0, 16);
148 yylval.bigint.str = NULL;
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000149 return INT;
150 }
151
152<MRI,EXPRESSION>([0-9A-Fa-f])+(H|h|X|x|B|b|O|o|D|d) {
153 int ibase ;
84c5e537
AM
Alan Modra2003-06-28 05:28:54 +0000154 switch (yytext[yyleng - 1]) {
155 case 'X':
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000156 case 'x':
157 case 'H':
158 case 'h':
159 ibase = 16;
160 break;
161 case 'O':
162 case 'o':
163 ibase = 8;
164 break;
165 case 'B':
166 case 'b':
167 ibase = 2;
168 break;
169 default:
170 ibase = 10;
171 }
172 yylval.integer = bfd_scan_vma (yytext, 0,
173 ibase);
84c5e537 Alan Modra2003-06-28 05:28:54 +0000174 yylval.bigint.str = NULL;
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000175 return INT;
176 }
6616c569 Alan Modra2002-02-15 02:11:05 +0000177<SCRIPT,DEFSYMEXP,MRI,BOTH,EXPRESSION>((("$"|0[xX])([0-9A-Fa-f])+)|(([0-9])+))(M|K|m|k)? {
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000178 char *s = yytext;
6616c569 Alan Modra2002-02-15 02:11:05 +0000179 int ibase = 0;
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000180
181 if (*s == '$')
6616c569
AM
Alan Modra2002-02-15 02:11:05 +0000182 {
183 ++s;
184 ibase = 16;
185 }
186 yylval.integer = bfd_scan_vma (s, 0, ibase);
84c5e537
AM
Alan Modra2003-06-28 05:28:54 +0000187 yylval.bigint.str = NULL;
188 if (yytext[yyleng - 1] == 'M'
189 || yytext[yyleng - 1] == 'm')
6616c569
AM
Alan Modra2002-02-15 02:11:05 +0000190 {
191 yylval.integer *= 1024 * 1024;
192 }
84c5e537
AM
Alan Modra2003-06-28 05:28:54 +0000193 else if (yytext[yyleng - 1] == 'K'
194 || yytext[yyleng - 1]=='k')
6616c569
AM
Alan Modra2002-02-15 02:11:05 +0000195 {
196 yylval.integer *= 1024;
197 }
198 else if (yytext[0] == '0'
199 && (yytext[1] == 'x'
200 || yytext[1] == 'X'))
201 {
202 yylval.bigint.str = xstrdup (yytext + 2);
203 }
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000204 return INT;
205 }
206<BOTH,SCRIPT,EXPRESSION,MRI>"]" { RTOKEN(']');}
207<BOTH,SCRIPT,EXPRESSION,MRI>"[" { RTOKEN('[');}
208<BOTH,SCRIPT,EXPRESSION,MRI>"<<=" { RTOKEN(LSHIFTEQ);}
209<BOTH,SCRIPT,EXPRESSION,MRI>">>=" { RTOKEN(RSHIFTEQ);}
210<BOTH,SCRIPT,EXPRESSION,MRI>"||" { RTOKEN(OROR);}
211<BOTH,SCRIPT,EXPRESSION,MRI>"==" { RTOKEN(EQ);}
212<BOTH,SCRIPT,EXPRESSION,MRI>"!=" { RTOKEN(NE);}
213<BOTH,SCRIPT,EXPRESSION,MRI>">=" { RTOKEN(GE);}
214<BOTH,SCRIPT,EXPRESSION,MRI>"<=" { RTOKEN(LE);}
215<BOTH,SCRIPT,EXPRESSION,MRI>"<<" { RTOKEN(LSHIFT);}
216<BOTH,SCRIPT,EXPRESSION,MRI>">>" { RTOKEN(RSHIFT);}
217<BOTH,SCRIPT,EXPRESSION,MRI>"+=" { RTOKEN(PLUSEQ);}
218<BOTH,SCRIPT,EXPRESSION,MRI>"-=" { RTOKEN(MINUSEQ);}
219<BOTH,SCRIPT,EXPRESSION,MRI>"*=" { RTOKEN(MULTEQ);}
220<BOTH,SCRIPT,EXPRESSION,MRI>"/=" { RTOKEN(DIVEQ);}
221<BOTH,SCRIPT,EXPRESSION,MRI>"&=" { RTOKEN(ANDEQ);}
222<BOTH,SCRIPT,EXPRESSION,MRI>"|=" { RTOKEN(OREQ);}
223<BOTH,SCRIPT,EXPRESSION,MRI>"&&" { RTOKEN(ANDAND);}
224<BOTH,SCRIPT,EXPRESSION,MRI>">" { RTOKEN('>');}
225<BOTH,SCRIPT,EXPRESSION,MRI>"," { RTOKEN(',');}
226<BOTH,SCRIPT,EXPRESSION,MRI>"&" { RTOKEN('&');}
227<BOTH,SCRIPT,EXPRESSION,MRI>"|" { RTOKEN('|');}
228<BOTH,SCRIPT,EXPRESSION,MRI>"~" { RTOKEN('~');}
229<BOTH,SCRIPT,EXPRESSION,MRI>"!" { RTOKEN('!');}
230<BOTH,SCRIPT,EXPRESSION,MRI>"?" { RTOKEN('?');}
231<BOTH,SCRIPT,EXPRESSION,MRI>"*" { RTOKEN('*');}
232<BOTH,SCRIPT,EXPRESSION,MRI>"+" { RTOKEN('+');}
233<BOTH,SCRIPT,EXPRESSION,MRI>"-" { RTOKEN('-');}
234<BOTH,SCRIPT,EXPRESSION,MRI>"/" { RTOKEN('/');}
235<BOTH,SCRIPT,EXPRESSION,MRI>"%" { RTOKEN('%');}
236<BOTH,SCRIPT,EXPRESSION,MRI>"<" { RTOKEN('<');}
92c23ae7
NC
Nick Clifton2004-11-19 09:31:55 +0000237<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('(');}
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000242<BOTH,SCRIPT,EXPRESSION,MRI>":" { RTOKEN(':'); }
243<BOTH,SCRIPT,EXPRESSION,MRI>";" { RTOKEN(';');}
92c23ae7 Nick Clifton2004-11-19 09:31:55 +0000244<BOTH,SCRIPT>"MEMORY" { RTOKEN(MEMORY);}
401c06ad Nick Clifton2009-03-02 17:27:36 +0000245<BOTH,SCRIPT>"REGION_ALIAS" { RTOKEN(REGION_ALIAS);}
cba8ccce Alan Modra2011-01-13 13:29:55 +0000246<BOTH,SCRIPT>"LD_FEATURE" { RTOKEN(LD_FEATURE);}
92c23ae7
NC
Nick Clifton2004-11-19 09:31:55 +0000247<BOTH,SCRIPT,EXPRESSION>"ORIGIN" { RTOKEN(ORIGIN);}
248<BOTH,SCRIPT>"VERSION" { RTOKEN(VERSIONK);}
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000249<EXPRESSION,BOTH,SCRIPT>"BLOCK" { RTOKEN(BLOCK);}
250<EXPRESSION,BOTH,SCRIPT>"BIND" { RTOKEN(BIND);}
92c23ae7
NC
Nick Clifton2004-11-19 09:31:55 +0000251<BOTH,SCRIPT,EXPRESSION>"LENGTH" { RTOKEN(LENGTH);}
252<EXPRESSION,BOTH,SCRIPT>"ALIGN" { RTOKEN(ALIGN_K);}
4b5629ba Jakub Jelinek2002-02-12 14:50:08 +0000253<EXPRESSION,BOTH,SCRIPT>"DATA_SEGMENT_ALIGN" { RTOKEN(DATA_SEGMENT_ALIGN);}
0816a831 Jakub Jelinek2004-05-11 17:08:38 +0000254<EXPRESSION,BOTH,SCRIPT>"DATA_SEGMENT_RELRO_END" { RTOKEN(DATA_SEGMENT_RELRO_END);}
4b5629ba Jakub Jelinek2002-02-12 14:50:08 +0000255<EXPRESSION,BOTH,SCRIPT>"DATA_SEGMENT_END" { RTOKEN(DATA_SEGMENT_END);}
92c23ae7
NC
Nick Clifton2004-11-19 09:31:55 +0000256<EXPRESSION,BOTH,SCRIPT>"ADDR" { RTOKEN(ADDR);}
257<EXPRESSION,BOTH,SCRIPT>"LOADADDR" { RTOKEN(LOADADDR);}
cff93187 Nathan Sidwell2007-06-18 12:38:22 +0000258<EXPRESSION,BOTH,SCRIPT>"ALIGNOF" { RTOKEN(ALIGNOF); }
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000259<EXPRESSION,BOTH>"MAX" { RTOKEN(MAX_K); }
260<EXPRESSION,BOTH>"MIN" { RTOKEN(MIN_K); }
746dcfd6 Nathan Sidwell2007-05-24 09:24:09 +0000261<EXPRESSION,BOTH,SCRIPT>"ASSERT" { RTOKEN(ASSERT_K); }
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000262<BOTH,SCRIPT>"ENTRY" { RTOKEN(ENTRY);}
263<BOTH,SCRIPT,MRI>"EXTERN" { RTOKEN(EXTERN);}
92c23ae7 Nick Clifton2004-11-19 09:31:55 +0000264<EXPRESSION,BOTH,SCRIPT>"NEXT" { RTOKEN(NEXT);}
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000265<EXPRESSION,BOTH,SCRIPT>"sizeof_headers" { RTOKEN(SIZEOF_HEADERS);}
266<EXPRESSION,BOTH,SCRIPT>"SIZEOF_HEADERS" { RTOKEN(SIZEOF_HEADERS);}
cfb3e4d8 Mark Mitchell2004-10-26 18:41:52 +0000267<EXPRESSION,BOTH,SCRIPT>"SEGMENT_START" { RTOKEN(SEGMENT_START);}
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000268<BOTH,SCRIPT>"MAP" { RTOKEN(MAP);}
92c23ae7
NC
Nick Clifton2004-11-19 09:31:55 +0000269<EXPRESSION,BOTH,SCRIPT>"SIZEOF" { RTOKEN(SIZEOF);}
270<BOTH,SCRIPT>"TARGET" { RTOKEN(TARGET_K);}
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000271<BOTH,SCRIPT>"SEARCH_DIR" { RTOKEN(SEARCH_DIR);}
92c23ae7 Nick Clifton2004-11-19 09:31:55 +0000272<BOTH,SCRIPT>"OUTPUT" { RTOKEN(OUTPUT);}
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000273<BOTH,SCRIPT>"INPUT" { RTOKEN(INPUT);}
274<EXPRESSION,BOTH,SCRIPT>"GROUP" { RTOKEN(GROUP);}
6008a341 Jakub Jelinek2005-01-21 12:04:25 +0000275<EXPRESSION,BOTH,SCRIPT>"AS_NEEDED" { RTOKEN(AS_NEEDED);}
92c23ae7 Nick Clifton2004-11-19 09:31:55 +0000276<EXPRESSION,BOTH,SCRIPT>"DEFINED" { RTOKEN(DEFINED);}
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000277<BOTH,SCRIPT>"CREATE_OBJECT_SYMBOLS" { RTOKEN(CREATE_OBJECT_SYMBOLS);}
278<BOTH,SCRIPT>"CONSTRUCTORS" { RTOKEN( CONSTRUCTORS);}
92c23ae7 Nick Clifton2004-11-19 09:31:55 +0000279<BOTH,SCRIPT>"FORCE_COMMON_ALLOCATION" { RTOKEN(FORCE_COMMON_ALLOCATION);}
dd6c6ef5 Alan Modra2001-09-29 12:57:54 +0000280<BOTH,SCRIPT>"INHIBIT_COMMON_ALLOCATION" { RTOKEN(INHIBIT_COMMON_ALLOCATION);}
92c23ae7 Nick Clifton2004-11-19 09:31:55 +0000281<BOTH,SCRIPT>"SECTIONS" { RTOKEN(SECTIONS);}
6b939cf2
AM
Alan Modra2008-01-25 12:03:37 +0000282<BOTH,SCRIPT>"INSERT" { RTOKEN(INSERT_K);}
283<BOTH,SCRIPT>"AFTER" { RTOKEN(AFTER);}
284<BOTH,SCRIPT>"BEFORE" { RTOKEN(BEFORE);}
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000285<BOTH,SCRIPT>"FILL" { RTOKEN(FILL);}
92c23ae7 Nick Clifton2004-11-19 09:31:55 +0000286<BOTH,SCRIPT>"STARTUP" { RTOKEN(STARTUP);}
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000287<BOTH,SCRIPT>"OUTPUT_FORMAT" { RTOKEN(OUTPUT_FORMAT);}
288<BOTH,SCRIPT>"OUTPUT_ARCH" { RTOKEN( OUTPUT_ARCH);}
289<BOTH,SCRIPT>"HLL" { RTOKEN(HLL);}
92c23ae7 Nick Clifton2004-11-19 09:31:55 +0000290<BOTH,SCRIPT>"SYSLIB" { RTOKEN(SYSLIB);}
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000291<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);}
92c23ae7 Nick Clifton2004-11-19 09:31:55 +0000297<BOTH,SCRIPT>"NOFLOAT" { RTOKEN(NOFLOAT);}
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000298<EXPRESSION,BOTH,SCRIPT>"NOCROSSREFS" { RTOKEN(NOCROSSREFS);}
299<BOTH,SCRIPT>"OVERLAY" { RTOKEN(OVERLAY); }
1505566c
L
H.J. Lu2004-10-04 16:45:51 +0000300<BOTH,SCRIPT>"SORT_BY_NAME" { RTOKEN(SORT_BY_NAME); }
301<BOTH,SCRIPT>"SORT_BY_ALIGNMENT" { RTOKEN(SORT_BY_ALIGNMENT); }
302<BOTH,SCRIPT>"SORT" { RTOKEN(SORT_BY_NAME); }
30dfd030 H.J. Lu2010-12-15 14:56:35 +0000303<BOTH,SCRIPT>"SORT_BY_INIT_PRIORITY" { RTOKEN(SORT_BY_INIT_PRIORITY); }
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000304<EXPRESSION,BOTH,SCRIPT>"NOLOAD" { RTOKEN(NOLOAD);}
305<EXPRESSION,BOTH,SCRIPT>"DSECT" { RTOKEN(DSECT);}
306<EXPRESSION,BOTH,SCRIPT>"COPY" { RTOKEN(COPY);}
307<EXPRESSION,BOTH,SCRIPT>"INFO" { RTOKEN(INFO);}
308<EXPRESSION,BOTH,SCRIPT>"OVERLAY" { RTOKEN(OVERLAY);}
d5d8cfb7
JJ
Jakub Jelinek2004-05-19 14:01:14 +0000309<EXPRESSION,BOTH,SCRIPT>"ONLY_IF_RO" { RTOKEN(ONLY_IF_RO); }
310<EXPRESSION,BOTH,SCRIPT>"ONLY_IF_RW" { RTOKEN(ONLY_IF_RW); }
01490f0f Alan Modra2005-05-11 14:10:10 +0000311<EXPRESSION,BOTH,SCRIPT>"SPECIAL" { RTOKEN(SPECIAL); }
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000312<BOTH,SCRIPT>"o" { RTOKEN(ORIGIN);}
313<BOTH,SCRIPT>"org" { RTOKEN(ORIGIN);}
314<BOTH,SCRIPT>"l" { RTOKEN( LENGTH);}
315<BOTH,SCRIPT>"len" { RTOKEN( LENGTH);}
a0b484d3 Nathan Sidwell2008-07-06 13:38:37 +0000316<EXPRESSION,BOTH,SCRIPT>"INCLUDE" { RTOKEN(INCLUDE);}
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000317<BOTH,SCRIPT>"PHDRS" { RTOKEN (PHDRS); }
92c23ae7
NC
Nick Clifton2004-11-19 09:31:55 +0000318<EXPRESSION,BOTH,SCRIPT>"AT" { RTOKEN(AT);}
319<EXPRESSION,BOTH,SCRIPT>"SUBALIGN" { RTOKEN(SUBALIGN);}
320<EXPRESSION,BOTH,SCRIPT>"PROVIDE" { RTOKEN(PROVIDE); }
ead0700b H.J. Lu2005-08-05 13:52:13 +0000321<EXPRESSION,BOTH,SCRIPT>"PROVIDE_HIDDEN" { RTOKEN(PROVIDE_HIDDEN); }
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000322<EXPRESSION,BOTH,SCRIPT>"KEEP" { RTOKEN(KEEP); }
92c23ae7 Nick Clifton2004-11-19 09:31:55 +0000323<EXPRESSION,BOTH,SCRIPT>"EXCLUDE_FILE" { RTOKEN(EXCLUDE_FILE); }
fc34748f H.J. Lu2006-05-30 16:45:32 +0000324<EXPRESSION,BOTH,SCRIPT>"CONSTANT" { RTOKEN(CONSTANT);}
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000325<MRI>"#".*\n? { ++ lineno; }
326<MRI>"\n" { ++ lineno; RTOKEN(NEWLINE); }
327<MRI>"*".* { /* Mri comment line */ }
328<MRI>";".* { /* Mri comment line */ }
329<MRI>"END" { RTOKEN(ENDWORD); }
92c23ae7
NC
Nick Clifton2004-11-19 09:31:55 +0000330<MRI>"ALIGNMOD" { RTOKEN(ALIGNMOD);}
331<MRI>"ALIGN" { RTOKEN(ALIGN_K);}
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000332<MRI>"CHIP" { RTOKEN(CHIP); }
333<MRI>"BASE" { RTOKEN(BASE); }
92c23ae7
NC
Nick Clifton2004-11-19 09:31:55 +0000334<MRI>"ALIAS" { RTOKEN(ALIAS); }
335<MRI>"TRUNCATE" { RTOKEN(TRUNCATE); }
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000336<MRI>"LOAD" { RTOKEN(LOAD); }
337<MRI>"PUBLIC" { RTOKEN(PUBLIC); }
338<MRI>"ORDER" { RTOKEN(ORDER); }
339<MRI>"NAME" { RTOKEN(NAMEWORD); }
340<MRI>"FORMAT" { RTOKEN(FORMAT); }
341<MRI>"CASE" { RTOKEN(CASE); }
342<MRI>"START" { RTOKEN(START); }
343<MRI>"LIST".* { RTOKEN(LIST); /* LIST and ignore to end of line */ }
344<MRI>"SECT" { RTOKEN(SECT); }
345<EXPRESSION,BOTH,SCRIPT,MRI>"ABSOLUTE" { RTOKEN(ABSOLUTE); }
346<MRI>"end" { RTOKEN(ENDWORD); }
92c23ae7
NC
Nick Clifton2004-11-19 09:31:55 +0000347<MRI>"alignmod" { RTOKEN(ALIGNMOD);}
348<MRI>"align" { RTOKEN(ALIGN_K);}
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000349<MRI>"chip" { RTOKEN(CHIP); }
350<MRI>"base" { RTOKEN(BASE); }
92c23ae7
NC
Nick Clifton2004-11-19 09:31:55 +0000351<MRI>"alias" { RTOKEN(ALIAS); }
352<MRI>"truncate" { RTOKEN(TRUNCATE); }
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000353<MRI>"load" { RTOKEN(LOAD); }
354<MRI>"public" { RTOKEN(PUBLIC); }
355<MRI>"order" { RTOKEN(ORDER); }
356<MRI>"name" { RTOKEN(NAMEWORD); }
357<MRI>"format" { RTOKEN(FORMAT); }
358<MRI>"case" { RTOKEN(CASE); }
359<MRI>"extern" { RTOKEN(EXTERN); }
360<MRI>"start" { RTOKEN(START); }
361<MRI>"list".* { RTOKEN(LIST); /* LIST and ignore to end of line */ }
362<MRI>"sect" { RTOKEN(SECT); }
363<EXPRESSION,BOTH,SCRIPT,MRI>"absolute" { RTOKEN(ABSOLUTE); }
364
365<MRI>{FILENAMECHAR1}{NOCFILENAMECHAR}* {
366/* Filename without commas, needed to parse mri stuff */
84c5e537 Alan Modra2003-06-28 05:28:54 +0000367 yylval.name = xstrdup (yytext);
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000368 return NAME;
369 }
370
371
746dcfd6 Nathan Sidwell2007-05-24 09:24:09 +0000372<BOTH>{FILENAMECHAR1}{FILENAMECHAR}* {
84c5e537 Alan Modra2003-06-28 05:28:54 +0000373 yylval.name = xstrdup (yytext);
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000374 return NAME;
375 }
746dcfd6
NS
Nathan Sidwell2007-05-24 09:24:09 +0000376<BOTH>"-l"{FILENAMECHAR}+ {
377 yylval.name = xstrdup (yytext + 2);
378 return LNAME;
379 }
380<EXPRESSION>{FILENAMECHAR1}{NOCFILENAMECHAR}* {
381 yylval.name = xstrdup (yytext);
382 return NAME;
383 }
384<EXPRESSION>"-l"{NOCFILENAMECHAR}+ {
8a0a249a H.J. Lu2001-05-02 16:42:55 +0000385 yylval.name = xstrdup (yytext + 2);
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000386 return LNAME;
387 }
388<SCRIPT>{WILDCHAR}* {
389 /* Annoyingly, this pattern can match comments, and we have
390 longest match issues to consider. So if the first two
391 characters are a comment opening, put the input back and
392 try again. */
393 if (yytext[0] == '/' && yytext[1] == '*')
394 {
84c5e537 Alan Modra2003-06-28 05:28:54 +0000395 yyless (2);
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000396 comment ();
397 }
398 else
399 {
84c5e537 Alan Modra2003-06-28 05:28:54 +0000400 yylval.name = xstrdup (yytext);
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000401 return NAME;
402 }
403 }
404
405<EXPRESSION,BOTH,SCRIPT,VERS_NODE>"\""[^\"]*"\"" {
406 /* No matter the state, quotes
407 give what's inside */
84c5e537
AM
Alan Modra2003-06-28 05:28:54 +0000408 yylval.name = xstrdup (yytext + 1);
409 yylval.name[yyleng - 2] = 0;
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000410 return NAME;
411 }
412<BOTH,SCRIPT,EXPRESSION>"\n" { lineno++;}
413<MRI,BOTH,SCRIPT,EXPRESSION>[ \t\r]+ { }
414
415<VERS_NODE,VERS_SCRIPT>[:,;] { return *yytext; }
416
417<VERS_NODE>global { RTOKEN(GLOBAL); }
418
419<VERS_NODE>local { RTOKEN(LOCAL); }
420
421<VERS_NODE>extern { RTOKEN(EXTERN); }
422
8a0a249a H.J. Lu2001-05-02 16:42:55 +0000423<VERS_NODE>{V_IDENTIFIER} { yylval.name = xstrdup (yytext);
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000424 return VERS_IDENTIFIER; }
425
8a0a249a H.J. Lu2001-05-02 16:42:55 +0000426<VERS_SCRIPT>{V_TAG} { yylval.name = xstrdup (yytext);
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000427 return VERS_TAG; }
428
429<VERS_START>"{" { BEGIN(VERS_SCRIPT); return *yytext; }
430
84c5e537 Alan Modra2003-06-28 05:28:54 +0000431<VERS_SCRIPT>"{" { BEGIN(VERS_NODE);
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000432 vers_node_nesting = 0;
433 return *yytext;
434 }
435<VERS_SCRIPT>"}" { return *yytext; }
436<VERS_NODE>"{" { vers_node_nesting++; return *yytext; }
437<VERS_NODE>"}" { if (--vers_node_nesting < 0)
438 BEGIN(VERS_SCRIPT);
439 return *yytext;
440 }
441
442<VERS_START,VERS_NODE,VERS_SCRIPT>[\n] { lineno++; }
443
444<VERS_START,VERS_NODE,VERS_SCRIPT>#.* { /* Eat up comments */ }
445
446<VERS_START,VERS_NODE,VERS_SCRIPT>[ \t\r]+ { /* Eat up whitespace */ }
447
448<<EOF>> {
449 include_stack_ptr--;
84c5e537
AM
Alan Modra2003-06-28 05:28:54 +0000450
451 if (include_stack_ptr == 0)
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000452 {
84c5e537 Alan Modra2003-06-28 05:28:54 +0000453 yyterminate ();
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000454 }
84c5e537 Alan Modra2003-06-28 05:28:54 +0000455 else
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000456 {
84c5e537 Alan Modra2003-06-28 05:28:54 +0000457 yy_switch_to_buffer (include_stack[include_stack_ptr]);
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000458 }
c377c93b Alan Modra2001-10-20 13:49:00 +0000459
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000460 ldfile_input_filename = file_name_stack[include_stack_ptr - 1];
c377c93b Alan Modra2001-10-20 13:49:00 +0000461 lineno = lineno_stack[include_stack_ptr];
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000462
463 return END;
464}
465
84c5e537
AM
Alan Modra2003-06-28 05:28:54 +0000466<SCRIPT,MRI,VERS_START,VERS_SCRIPT,VERS_NODE>. lex_warn_invalid (" in script", yytext);
467<EXPRESSION,DEFSYMEXP,BOTH>. lex_warn_invalid (" in expression", yytext);
468
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000469%%
470\f
471
472/* Switch flex to reading script file NAME, open on FILE,
473 saving the current input info on the include stack. */
474
475void
84c5e537 Alan Modra2003-06-28 05:28:54 +0000476lex_push_file (FILE *file, const char *name)
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000477{
84c5e537 Alan Modra2003-06-28 05:28:54 +0000478 if (include_stack_ptr >= MAX_INCLUDE_DEPTH)
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000479 {
84c5e537 Alan Modra2003-06-28 05:28:54 +0000480 einfo ("%F:includes nested too deeply\n");
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000481 }
482 file_name_stack[include_stack_ptr] = name;
c377c93b Alan Modra2001-10-20 13:49:00 +0000483 lineno_stack[include_stack_ptr] = lineno;
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000484 include_stack[include_stack_ptr] = YY_CURRENT_BUFFER;
485
486 include_stack_ptr++;
c377c93b Alan Modra2001-10-20 13:49:00 +0000487 lineno = 1;
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000488 yyin = file;
84c5e537 Alan Modra2003-06-28 05:28:54 +0000489 yy_switch_to_buffer (yy_create_buffer (yyin, YY_BUF_SIZE));
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000490}
491
492/* Return a newly created flex input buffer containing STRING,
493 which is SIZE bytes long. */
494
84c5e537
AM
Alan Modra2003-06-28 05:28:54 +0000495static YY_BUFFER_STATE
496yy_create_string_buffer (const char *string, size_t size)
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000497{
498 YY_BUFFER_STATE b;
499
500 /* Calls to m-alloc get turned by sed into xm-alloc. */
84c5e537 Alan Modra2003-06-28 05:28:54 +0000501 b = malloc (sizeof (struct yy_buffer_state));
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000502 b->yy_input_file = 0;
503 b->yy_buf_size = size;
504
505 /* yy_ch_buf has to be 2 characters longer than the size given because
506 we need to put in 2 end-of-buffer characters. */
84c5e537 Alan Modra2003-06-28 05:28:54 +0000507 b->yy_ch_buf = malloc ((unsigned) (b->yy_buf_size + 3));
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000508
509 b->yy_ch_buf[0] = '\n';
510 strcpy (b->yy_ch_buf+1, string);
511 b->yy_ch_buf[size+1] = YY_END_OF_BUFFER_CHAR;
512 b->yy_ch_buf[size+2] = YY_END_OF_BUFFER_CHAR;
513 b->yy_n_chars = size+1;
514 b->yy_buf_pos = &b->yy_ch_buf[1];
515
c12eea48
AM
Alan Modra2000-11-05 06:27:15 +0000516 b->yy_is_our_buffer = 1;
517 b->yy_is_interactive = 0;
518 b->yy_at_bol = 1;
519 b->yy_fill_buffer = 0;
520
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000521 /* flex 2.4.7 changed the interface. FIXME: We should not be using
522 a flex internal interface in the first place! */
523#ifdef YY_BUFFER_NEW
524 b->yy_buffer_status = YY_BUFFER_NEW;
525#else
526 b->yy_eof_status = EOF_NOT_SEEN;
527#endif
528
529 return b;
530}
531
532/* Switch flex to reading from STRING, saving the current input info
533 on the include stack. */
534
535void
84c5e537 Alan Modra2003-06-28 05:28:54 +0000536lex_redirect (const char *string)
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000537{
538 YY_BUFFER_STATE tmp;
539
540 yy_init = 0;
84c5e537 Alan Modra2003-06-28 05:28:54 +0000541 if (include_stack_ptr >= MAX_INCLUDE_DEPTH)
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000542 {
543 einfo("%F: macros nested too deeply\n");
544 }
545 file_name_stack[include_stack_ptr] = "redirect";
c377c93b Alan Modra2001-10-20 13:49:00 +0000546 lineno_stack[include_stack_ptr] = lineno;
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000547 include_stack[include_stack_ptr] = YY_CURRENT_BUFFER;
548 include_stack_ptr++;
c377c93b Alan Modra2001-10-20 13:49:00 +0000549 lineno = 1;
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000550 tmp = yy_create_string_buffer (string, strlen (string));
551 yy_switch_to_buffer (tmp);
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000552}
553\f
554/* Functions to switch to a different flex start condition,
555 saving the current start condition on `state_stack'. */
556
557static int state_stack[MAX_INCLUDE_DEPTH * 2];
558static int *state_stack_p = state_stack;
559
560void
84c5e537 Alan Modra2003-06-28 05:28:54 +0000561ldlex_script (void)
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000562{
563 *(state_stack_p)++ = yy_start;
564 BEGIN (SCRIPT);
565}
566
567void
84c5e537 Alan Modra2003-06-28 05:28:54 +0000568ldlex_mri_script (void)
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000569{
570 *(state_stack_p)++ = yy_start;
571 BEGIN (MRI);
572}
573
574void
84c5e537 Alan Modra2003-06-28 05:28:54 +0000575ldlex_version_script (void)
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000576{
577 *(state_stack_p)++ = yy_start;
578 BEGIN (VERS_START);
579}
580
581void
84c5e537 Alan Modra2003-06-28 05:28:54 +0000582ldlex_version_file (void)
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000583{
584 *(state_stack_p)++ = yy_start;
585 BEGIN (VERS_SCRIPT);
586}
587
588void
84c5e537 Alan Modra2003-06-28 05:28:54 +0000589ldlex_defsym (void)
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000590{
591 *(state_stack_p)++ = yy_start;
592 BEGIN (DEFSYMEXP);
593}
84c5e537 Alan Modra2003-06-28 05:28:54 +0000594
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000595void
84c5e537 Alan Modra2003-06-28 05:28:54 +0000596ldlex_expression (void)
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000597{
598 *(state_stack_p)++ = yy_start;
599 BEGIN (EXPRESSION);
600}
601
602void
84c5e537 Alan Modra2003-06-28 05:28:54 +0000603ldlex_both (void)
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000604{
605 *(state_stack_p)++ = yy_start;
606 BEGIN (BOTH);
607}
608
609void
84c5e537 Alan Modra2003-06-28 05:28:54 +0000610ldlex_popstate (void)
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000611{
612 yy_start = *(--state_stack_p);
613}
614\f
615
0340e939 Andreas Schwab2009-10-14 10:54:27 +0000616/* Place up to MAX_SIZE characters in BUF and return
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000617 either the number of characters read, or 0 to indicate EOF. */
618
0340e939
AS
Andreas Schwab2009-10-14 10:54:27 +0000619static int
620yy_input (char *buf, int max_size)
aa2289c2 Richard Henderson1999-05-03 07:29:11 +0000621{
0340e939 Andreas Schwab2009-10-14 10:54:27 +0000622 int result = 0;
f15e574c H.J. Lu2003-04-15 14:50:29 +0000623 if (YY_CURRENT_BUFFER->yy_input_file)
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000624 {
625 if (yyin)
626 {
0340e939
AS
Andreas Schwab2009-10-14 10:54:27 +0000627 result = fread (buf, 1, max_size, yyin);
628 if (result < max_size && ferror (yyin))
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000629 einfo ("%F%P: read in flex scanner failed\n");
630 }
631 }
0340e939 Andreas Schwab2009-10-14 10:54:27 +0000632 return result;
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000633}
634
635/* Eat the rest of a C-style comment. */
636
637static void
84c5e537 Alan Modra2003-06-28 05:28:54 +0000638comment (void)
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000639{
640 int c;
641
642 while (1)
643 {
644 c = input();
84c5e537 Alan Modra2003-06-28 05:28:54 +0000645 while (c != '*' && c != EOF)
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000646 {
647 if (c == '\n')
648 lineno++;
649 c = input();
650 }
651
652 if (c == '*')
653 {
654 c = input();
655 while (c == '*')
656 c = input();
657 if (c == '/')
658 break; /* found the end */
659 }
660
661 if (c == '\n')
662 lineno++;
663
664 if (c == EOF)
665 {
666 einfo( "%F%P: EOF in comment\n");
667 break;
668 }
669 }
670}
671
672/* Warn the user about a garbage character WHAT in the input
673 in context WHERE. */
674
675static void
84c5e537 Alan Modra2003-06-28 05:28:54 +0000676lex_warn_invalid (char *where, char *what)
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000677{
678 char buf[5];
679
680 /* If we have found an input file whose format we do not recognize,
681 and we are therefore treating it as a linker script, and we find
682 an invalid character, then most likely this is a real object file
683 of some different format. Treat it as such. */
684 if (ldfile_assumed_script)
685 {
686 bfd_set_error (bfd_error_file_not_recognized);
687 einfo ("%F%s: file not recognized: %E\n", ldfile_input_filename);
688 }
689
75e56203 H.J. Lu2001-09-19 05:33:36 +0000690 if (! ISPRINT (*what))
aa2289c2
RH
Richard Henderson1999-05-03 07:29:11 +0000691 {
692 sprintf (buf, "\\%03o", (unsigned int) *what);
693 what = buf;
694 }
695
696 einfo ("%P:%S: ignoring invalid character `%s'%s\n", what, where);
697}