public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* specs parser changed?
@ 2005-09-21 14:57 Ludo Van Put
  0 siblings, 0 replies; only message in thread
From: Ludo Van Put @ 2005-09-21 14:57 UTC (permalink / raw)
  To: gcc-help

We need to distinguish between handwritten assembler and compiled code 
in order to make assumptions on the behaviour of the code in our 
link-time optimizer (http://www.elis.ugent.be/diablo). We want to know 
if a certain piece of code adheres to calling conventions etc.

In the past we patched the default invoke_as spec in gcc/gcc.c as 
follows to do it:

static const char *invoke_as =
-"%{!S:-o %{|!pipe:%g.s} |\n as %(asm_options) %{!pipe:%g.s} %A }";
+"%{!S:-o %{|!pipe:%g.s} |\n\
+%{!pipe:perl -e open(I,\"<%g.s\");open(X,\">%g.sa\");\
+while(<I>){print\\ X\\ $_;\
+print\\ X\\ \"\\\\$compiler$i:\\\\n\"\\ if\\ /^.NO_APP/;\
+print\\ X\\ \"\\\\$handwritten$i:\\\\n\"\\ if\\ /^.APP/;\
+$i++;}close(I);close(X);rename(\"%g.sa\",\"%g.s\"); }\n\
+%{pipe:perl -e while(<>){print;\
+print\\ \"\\\\$compiler$i:\\\\n\"\\ if\\ /^.NO_APP/;\
+print\\ \"\\\\$handwritten$i:\\\\n\"\\ if\\ /^.APP/;\
+$i++;} } |\n\
+as %(asm_options) %{!pipe:%g.s} %A }";

This runs the compiler output through perl and inserts textual symbols 
in the assembly. This way the assembler later on inserts the necessary 
symbols in the output file.

In gcc-4.0.1 this patch doesn't work anymore. In gcc/gcc.c this now 
looks like:

static const char *invoke_as =
#ifdef AS_NEEDS_DASH_FOR_PIPED_INPUT
"%{!S:-o %|.s |\n\
%{!pipe:perl -e open(I,\"<%g.s\");open(X,\">%g.sa\");\
while(<I>){print\\ X\\ $_;\
print\\ X\\ \"\\\\$compiler$i:\\\\n\"\\ if\\ /^.NO_APP/;\
print\\ X\\ \"\\\\$handwritten$i:\\\\n\"\\ if\\ /^.APP/;\
$i++;}close(I);close(X);rename(\"%g.sa\",\"%g.s\"); }\n\
%{pipe:perl -e while(<>){print;\
print\\ \"\\\\$compiler$i:\\\\n\"\\ if\\ /^.NO_APP/;\
print\\ \"\\\\$handwritten$i:\\\\n\"\\ if\\ /^.APP/;\
$i++;} } |\n\
as %(asm_options) %|.s %A }";
#else
"%{!S:-o %|.s |\n as %(asm_options) %m.s %A }";
#endif

After a configure:

../configure --host=i686-pc-linux-gnu --target=i686-linux 
--disable-threads --enable-languages=c 
--prefix=/export/home/lvanput/architectures/ia32/b216
_gc401_gl235/ --disable-shared


and make, I get this error message:

xgcc: braced spec '!pipe:perl -e 
open(I,"<%g.s");open(X,">%g.sa");while(<I>){print\ X\ $_;print\ X\ 
"\\$compiler$i:\\n"\ if\ /^.NO_APP/;print\ X\ "\\$handwritten$i:\\n"\ 
if\ /^.APP/;$i++;}close(I);close(X);rename("%g.sa","%g.s"); }
%{pipe:perl -e while(<>){print;print\ "\\$compiler$i:\\n"\ if\ 
/^.NO_APP/;print\ "\\$handwritten$i:\\n"\ if\ /^.APP/;$i++;} } |
as %(asm_options) %|.s %A' is invalid at '('


This previously worked for gcc-3.3.2. From the documentation I 
understood that the specs substition rules have been extended and that 
';' has a special meaning inside %{}

Does anyone knows how to work around this problem?
Or even better, does anyone knows how to patch the GNU assembler to emit 
symbols when it reads in #APP and #NO_APP?

Thanks in advance,

Ludo Van Put

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-09-21 14:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-21 14:57 specs parser changed? Ludo Van Put

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).