aboutsummaryrefslogtreecommitdiff
path: root/ld/ldlex.l
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2012-02-17 14:09:57 +0000
committerAlan Modra <amodra@gmail.com>2012-02-17 14:09:57 +0000
commitdab69f680baf93b577f85c1a9344d7ea7996f466 (patch)
treed39b8e854f707ee6bd0dba8e73c3a8d79cd1ae22 /ld/ldlex.l
parent9e507076870544c11dc3711e836d6803f30e7658 (diff)
downloadgdb-dab69f680baf93b577f85c1a9344d7ea7996f466.zip
gdb-dab69f680baf93b577f85c1a9344d7ea7996f466.tar.gz
gdb-dab69f680baf93b577f85c1a9344d7ea7996f466.tar.bz2
PR ld/13343
* ld.h (parsing_defsym): Delete. * ldexp.c (exp_intop, exp_bigintop, exp_relop): Set type.filename. (fold_binary, fold_name, exp_fold_tree_1, exp_get_vma, exp_get_fill, exp_get_abs_int): Add tree arg for %S in error messages. Don't fudge lineno. (exp_binop, exp_unop, exp_nameop, exp_assop, exp_assert): Copy type.filename from sub-tree. (exp_trinop): Likewise, and use "cond" rather than "lhs". * ldexp.h (node_type): Add filename field to struct. * ldfile.c (ldfile_input_filename): Delete. Remove all refs. * ldfile.h (ldfile_input_filename): Delete. * ldgram.y (phdr_type, phdr_qualifiers, yyerror): Add NULL arg for %S in error messages. * ldemul.c (syslib_default, hll_default): Likewise. * ldlang.c (lang_memory_region_lookup, lang_memory_region_alias, lang_get_regions, lang_new_phdr): Likewise. (lang_size_sections_1): Pass addr_tree for %S. * ldlex.h (lex_redirect): Update prototype. (ldlex_filename): Declare. * ldlex.l (<EOF>): Don't set ldfile_input_filename. (lex_redirect): Add fake_filename and count params. Push fake_filename to file_name_stack and init lineno from count. (ldlex_filename): New function. (lex_warn_invalid): Use above. * ldmain.c (main): Update lex_redirect call. * ldmisc.c (vfinfo <%S>): Take file name and line number from etree_type arg, or use current if arg is NULL. * lexsup.c (parsing_defsym): Delete. (parse_args <OPTION_DEFSYM>): Update lex_redirect call.
Diffstat (limited to 'ld/ldlex.l')
-rw-r--r--ld/ldlex.l27
1 files changed, 15 insertions, 12 deletions
diff --git a/ld/ldlex.l b/ld/ldlex.l
index 4e859b0..33dd83d 100644
--- a/ld/ldlex.l
+++ b/ld/ldlex.l
@@ -3,7 +3,7 @@
%{
/* Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+ 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
Written by Steve Chamberlain of Cygnus Support.
@@ -448,17 +448,11 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
<<EOF>> {
include_stack_ptr--;
-
if (include_stack_ptr == 0)
- {
yyterminate ();
- }
else
- {
yy_switch_to_buffer (include_stack[include_stack_ptr]);
- }
- ldfile_input_filename = file_name_stack[include_stack_ptr - 1];
lineno = lineno_stack[include_stack_ptr];
return END;
@@ -534,7 +528,7 @@ yy_create_string_buffer (const char *string, size_t size)
on the include stack. */
void
-lex_redirect (const char *string)
+lex_redirect (const char *string, const char *fake_filename, unsigned int count)
{
YY_BUFFER_STATE tmp;
@@ -543,11 +537,11 @@ lex_redirect (const char *string)
{
einfo("%F: macros nested too deeply\n");
}
- file_name_stack[include_stack_ptr] = "redirect";
+ file_name_stack[include_stack_ptr] = fake_filename;
lineno_stack[include_stack_ptr] = lineno;
include_stack[include_stack_ptr] = YY_CURRENT_BUFFER;
include_stack_ptr++;
- lineno = 1;
+ lineno = count;
tmp = yy_create_string_buffer (string, strlen (string));
yy_switch_to_buffer (tmp);
}
@@ -612,6 +606,15 @@ ldlex_popstate (void)
{
yy_start = *(--state_stack_p);
}
+
+/* Return the current file name, or the previous file if no file is
+ current. */
+
+const char*
+ldlex_filename (void)
+{
+ return file_name_stack[include_stack_ptr - (include_stack_ptr != 0)];
+}
/* Place up to MAX_SIZE characters in BUF and return
@@ -685,7 +688,7 @@ lex_warn_invalid (char *where, char *what)
if (ldfile_assumed_script)
{
bfd_set_error (bfd_error_file_not_recognized);
- einfo ("%F%s: file not recognized: %E\n", ldfile_input_filename);
+ einfo ("%F%s: file not recognized: %E\n", ldlex_filename ());
}
if (! ISPRINT (*what))
@@ -694,5 +697,5 @@ lex_warn_invalid (char *where, char *what)
what = buf;
}
- einfo ("%P:%S: ignoring invalid character `%s'%s\n", what, where);
+ einfo ("%P:%S: ignoring invalid character `%s'%s\n", NULL, what, where);
}