Commit 891a2e42 by Rainer Orth Committed by Rainer Orth

re PR libmudflap/49550 (Many libmudflap tests fail on Solaris 11/x86)

	gcc:
	PR libmudflap/49550
	* gcc.c (MFWRAP_SPEC): Also wrap mmap64.

	libmudflap:
	PR libmudflap/49550
	* mf-runtime.c (__wrap_main) [__sun__ && __svr4__]: Don't register
	stdin, stdout, stderr.
	Register __ctype, __ctype_mask.

	* configure.ac: Check for mmap64.
	Check for rawmemchr, stpcpy, mempcpy.
	* configure: Regenerate.
	* config.h.in: Regenerate.
	* mf-hooks1.c [HAVE_MMAP64] (__mf_0fn_mmap64): New function.
	(mmap64): New wrapper function.
	* mf-impl.h (__mf_dynamic_index) [HAVE_MMAP64]: Add dyn_mmap64.
	* mf-runtime.c (__mf_dynamic) [HAVE_MMAP64]: Handle mmap64.

	* mf-hooks2.c [HAVE_GETMNTENT && HAVE_SYS_MNTTAB_H]: Implement
	getmntent wrapper.

	* mf-hooks3.c (_REENTRANT): Define.

	* testsuite/libmudflap.c/heap-scalestress.c (SCALE): Reduce to 10000.

	* testsuite/libmudflap.c/pass-stratcliff.c: Include ../config.h.
	(MIN): Define.
	Use HAVE_RAWMEMCHR, HAVE_STPCPY, HAVE_MEMPCPY as guards.

	* testsuite/libmudflap.c/pass47-frag.c: Expect __ctype warning on
	*-*-solaris2.*.

