Date: Thu, 6 Jun 2002 15:49:17 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: "David O'Brien" <obrien@FreeBSD.org> Cc: cvs-committers@FreeBSD.org, <cvs-all@FreeBSD.org> Subject: Re: cvs commit: src UPDATING Message-ID: <20020606154302.O10454-100000@gamplex.bde.org> In-Reply-To: <20020606143319.V10309-100000@gamplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 6 Jun 2002, Bruce Evans wrote:
> Perhaps. It seems to be caused by a very funny bug in printf or scanf or
> in related functions in gcc.
>
> > $ cat foo.c
> > int main(void) { return 0; }
> > $ /usr/bin/cc -gstabs+ foo.c
> > $ ./a.out
> > $ /usr/bin/cc -S -gstabs+ foo.c
> > $ cat foo.s
> > .file "foo.c"
> > ..snip..
> > .stabs "",100,0,0,nantext
> > nantext:
>
> "nan" here seems to be be for misparsing ".Letext" as "nan" (numeric
> Not a Number). I get "nan" for the label in the stabs line and
> "-inftext" for the label itself. "-inf" seems to be for misparsing
> something as numeric -Infinity. The bogus label "-inftext" causes
> only a warning from the assembler. Linkage fails later because there
> is no label "nantext".
The cause of the bug is less interesting than the bug. It is just two
%L's in an unchecked format string interpreting stack garbage as long
doubles.
The following seems to be the correct fix:
%%%
Index: freebsd.h
===================================================================
RCS file: /home/ncvs/src/contrib/gcc/config/i386/freebsd.h,v
retrieving revision 1.49
diff -u -2 -r1.49 freebsd.h
--- freebsd.h 12 May 2002 17:31:12 -0000 1.49
+++ freebsd.h 6 Jun 2002 05:20:41 -0000
@@ -399,5 +400,6 @@
do { \
if (TARGET_ELF) { \
- fprintf ((FILE), "\t.text\n\t.stabs \"\",%d,0,0,%LLetext\n%LLetext:\n", \
+ asm_fprintf ((FILE), \
+ "\t.text\n\t.stabs \"\",%d,0,0,%LLetext\n%LLetext:\n", \
N_SO); \
} \
%%%
%L in asm_fprintf() just just produces "." here. Perhaps asm_printf()
should be used in other places that add a target-dependent prefix. It
isn't used much, and couldn't be format-checked easily, since its %L
and probably other format specifiers conflict with the standard printf
ones.
Bruce
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020606154302.O10454-100000>
