This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: trouble with INCLUDE in linker command files
- To: Guy dot McCarthy at microchip dot com
- Subject: Re: trouble with INCLUDE in linker command files
- From: Alan Modra <amodra at bigpond dot net dot au>
- Date: Wed, 17 Oct 2001 11:47:13 +0930
- Cc: binutils at sourceware dot cygnus dot com
- References: <OFB7860B5D.FEFC4087-ON07256AE7.0079C1C4@microchip.com>
On Tue, Oct 16, 2001 at 03:12:37PM -0700, Guy.McCarthy@microchip.com wrote:
> There appears to be a bug in ld having to do with INCLUDE in linker
> command files. I am using binutils v2.11.2 with a target of
> i386-pc-cygwin.
I think this will fix the problem. Can someone familiar with lex and yacc
check that I'm DTRT?
* ldgram.y (mri_script_command): Surround processing of INCLUDE
with ldlex_script, ldlex_popstate.
(ifile_p1): Likewise.
* ldlex.l (EOF): Don't BEGIN(SCRIPT). Restore lineno from the
correct slot.
(lex_push_file): Save current lineno to lineno_stack. Set lineno
to 1. Don't BEGIN(SCRIPT).
(lex_redirect): Similarly.
* ldmain.c (main): Set yydebug non-zero if YYDEBUG.
--
Alan Modra
Index: ld/ldgram.y
===================================================================
RCS file: /cvs/src/src/ld/ldgram.y,v
retrieving revision 1.14
diff -u -p -r1.14 ldgram.y
--- ldgram.y 2001/09/29 12:57:54 1.14
+++ ldgram.y 2001/10/17 02:02:54
@@ -238,7 +238,9 @@ mri_script_command:
| CASE casesymlist
| EXTERN extern_name_list
| INCLUDE filename
- { ldfile_open_command_file ($2); } mri_script_lines END
+ { ldlex_script (); ldfile_open_command_file($2); }
+ mri_script_lines END
+ { ldlex_popstate (); }
| START NAME
{ lang_add_entry ($2, false); }
|
@@ -332,7 +334,9 @@ ifile_p1:
| MAP '(' filename ')'
{ lang_add_map($3); }
| INCLUDE filename
- { ldfile_open_command_file($2); } ifile_list END
+ { ldlex_script (); ldfile_open_command_file($2); }
+ ifile_list END
+ { ldlex_popstate (); }
| NOCROSSREFS '(' nocrossref_list ')'
{
lang_add_nocrossref ($3);
Index: ld/ldlex.l
===================================================================
RCS file: /cvs/src/src/ld/ldlex.l,v
retrieving revision 1.7
diff -u -p -r1.7 ldlex.l
--- ldlex.l 2001/09/29 12:57:54 1.7
+++ ldlex.l 2001/10/17 02:02:55
@@ -418,11 +418,10 @@ V_IDENTIFIER [*?.$_a-zA-Z]([*?.$_a-zA-Z0
else
{
yy_switch_to_buffer(include_stack[include_stack_ptr]);
-
}
- BEGIN(SCRIPT);
+
ldfile_input_filename = file_name_stack[include_stack_ptr - 1];
- lineno = lineno_stack[include_stack_ptr - 1];
+ lineno = lineno_stack[include_stack_ptr];
return END;
}
@@ -446,13 +445,13 @@ lex_push_file (file, name)
einfo("%F:includes nested too deeply\n");
}
file_name_stack[include_stack_ptr] = name;
- lineno_stack[include_stack_ptr] = 1;
+ lineno_stack[include_stack_ptr] = lineno;
include_stack[include_stack_ptr] = YY_CURRENT_BUFFER;
include_stack_ptr++;
+ lineno = 1;
yyin = file;
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
- BEGIN (SCRIPT);
}
/* Return a newly created flex input buffer containing STRING,
@@ -512,12 +511,12 @@ lex_redirect (string)
einfo("%F: macros nested too deeply\n");
}
file_name_stack[include_stack_ptr] = "redirect";
- lineno_stack[include_stack_ptr] = 0;
+ lineno_stack[include_stack_ptr] = lineno;
include_stack[include_stack_ptr] = YY_CURRENT_BUFFER;
include_stack_ptr++;
+ lineno = 1;
tmp = yy_create_string_buffer (string, strlen (string));
yy_switch_to_buffer (tmp);
- BEGIN (SCRIPT);
}
/* Functions to switch to a different flex start condition,
Index: ld/ldmain.c
===================================================================
RCS file: /cvs/src/src/ld/ldmain.c,v
retrieving revision 1.35
diff -u -p -r1.35 ldmain.c
--- ldmain.c 2001/09/29 12:57:54 1.35
+++ ldmain.c 2001/10/17 02:02:55
@@ -196,6 +196,13 @@ main (argc, argv)
xexit (1);
}
+#if YYDEBUG
+ {
+ extern int yydebug;
+ yydebug = 1;
+ }
+#endif
+
/* Initialize the data about options. */
trace_files = trace_file_tries = version_printed = false;
whole_archive = false;