From-SVN: r175961
parent 8384ac41
2011-07-07 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2011-07-07 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR libmudflap/49550
* gcc.c (MFWRAP_SPEC): Also wrap mmap64.
2011-07-07 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR target/39150 PR target/39150
* configure.ac (gcc_cv_as_hidden): Also accept * configure.ac (gcc_cv_as_hidden): Also accept
x86_64-*-solaris2.1[0-9]*. x86_64-*-solaris2.1[0-9]*.
......
...@@ -518,7 +518,7 @@ proper position among the other output files. */ ...@@ -518,7 +518,7 @@ proper position among the other output files. */
/* XXX: should exactly match hooks provided by libmudflap.a */ /* XXX: should exactly match hooks provided by libmudflap.a */
#define MFWRAP_SPEC " %{static: %{fmudflap|fmudflapth: \ #define MFWRAP_SPEC " %{static: %{fmudflap|fmudflapth: \
--wrap=malloc --wrap=free --wrap=calloc --wrap=realloc\ --wrap=malloc --wrap=free --wrap=calloc --wrap=realloc\
--wrap=mmap --wrap=munmap --wrap=alloca\ --wrap=mmap --wrap=mmap64 --wrap=munmap --wrap=alloca\
} %{fmudflapth: --wrap=pthread_create\ } %{fmudflapth: --wrap=pthread_create\
}} %{fmudflap|fmudflapth: --wrap=main}" }} %{fmudflap|fmudflapth: --wrap=main}"
#endif #endif
......
2011-07-07 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR libmudflap/49550
* mf-runtime.c (__wrap_main) [__sun__ && __svr4__]: Don't register
stdin, stdout, stderr.
Register __ctype, __ctype_mask.
* configure.ac: Check for mmap64.
Check for rawmemchr, stpcpy, mempcpy.
* configure: Regenerate.
* config.h.in: Regenerate.
* mf-hooks1.c [HAVE_MMAP64] (__mf_0fn_mmap64): New function.
(mmap64): New wrapper function.
* mf-impl.h (__mf_dynamic_index) [HAVE_MMAP64]: Add dyn_mmap64.
* mf-runtime.c (__mf_dynamic) [HAVE_MMAP64]: Handle mmap64.
* mf-hooks2.c [HAVE_GETMNTENT && HAVE_SYS_MNTTAB_H]: Implement
getmntent wrapper.
* mf-hooks3.c (_REENTRANT): Define.
* testsuite/libmudflap.c/heap-scalestress.c (SCALE): Reduce to 10000.
* testsuite/libmudflap.c/pass-stratcliff.c: Include ../config.h.
(MIN): Define.
Use HAVE_RAWMEMCHR, HAVE_STPCPY, HAVE_MEMPCPY as guards.
* testsuite/libmudflap.c/pass47-frag.c: Expect __ctype warning on
*-*-solaris2.*.
2011-07-01 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2011-07-01 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR libmudflap/49549 PR libmudflap/49549
......
...@@ -126,18 +126,27 @@ ...@@ -126,18 +126,27 @@
/* Define to 1 if you have the `dl' library (-ldl). */ /* Define to 1 if you have the `dl' library (-ldl). */
#undef HAVE_LIBDL #undef HAVE_LIBDL
/* Define to 1 if you have the `socket' library (-lsocket). */
#undef HAVE_LIBSOCKET
/* Define to 1 if you have the `memmem' function. */ /* Define to 1 if you have the `memmem' function. */
#undef HAVE_MEMMEM #undef HAVE_MEMMEM
/* Define to 1 if you have the <memory.h> header file. */ /* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H #undef HAVE_MEMORY_H
/* Define to 1 if you have the `mempcpy' function. */
#undef HAVE_MEMPCPY
/* Define to 1 if you have the `memrchr' function. */ /* Define to 1 if you have the `memrchr' function. */
#undef HAVE_MEMRCHR #undef HAVE_MEMRCHR
/* Define to 1 if you have the `mmap' function. */ /* Define to 1 if you have the `mmap' function. */
#undef HAVE_MMAP #undef HAVE_MMAP
/* Define to 1 if you have the `mmap64' function. */
#undef HAVE_MMAP64
/* Define to 1 if you have the <mntent.h> header file. */ /* Define to 1 if you have the <mntent.h> header file. */
#undef HAVE_MNTENT_H #undef HAVE_MNTENT_H
...@@ -156,6 +165,9 @@ ...@@ -156,6 +165,9 @@
/* Define to 1 if you have the <pwd.h> header file. */ /* Define to 1 if you have the <pwd.h> header file. */
#undef HAVE_PWD_H #undef HAVE_PWD_H
/* Define to 1 if you have the `rawmemchr' function. */
#undef HAVE_RAWMEMCHR
/* Define to 1 if you have the `setbuf' function. */ /* Define to 1 if you have the `setbuf' function. */
#undef HAVE_SETBUF #undef HAVE_SETBUF
...@@ -192,6 +204,9 @@ ...@@ -192,6 +204,9 @@
/* Define to 1 if you have the <stdlib.h> header file. */ /* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H #undef HAVE_STDLIB_H
/* Define to 1 if you have the `stpcpy' function. */
#undef HAVE_STPCPY
/* Define to 1 if you have the <strings.h> header file. */ /* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H #undef HAVE_STRINGS_H
......
...@@ -4455,6 +4455,17 @@ _ACEOF ...@@ -4455,6 +4455,17 @@ _ACEOF
fi fi
done done
for ac_func in mmap64
do :
ac_fn_c_check_func "$LINENO" "mmap64" "ac_cv_func_mmap64"
if test "x$ac_cv_func_mmap64" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_MMAP64 1
_ACEOF
fi
done
for ac_func in __libc_freeres for ac_func in __libc_freeres
do : do :
ac_fn_c_check_func "$LINENO" "__libc_freeres" "ac_cv_func___libc_freeres" ac_fn_c_check_func "$LINENO" "__libc_freeres" "ac_cv_func___libc_freeres"
...@@ -4466,6 +4477,19 @@ _ACEOF ...@@ -4466,6 +4477,19 @@ _ACEOF
fi fi
done done
for ac_func in rawmemchr stpcpy mempcpy
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
...@@ -10583,7 +10607,7 @@ else ...@@ -10583,7 +10607,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 10586 "configure" #line 10610 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
...@@ -10689,7 +10713,7 @@ else ...@@ -10689,7 +10713,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 10692 "configure" #line 10716 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
......
...@@ -75,7 +75,9 @@ AC_CHECK_FUNCS(getservent getservbyname getservbyport getaddrinfo gai_strerror) ...@@ -75,7 +75,9 @@ AC_CHECK_FUNCS(getservent getservbyname getservbyport getaddrinfo gai_strerror)
AC_CHECK_FUNCS(getprotoent getprotobyname getprotobynumber) AC_CHECK_FUNCS(getprotoent getprotobyname getprotobynumber)
AC_CHECK_FUNCS(getmntent setmntent addmntent) AC_CHECK_FUNCS(getmntent setmntent addmntent)
AC_CHECK_FUNCS(inet_ntoa mmap munmap) AC_CHECK_FUNCS(inet_ntoa mmap munmap)
AC_CHECK_FUNCS(mmap64)
AC_CHECK_FUNCS(__libc_freeres) AC_CHECK_FUNCS(__libc_freeres)
AC_CHECK_FUNCS(rawmemchr stpcpy mempcpy)
AC_TRY_COMPILE([#include <sys/types.h> AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/ipc.h> #include <sys/ipc.h>
......
/* Mudflap: narrow-pointer bounds-checking by tree rewriting. /* Mudflap: narrow-pointer bounds-checking by tree rewriting.
Copyright (C) 2002, 2003, 2004, 2009 Free Software Foundation, Inc. Copyright (C) 2002, 2003, 2004, 2009, 2011 Free Software Foundation, Inc.
Contributed by Frank Ch. Eigler <fche@redhat.com> Contributed by Frank Ch. Eigler <fche@redhat.com>
and Graydon Hoare <graydon@redhat.com> and Graydon Hoare <graydon@redhat.com>
...@@ -414,6 +414,61 @@ WRAPPER(int , munmap, void *start, size_t length) ...@@ -414,6 +414,61 @@ WRAPPER(int , munmap, void *start, size_t length)
#endif /* HAVE_MMAP */ #endif /* HAVE_MMAP */
#ifdef HAVE_MMAP64
#if PIC
/* A special bootstrap variant. */
void *
__mf_0fn_mmap64 (void *start, size_t l, int prot, int f, int fd, off64_t off)
{
return (void *) -1;
}
#endif
#undef mmap
WRAPPER(void *, mmap64,
void *start, size_t length, int prot,
int flags, int fd, off64_t offset)
{
DECLARE(void *, mmap64, void *, size_t, int,
int, int, off64_t);
void *result;
BEGIN_PROTECT (mmap64, start, length, prot, flags, fd, offset);
result = CALL_REAL (mmap64, start, length, prot,
flags, fd, offset);
/*
VERBOSE_TRACE ("mmap64 (%08lx, %08lx, ...) => %08lx\n",
(uintptr_t) start, (uintptr_t) length,
(uintptr_t) result);
*/
if (result != (void *)-1)
{
/* Register each page as a heap object. Why not register it all
as a single segment? That's so that a later munmap() call
can unmap individual pages. XXX: would __MF_TYPE_GUESS make
this more automatic? */
size_t ps = getpagesize ();
uintptr_t base = (uintptr_t) result;
uintptr_t offset;
for (offset=0; offset<length; offset+=ps)
{
/* XXX: We could map PROT_NONE to __MF_TYPE_NOACCESS. */
/* XXX: Unaccessed HEAP pages are reported as leaks. Is this
appropriate for unaccessed mmap pages? */
__mf_register ((void *) CLAMPADD (base, offset), ps,
__MF_TYPE_HEAP_I, "mmap64 page");
}
}
return result;
}
#endif /* HAVE_MMAP64 */
/* This wrapper is a little different, as it's called indirectly from /* This wrapper is a little different, as it's called indirectly from
__mf_fini also to clean up pending allocations. */ __mf_fini also to clean up pending allocations. */
void * void *
......
...@@ -2102,7 +2102,42 @@ WRAPPER2(struct mntent *, getmntent, FILE *filep) ...@@ -2102,7 +2102,42 @@ WRAPPER2(struct mntent *, getmntent, FILE *filep)
return m; return m;
} }
#elif defined HAVE_SYS_MNTTAB_H #elif defined HAVE_SYS_MNTTAB_H
/* FIXME: Implement. */ WRAPPER2(int, getmntent, FILE *filep, struct mnttab *mp)
{
static struct mnttab *last = NULL;
int res;
MF_VALIDATE_EXTENT (filep, sizeof (*filep), __MF_CHECK_WRITE,
"getmntent stream");
#define UR(field) __mf_unregister(last->field, strlen (last->field)+1, __MF_TYPE_STATIC)
if (last)
{
UR (mnt_special);
UR (mnt_mountp);
UR (mnt_fstype);
UR (mnt_mntopts);
UR (mnt_time);
__mf_unregister (last, sizeof (*last), __MF_TYPE_STATIC);
}
#undef UR
res = getmntent (filep, mp);
last = mp;
#define R(field) __mf_register(last->field, strlen (last->field)+1, __MF_TYPE_STATIC, "mntent " #field)
if (mp)
{
R (mnt_special);
R (mnt_mountp);
R (mnt_fstype);
R (mnt_mntopts);
R (mnt_time);
__mf_register (last, sizeof (*last), __MF_TYPE_STATIC, "getmntent result");
}
#undef R
return res;
}
#endif #endif
#endif #endif
......
/* Mudflap: narrow-pointer bounds-checking by tree rewriting. /* Mudflap: narrow-pointer bounds-checking by tree rewriting.
Copyright (C) 2002, 2003, 2004, 2005, 2009 Copyright (C) 2002, 2003, 2004, 2005, 2009, 2011
Free Software Foundation, Inc. Free Software Foundation, Inc.
Contributed by Frank Ch. Eigler <fche@redhat.com> Contributed by Frank Ch. Eigler <fche@redhat.com>
and Graydon Hoare <graydon@redhat.com> and Graydon Hoare <graydon@redhat.com>
...@@ -44,6 +44,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ...@@ -44,6 +44,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define _ALL_SOURCE #define _ALL_SOURCE
#define _LARGE_FILE_API #define _LARGE_FILE_API
#define _XOPEN_SOURCE_EXTENDED 1 #define _XOPEN_SOURCE_EXTENDED 1
#define _REENTRANT
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
......
/* Implementation header for mudflap runtime library. /* Implementation header for mudflap runtime library.
Mudflap: narrow-pointer bounds-checking by tree rewriting. Mudflap: narrow-pointer bounds-checking by tree rewriting.
Copyright (C) 2002, 2003, 2004, 2009 Free Software Foundation, Inc. Copyright (C) 2002, 2003, 2004, 2009, 2011 Free Software Foundation, Inc.
Contributed by Frank Ch. Eigler <fche@redhat.com> Contributed by Frank Ch. Eigler <fche@redhat.com>
and Graydon Hoare <graydon@redhat.com> and Graydon Hoare <graydon@redhat.com>
...@@ -212,6 +212,9 @@ extern struct __mf_dynamic_entry __mf_dynamic[]; ...@@ -212,6 +212,9 @@ extern struct __mf_dynamic_entry __mf_dynamic[];
enum __mf_dynamic_index enum __mf_dynamic_index
{ {
dyn_calloc, dyn_free, dyn_malloc, dyn_mmap, dyn_calloc, dyn_free, dyn_malloc, dyn_mmap,
#ifdef HAVE_MMAP64
dyn_mmap64,
#endif
dyn_munmap, dyn_realloc, dyn_munmap, dyn_realloc,
dyn_INITRESOLVE, /* Marker for last init-time resolution. */ dyn_INITRESOLVE, /* Marker for last init-time resolution. */
#ifdef LIBMUDFLAPTH #ifdef LIBMUDFLAPTH
......
...@@ -666,6 +666,9 @@ struct __mf_dynamic_entry __mf_dynamic [] = ...@@ -666,6 +666,9 @@ struct __mf_dynamic_entry __mf_dynamic [] =
{NULL, "free", NULL}, {NULL, "free", NULL},
{NULL, "malloc", NULL}, {NULL, "malloc", NULL},
{NULL, "mmap", NULL}, {NULL, "mmap", NULL},
#ifdef HAVE_MMAP64
{NULL, "mmap64", NULL},
#endif
{NULL, "munmap", NULL}, {NULL, "munmap", NULL},
{NULL, "realloc", NULL}, {NULL, "realloc", NULL},
{NULL, "DUMMY", NULL}, /* dyn_INITRESOLVE */ {NULL, "DUMMY", NULL}, /* dyn_INITRESOLVE */
...@@ -781,12 +784,22 @@ __wrap_main (int argc, char* argv[]) ...@@ -781,12 +784,22 @@ __wrap_main (int argc, char* argv[])
__mf_register (& errno, sizeof (errno), __MF_TYPE_STATIC, "errno area"); __mf_register (& errno, sizeof (errno), __MF_TYPE_STATIC, "errno area");
#if !(defined(__sun__) && defined(__svr4__))
/* Conflicts with the automatic registration of __iob[]. */
__mf_register (stdin, sizeof (*stdin), __MF_TYPE_STATIC, "stdin"); __mf_register (stdin, sizeof (*stdin), __MF_TYPE_STATIC, "stdin");
__mf_register (stdout, sizeof (*stdout), __MF_TYPE_STATIC, "stdout"); __mf_register (stdout, sizeof (*stdout), __MF_TYPE_STATIC, "stdout");
__mf_register (stderr, sizeof (*stderr), __MF_TYPE_STATIC, "stderr"); __mf_register (stderr, sizeof (*stderr), __MF_TYPE_STATIC, "stderr");
#endif
/* Make some effort to register ctype.h static arrays. */ /* Make some effort to register ctype.h static arrays. */
/* XXX: e.g., on Solaris, may need to register __ctype, _ctype, __ctype_mask, __toupper, etc. */ #if defined(__sun__) && defined(__svr4__)
/* __ctype[] is declared without size, but MB_CUR_MAX is the last
member. There seems to be no proper way to determine the size. */
__mf_register (__ctype, &MB_CUR_MAX - &__ctype[0] + 1, __MF_TYPE_STATIC, "__ctype");
/* __ctype_mask points at _C_masks[1]. The size can only determined
using nm on libc.so.1. */
__mf_register (__ctype_mask - 1, 1028, __MF_TYPE_STATIC, "_C_masks");
#endif
/* On modern Linux GLIBC, these are thread-specific and changeable, and are dealt /* On modern Linux GLIBC, these are thread-specific and changeable, and are dealt
with in mf-hooks2.c. */ with in mf-hooks2.c. */
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <unistd.h> #include <unistd.h>
#ifndef SCALE #ifndef SCALE
#define SCALE 100000 #define SCALE 10000
#endif #endif
......
/* Test for string function add boundaries of usable memory. /* Test for string function add boundaries of usable memory.
Copyright (C) 1996,1997,1999,2000,2001,2002 Free Software Foundation, Inc. Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2011
Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
...@@ -25,6 +26,8 @@ ...@@ -25,6 +26,8 @@
test the real implementation. */ test the real implementation. */
#undef __USE_STRING_INLINES #undef __USE_STRING_INLINES
#include "../config.h"
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
...@@ -36,6 +39,10 @@ ...@@ -36,6 +39,10 @@
#define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif #endif
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
...@@ -153,7 +160,7 @@ main (int argc, char *argv[]) ...@@ -153,7 +160,7 @@ main (int argc, char *argv[])
} }
} }
#if !defined __FreeBSD__ && !(defined __sun__ && defined __svr4__) #ifdef HAVE_RAWMEMCHR
/* rawmemchr test */ /* rawmemchr test */
for (outer = size - 1; outer >= MAX (0, size - 128); --outer) for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
{ {
...@@ -250,7 +257,7 @@ main (int argc, char *argv[]) ...@@ -250,7 +257,7 @@ main (int argc, char *argv[])
} }
} }
#ifndef __FreeBSD__ && !(defined __sun__ && defined __svr4__) #ifdef HAVE_STPCPY
/* stpcpy test */ /* stpcpy test */
for (outer = size - 1; outer >= MAX (0, size - 128); --outer) for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
{ {
...@@ -302,7 +309,7 @@ main (int argc, char *argv[]) ...@@ -302,7 +309,7 @@ main (int argc, char *argv[])
result = 1; result = 1;
} }
#if !defined __FreeBSD__ && !(defined __sun__ && defined __svr4__) #ifdef HAVE_MEMPCPY
/* mempcpy test */ /* mempcpy test */
for (outer = size - 1; outer >= MAX (0, size - 128); --outer) for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
for (inner = 0; inner < size - outer; ++inner) for (inner = 0; inner < size - outer; ++inner)
......
...@@ -8,3 +8,5 @@ int main () ...@@ -8,3 +8,5 @@ int main ()
tolower (buf[4]) == 'o' && tolower ('X') == 'x' && tolower (buf[4]) == 'o' && tolower ('X') == 'x' &&
isdigit (buf[3])) == 0 && isalnum ('4')); isdigit (buf[3])) == 0 && isalnum ('4'));
} }
/* { dg-warning "cannot track unknown size extern .__ctype." "Solaris __ctype declared without size" { target *-*-solaris2.* } 0 } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment