This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: mudflap: how do I give size for 'void *' objects? - example
- From: Eyal Lebedinsky <eyal at eyal dot emu dot id dot au>
- To: "list, gcc" <gcc at gcc dot gnu dot org>, "Eigler, Frank Ch." <fche at redhat dot com>
- Date: Sat, 05 Apr 2003 16:26:41 +1000
- Subject: Re: mudflap: how do I give size for 'void *' objects? - example
- Organization: Eyal at Home
- References: <3E8CCC43.3F317393@eyal.emu.id.au>
Eyal Lebedinsky wrote:
>
> I have a problem where I get a large number of reported violations
> when accessing objects acquired through something like
> p = shmat()
> where the size of the object is unknown (unless mudflap uses
> extra internal knowledge).
Here is a simple program that demonstrates the problem with ctime().
Note how the fprintf() works OK (no violation) but the strlen()
fails. I assume that mudflap has its own strlen() wrapper that
trips on the "foreign" pointer returned from ctime().
-----------------------------------------------------
#!/bin/sh
mf="/usr/local/gcc-mudflap"
cat >zz.c <<EOF
#include <stdio.h>
#include <time.h>
#include <string.h>
int main ()
{
time_t t;
char *p;
int l;
t = time (NULL);
p = ctime (&t);
fprintf (stderr, "%s", p);
l = (int)strlen (p);
return (0);
}
EOF
export LD_LIBRARY_PATH="$mf/lib"
cc="$mf/bin/i686-pc-linux-gnu-gcc-3.5-tree-ssa -fmudflap -g -O0"
#cc="gcc"
test -f zz && rm zz
$cc -Wall -o zz zz.c
./zz
-----------------------------------------------------
--
Eyal Lebedinsky (eyal at eyal dot emu dot id dot au) <http://samba.org/eyal/>