Hi Tristan,
thank you for the very quick checkins of my bugfixes.
> thank you for this bug fix. I was aware of this issue on x86-64,
> but miss this call.
Yeah and I missed one too :)
There's a call to snprintf in Grt.Rtis_Utils.Get_Value. It currently
works by sheer luck, because Type_Rti.Kind ends up in %eax, then gcc
subtracts 0x16 from %eax, and then it calls snprintf. This means at the
call to snprintf, %al contains 5, which is in the allowed range and at
least 1 to copy the used %xmm0 register to the vararg structure.
But should the register allocation order or the exact jump table
implementation ever change in gcc, we risk segfaults.
Would be nice if you could check this in as well.
Thanks and have a nice new year's eve!
Tom
--- gcc/vhdl/grt/grt-cbinding.c.orig 2009-12-30 17:00:41.000000000 +0100
+++ gcc/vhdl/grt/grt-cbinding.c 2009-12-30 17:05:07.000000000 +0100
@@ -37,6 +37,16 @@
return stderr;
}
+int
+__ghdl_snprintf_g (char *buf, unsigned int len, double val)
+{
+ /*
+ * Warning: this assumes a C99 snprintf (ie, it returns the
+ * number of characters).
+ */
+ return snprintf (buf, len, "%g", val);
+}
+
void
__ghdl_fprintf_g (FILE *stream, double val)
{
--- gcc/vhdl/grt/grt-rtis_utils.adb.orig 2009-12-30 17:00:50.000000000
+0100
+++ gcc/vhdl/grt/grt-rtis_utils.adb 2009-12-30 17:04:26.000000000 +0100
@@ -450,16 +450,14 @@
L : Integer;
-- Warning: this assumes a C99 snprintf (ie, it returns the
-- number of characters).
- function snprintf (Cstr : Address;
- Size : Natural;
- Template : Address;
- Arg : Ghdl_F64)
+ function Snprintf_G (Cstr : Address;
+ Size : Natural;
+ Arg : Ghdl_F64)
return Integer;
- pragma Import (C, snprintf);
+ pragma Import (C, Snprintf_G, "__ghdl_snprintf_g");
- Format : constant String := "%g" & Character'Val (0);
begin
- L := snprintf (S'Address, S'Length, Format'Address, Value.F64);
+ L := Snprintf_G (S'Address, S'Length, Value.F64);
if L < 0 then
-- FIXME.
Append (Str, "?");
_______________________________________________
Ghdl-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/ghdl-discuss