This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

specs parser changed?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]