Portability improvements, e.g., libmudflap/15293.

2004-06-04  Frank Ch. Eigler  <fche@redhat.com>

	Portability improvements, e.g., libmudflap/15293.
	* configure.in: Look for glibc extension functions.  Look for
	support of -f{function,data}-sections.  Look for more headers.
	Create testsuite/mfconfig.exp.  Correct more "test x.." thinkos.
	* Makefile.am: Use $(SECTION_FLAGS).  Collapse piecemeal-compiled
	mf-hooks* into usual single object per source.
	* mf-hooks*.c: Remove all #if WRAP_foo conditionals.
	* mf-hooks2.c: #include a bunch more system headers.  Define strnlen
	if system doesn't provide one.
	* mf-hooks3.c (struct pthread_info): Add stack_*_alloc fields.
	(pthread_create): Use it to properly GC dead thread stacks.
	* mf-runtime.c (__mf_violation): Correct snprintf type warning.
	* testsuite/Makefile.am: Stop generating site.exp.
	* testsuite/mfconfig.exp.in: New file.
	* testsuite/config/default.exp: Load new mfconfig.exp.
	* testsuite/lib/libmudflap.exp (libmudflap-init): Add extra libraries.
	(prune_gcc_output): Add glibc static linking warnings.
	* testsuite/libmudflap.*/*frags.exp: Enumerate needed -lmudflap* libs.
	* testsuite/libmudflap.c/pass46-frag.c: Ditto.
	* configure, Makefile, aclocal.m4, config.h.in, testsuite/Makefile.in:
	Regenerated with autoconf 2.57 and automake 1.7.

From-SVN: r82632
This commit is contained in:
Frank Ch. Eigler 2004-06-04 20:12:01 +00:00
parent 28af2467e4
commit 7954e85c00
20 changed files with 2456 additions and 2523 deletions

View File

@ -1,3 +1,27 @@
2004-06-04 Frank Ch. Eigler <fche@redhat.com>
Portability improvements, e.g., libmudflap/15293.
* configure.in: Look for glibc extension functions. Look for
support of -f{function,data}-sections. Look for more headers.
Create testsuite/mfconfig.exp. Correct more "test x.." thinkos.
* Makefile.am: Use $(SECTION_FLAGS). Collapse piecemeal-compiled
mf-hooks* into usual single object per source.
* mf-hooks*.c: Remove all #if WRAP_foo conditionals.
* mf-hooks2.c: #include a bunch more system headers. Define strnlen
if system doesn't provide one.
* mf-hooks3.c (struct pthread_info): Add stack_*_alloc fields.
(pthread_create): Use it to properly GC dead thread stacks.
* mf-runtime.c (__mf_violation): Correct snprintf type warning.
* testsuite/Makefile.am: Stop generating site.exp.
* testsuite/mfconfig.exp.in: New file.
* testsuite/config/default.exp: Load new mfconfig.exp.
* testsuite/lib/libmudflap.exp (libmudflap-init): Add extra libraries.
(prune_gcc_output): Add glibc static linking warnings.
* testsuite/libmudflap.*/*frags.exp: Enumerate needed -lmudflap* libs.
* testsuite/libmudflap.c/pass46-frag.c: Ditto.
* configure, Makefile, aclocal.m4, config.h.in, testsuite/Makefile.in:
Regenerated with autoconf 2.57 and automake 1.7.
2004-06-04 Per Bothner <per@bothner.com>
* configure.in (LIBMUDFLAPTH): Fix thinko.
@ -13,7 +37,7 @@
* configure.in: Handle multilibs, support
--enable-version-specific-runtime-libs.
* Makefile.am (lib_LTLIBRARIES): Rename to ...
(toolexeclib_LTLIBRARIES): this for multilib support.
(toolexeclib_LTLIBRARIES): this for multilib support.
* Makefile.in: Regenerated.
* configure: Regenerated.
* aclocal.m4: Regenerated.

View File

@ -1,6 +1,6 @@
## Makefile for the toplevel directory of the mudflap library.
##
## Copyright (C) 2002, 2003
## Copyright (C) 2002, 2003, 2004
## Free Software Foundation, Inc.
##
@ -8,7 +8,8 @@ AUTOMAKE_OPTIONS = 1.3 foreign
MAINT_CHARSET = latin1
SUBDIRS = testsuite
AM_CFLAGS = -Wall
SECTION_FLAGS = @SECTION_FLAGS@
AM_CFLAGS = -Wall $(SECTION_FLAGS)
if LIBMUDFLAPTH
libmudflapth = libmudflapth.la
@ -21,289 +22,34 @@ include_HEADERS = mf-runtime.h
libmudflap_la_SOURCES = \
mf-runtime.c \
mf-heuristics.c
HOOK1OBJS = \
malloc-hook.lo \
free-hook.lo \
calloc-hook.lo \
realloc-hook.lo \
mmap-hook.lo \
munmap-hook.lo \
alloca-hook.lo
HOOK2OBJS = \
memcpy-hook.lo \
memmove-hook.lo \
memset-hook.lo \
memcmp-hook.lo \
memchr-hook.lo \
memrchr-hook.lo \
strcpy-hook.lo \
strncpy-hook.lo \
strcat-hook.lo \
strncat-hook.lo \
strcmp-hook.lo \
strcasecmp-hook.lo \
strncmp-hook.lo \
strncasecmp-hook.lo \
strdup-hook.lo \
strndup-hook.lo \
strchr-hook.lo \
strrchr-hook.lo \
strstr-hook.lo \
memmem-hook.lo \
strlen-hook.lo \
strnlen-hook.lo \
bzero-hook.lo \
bcopy-hook.lo \
bcmp-hook.lo \
index-hook.lo \
rindex-hook.lo \
asctime-hook.lo \
ctime-hook.lo \
gmtime-hook.lo \
localtime-hook.lo \
time-hook.lo \
strerror-hook.lo \
fopen-hook.lo \
fclose-hook.lo \
fread-hook.lo \
fwrite-hook.lo \
fgetc-hook.lo \
fgets-hook.lo \
getc-hook.lo \
gets-hook.lo \
ungetc-hook.lo \
fputc-hook.lo \
fputs-hook.lo \
putc-hook.lo \
puts-hook.lo \
clearerr-hook.lo \
feof-hook.lo \
ferror-hook.lo \
fileno-hook.lo \
printf-hook.lo \
fprintf-hook.lo \
sprintf-hook.lo \
snprintf-hook.lo \
vprintf-hook.lo \
vfprintf-hook.lo \
vsprintf-hook.lo \
vsnprintf-hook.lo \
access-hook.lo \
remove-hook.lo \
fflush-hook.lo \
fseek-hook.lo \
ftell-hook.lo \
rewind-hook.lo \
fgetpos-hook.lo \
fsetpos-hook.lo \
stat-hook.lo \
fstat-hook.lo \
lstat-hook.lo \
mkfifo-hook.lo \
setvbuf-hook.lo \
setbuf-hook.lo \
opendir-hook.lo \
closedir-hook.lo \
readdir-hook.lo \
recv-hook.lo \
recvfrom-hook.lo \
recvmsg-hook.lo \
send-hook.lo \
sendto-hook.lo \
sendmsg-hook.lo \
setsockopt-hook.lo \
getsockopt-hook.lo \
accept-hook.lo \
bind-hook.lo \
connect-hook.lo \
gethostname-hook.lo \
sethostname-hook.lo \
gethostbyname-hook.lo \
wait-hook.lo \
waitpid-hook.lo \
popen-hook.lo \
pclose-hook.lo \
execve-hook.lo \
execv-hook.lo \
execvp-hook.lo \
system-hook.lo \
dlopen-hook.lo \
dlerror-hook.lo \
dlsym-hook.lo \
dlclose-hook.lo \
fopen64-hook.lo \
stat64-hook.lo \
fseeko64-hook.lo \
ftello64-hook.lo \
semop-hook.lo \
semctl-hook.lo \
shmctl-hook.lo \
shmat-hook.lo \
shmdt-hook.lo
HOOK3OBJS =
$(HOOK1OBJS): mf-hooks1.c mf-runtime.h mf-impl.h
hook=`basename $@ -hook.lo`; \
$(LTCOMPILE) -DWRAP_$$hook -c $(srcdir)/mf-hooks1.c -o $@
$(HOOK2OBJS): mf-hooks2.c mf-runtime.h mf-impl.h
hook=`basename $@ -hook.lo`; \
$(LTCOMPILE) -DWRAP_$$hook -c $(srcdir)/mf-hooks2.c -o $@
$(HOOK3OBJS): mf-hooks3.c mf-runtime.h mf-impl.h
hook=`basename $@ -hook.lo`; \
$(LTCOMPILE) -DWRAP_$$hook -c $(srcdir)/mf-hooks3.c -o $@
# Hook objects only for libmudflapth use
PTHHOOK1OBJS= \
pth/malloc-hook.lo \
pth/free-hook.lo \
pth/calloc-hook.lo \
pth/realloc-hook.lo \
pth/mmap-hook.lo \
pth/munmap-hook.lo \
pth/alloca-hook.lo
PTHHOOK2OBJS= \
pth/memcpy-hook.lo \
pth/memmove-hook.lo \
pth/memset-hook.lo \
pth/memcmp-hook.lo \
pth/memchr-hook.lo \
pth/memrchr-hook.lo \
pth/strcpy-hook.lo \
pth/strncpy-hook.lo \
pth/strcat-hook.lo \
pth/strncat-hook.lo \
pth/strcmp-hook.lo \
pth/strcasecmp-hook.lo \
pth/strncmp-hook.lo \
pth/strncasecmp-hook.lo \
pth/strdup-hook.lo \
pth/strndup-hook.lo \
pth/strchr-hook.lo \
pth/strrchr-hook.lo \
pth/strstr-hook.lo \
pth/memmem-hook.lo \
pth/strlen-hook.lo \
pth/strnlen-hook.lo \
pth/bzero-hook.lo \
pth/bcopy-hook.lo \
pth/bcmp-hook.lo \
pth/index-hook.lo \
pth/rindex-hook.lo \
pth/asctime-hook.lo \
pth/ctime-hook.lo \
pth/gmtime-hook.lo \
pth/localtime-hook.lo \
pth/time-hook.lo \
pth/strerror-hook.lo \
pth/fopen-hook.lo \
pth/fclose-hook.lo \
pth/fread-hook.lo \
pth/fwrite-hook.lo \
pth/fgetc-hook.lo \
pth/fgets-hook.lo \
pth/getc-hook.lo \
pth/gets-hook.lo \
pth/ungetc-hook.lo \
pth/fputc-hook.lo \
pth/fputs-hook.lo \
pth/putc-hook.lo \
pth/puts-hook.lo \
pth/clearerr-hook.lo \
pth/feof-hook.lo \
pth/ferror-hook.lo \
pth/fileno-hook.lo \
pth/printf-hook.lo \
pth/fprintf-hook.lo \
pth/sprintf-hook.lo \
pth/snprintf-hook.lo \
pth/vprintf-hook.lo \
pth/vfprintf-hook.lo \
pth/vsprintf-hook.lo \
pth/vsnprintf-hook.lo \
pth/access-hook.lo \
pth/remove-hook.lo \
pth/fflush-hook.lo \
pth/fseek-hook.lo \
pth/ftell-hook.lo \
pth/rewind-hook.lo \
pth/fgetpos-hook.lo \
pth/fsetpos-hook.lo \
pth/stat-hook.lo \
pth/fstat-hook.lo \
pth/lstat-hook.lo \
pth/mkfifo-hook.lo \
pth/setvbuf-hook.lo \
pth/setbuf-hook.lo \
pth/opendir-hook.lo \
pth/closedir-hook.lo \
pth/readdir-hook.lo \
pth/recv-hook.lo \
pth/recvfrom-hook.lo \
pth/recvmsg-hook.lo \
pth/send-hook.lo \
pth/sendto-hook.lo \
pth/sendmsg-hook.lo \
pth/setsockopt-hook.lo \
pth/getsockopt-hook.lo \
pth/accept-hook.lo \
pth/bind-hook.lo \
pth/connect-hook.lo \
pth/gethostname-hook.lo \
pth/sethostname-hook.lo \
pth/gethostbyname-hook.lo \
pth/wait-hook.lo \
pth/waitpid-hook.lo \
pth/popen-hook.lo \
pth/pclose-hook.lo \
pth/execve-hook.lo \
pth/execv-hook.lo \
pth/execvp-hook.lo \
pth/system-hook.lo \
pth/dlopen-hook.lo \
pth/dlerror-hook.lo \
pth/dlsym-hook.lo \
pth/dlclose-hook.lo \
pth/fopen64-hook.lo \
pth/stat64-hook.lo \
pth/fseeko64-hook.lo \
pth/ftello64-hook.lo \
pth/semop-hook.lo \
pth/semctl-hook.lo \
pth/shmctl-hook.lo \
pth/shmat-hook.lo \
pth/shmdt-hook.lo
PTHHOOK3OBJS= \
pth/pthreadstuff-hook.lo
mf-heuristics.c \
mf-hooks1.c \
mf-hooks2.c
libmudflap_la_LIBADD =
libmudflap_la_DEPENDENCIES = $(libmudflap_la_LIBADD)
clean-local:
rm -f pth/*.o pth/*.lo
libmudflapth_la_SOURCES =
pth/mf-runtime.lo: mf-runtime.c mf-runtime.h mf-impl.h
$(LTCOMPILE) -DLIBMUDFLAPTH -c $(srcdir)/mf-runtime.c -o $@
pth/mf-heuristics.lo: mf-heuristics.c mf-runtime.h mf-impl.h
$(LTCOMPILE) -DLIBMUDFLAPTH -c $(srcdir)/mf-heuristics.c -o $@
$(PTHHOOK1OBJS): mf-hooks1.c mf-runtime.h mf-impl.h
hook=`basename $@ -hook.lo`; \
$(LTCOMPILE) -DLIBMUDFLAPTH -DWRAP_$$hook -c $(srcdir)/mf-hooks1.c -o $@
$(PTHHOOK2OBJS): mf-hooks2.c mf-runtime.h mf-impl.h
hook=`basename $@ -hook.lo`; \
$(LTCOMPILE) -DLIBMUDFLAPTH -DWRAP_$$hook -c $(srcdir)/mf-hooks2.c -o $@
$(PTHHOOK3OBJS): mf-hooks3.c mf-runtime.h mf-impl.h
hook=`basename $@ -hook.lo`; \
$(LTCOMPILE) -DLIBMUDFLAPTH -DWRAP_$$hook -c $(srcdir)/mf-hooks3.c -o $@
pth/mf-hooks1.lo: mf-hooks1.c mf-runtime.h mf-impl.h
$(LTCOMPILE) -DLIBMUDFLAPTH -c $(srcdir)/mf-hooks1.c -o $@
pth/mf-hooks2.lo: mf-hooks2.c mf-runtime.h mf-impl.h
$(LTCOMPILE) -DLIBMUDFLAPTH -c $(srcdir)/mf-hooks2.c -o $@
pth/mf-hooks3.lo: mf-hooks3.c mf-runtime.h mf-impl.h
$(LTCOMPILE) -DLIBMUDFLAPTH -c $(srcdir)/mf-hooks3.c -o $@
libmudflap_la_LIBADD = $(HOOK1OBJS) $(HOOK2OBJS) $(HOOK3OBJS)
libmudflap_la_DEPENDENCIES = $(libmudflap_la_LIBADD)
libmudflapth_la_LIBADD = pth/mf-runtime.lo pth/mf-heuristics.lo \
$(PTHHOOK1OBJS) $(PTHHOOK2OBJS) $(PTHHOOK3OBJS)
libmudflapth_la_SOURCES =
libmudflapth_la_LIBADD = \
pth/mf-runtime.lo \
pth/mf-heuristics.lo \
pth/mf-hooks1.lo \
pth/mf-hooks2.lo \
pth/mf-hooks3.lo
libmudflapth_la_DEPENDENCIES = $(libmudflapth_la_LIBADD)

File diff suppressed because it is too large Load Diff

1920
libmudflap/aclocal.m4 vendored

File diff suppressed because it is too large Load Diff

View File

@ -33,15 +33,24 @@
/* Define to 1 if you have the `dl' library (-ldl). */
#undef HAVE_LIBDL
/* Define to 1 if you have the `memmem' function. */
#undef HAVE_MEMMEM
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `memrchr' function. */
#undef HAVE_MEMRCHR
/* Define to 1 if you have the <netdb.h> header file. */
#undef HAVE_NETDB_H
/* define if you have <pthread.h> */
#undef HAVE_PTHREAD_H
/* Define to 1 if you have the `sethostname' function. */
#undef HAVE_SETHOSTNAME
/* Define to 1 if you have the `signal' function. */
#undef HAVE_SIGNAL
@ -66,12 +75,21 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strncpy' function. */
#undef HAVE_STRNCPY
/* Define to 1 if you have the `strnlen' function. */
#undef HAVE_STRNLEN
/* Define to 1 if you have the <sys/ipc.h> header file. */
#undef HAVE_SYS_IPC_H
/* Define to 1 if you have the <sys/sem.h> header file. */
#undef HAVE_SYS_SEM_H
/* Define to 1 if you have the <sys/shm.h> header file. */
#undef HAVE_SYS_SHM_H
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H

1293
libmudflap/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -63,12 +63,15 @@ AC_TRY_COMPILE([
enable_shared=no])
AC_CHECK_HEADERS(stdint.h execinfo.h signal.h dlfcn.h \
netdb.h sys/ipc.h sys/sem.h sys/wait.h sys/socket.h)
netdb.h sys/ipc.h sys/sem.h sys/shm.h sys/wait.h sys/socket.h)
AC_CHECK_FUNCS(backtrace backtrace_symbols gettimeofday signal)
dnl Check for 64-bit stdio calls related to Large File Support
AC_CHECK_FUNCS(fopen64 fseeko64 ftello64 stat64)
dnl Check for nonstandard functions
AC_CHECK_FUNCS(strnlen memrchr strncpy memmem sethostname)
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>],[union semun foo;], [mf_have_semun=1], [mf_have_semun=0])
@ -115,7 +118,14 @@ ac_have_pthread_h=yes
],[
ac_have_pthread_h=
])
AM_CONDITIONAL(LIBMUDFLAPTH, [test "$ac_have_pthread_h" != ""])
AM_CONDITIONAL(LIBMUDFLAPTH, [test "x$ac_have_pthread_h" != "x"])
if test "x$ac_have_pthread_h" != "x"
then
build_libmudflapth=1
else
build_libmudflapth=0
fi
AC_SUBST(build_libmudflapth)
AC_CHECK_LIB(dl, dlsym)
@ -155,7 +165,7 @@ esac
AC_SUBST(toolexecdir)
AC_SUBST(toolexeclibdir)
if test "x$enable_shared" = "xyes" && test "x$ac_have_pthread_h" != ""; then
if test "x$enable_shared" = "xyes" && test "x$ac_have_pthread_h" != "x"; then
# NB: don't check for -lpthread here, because then it would be
# added to LIBS. For the thread-unaware libmudflap.la, we don't
# want it there.
@ -166,7 +176,7 @@ if test "x$enable_shared" = "xyes" && test "x$ac_have_pthread_h" != ""; then
# the nonstandard dlvsym().
AC_CHECK_FUNCS(dlvsym)
AC_CHECK_TOOL(NM, nm)
if test "x$ac_cv_have_dlvsym" != ""; then
if test "x$ac_cv_have_dlvsym" != "x"; then
# Try compiling a simple pthreads program. Find the shared libraries it
# ends up with. Then use "nm" on those libraries to extract the
# default symbol versioning suffix ("@@"), if any. But that's tricky.
@ -193,10 +203,33 @@ EOF
fi
AC_DEFINE_UNQUOTED(PTHREAD_CREATE_VERSION, $pthread_create_version, [pthread_create symbol version])
# Figure out whether the compiler supports "-ffunction-sections -fdata-sections",
# similarly to how libstdc++ does it
ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
# Check for -ffunction-sections -fdata-sections
AC_MSG_CHECKING([for gcc that supports -ffunction-sections -fdata-sections])
CFLAGS='-Werror -ffunction-sections -fdata-sections'
AC_TRY_COMPILE(, [int foo;], [ac_fdsections=yes], [ac_fdsections=no])
if test "$ac_test_CFLAGS" = set; then
CFLAGS="$ac_save_CFLAGS"
else
# this is the suspicious part
CFLAGS=""
fi
if test x"$ac_fdsections" = x"yes"; then
SECTION_FLAGS='-ffunction-sections -fdata-sections'
fi
AC_MSG_RESULT($ac_fdsections)
AC_SUBST(SECTION_FLAGS)
if test ${multilib} = yes; then
multilib_arg="--enable-multilib"
else
multilib_arg=
fi
AC_OUTPUT([Makefile testsuite/Makefile mf-runtime.h])
AC_OUTPUT([Makefile testsuite/Makefile testsuite/mfconfig.exp mf-runtime.h])

View File

@ -1,5 +1,5 @@
/* Mudflap: narrow-pointer bounds-checking by tree rewriting.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
Contributed by Frank Ch. Eigler <fche@redhat.com>
and Graydon Hoare <graydon@redhat.com>
@ -74,8 +74,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
use plain macros in mf-runtime.h. */
#ifdef WRAP_malloc
#if PIC
/* A special bootstrap variant. */
void *
@ -86,6 +84,7 @@ __mf_0fn_malloc (size_t c)
}
#endif
#undef malloc
WRAPPER(void *, malloc, size_t c)
{
@ -108,11 +107,8 @@ WRAPPER(void *, malloc, size_t c)
return result;
}
#endif
#ifdef WRAP_calloc
#ifdef PIC
/* A special bootstrap variant. */
void *
@ -136,6 +132,7 @@ __mf_0fn_calloc (size_t c, size_t n)
}
#endif
#undef calloc
WRAPPER(void *, calloc, size_t c, size_t n)
{
@ -164,9 +161,7 @@ WRAPPER(void *, calloc, size_t c, size_t n)
return result;
}
#endif
#ifdef WRAP_realloc
#if PIC
/* A special bootstrap variant. */
@ -177,6 +172,7 @@ __mf_0fn_realloc (void *buf, size_t c)
}
#endif
#undef realloc
WRAPPER(void *, realloc, void *buf, size_t c)
{
@ -220,11 +216,8 @@ WRAPPER(void *, realloc, void *buf, size_t c)
return result;
}
#endif
#ifdef WRAP_free
#if PIC
/* A special bootstrap variant. */
void
@ -297,11 +290,8 @@ WRAPPER(void, free, void *buf)
CALL_REAL (free, base);
}
}
#endif
#ifdef WRAP_mmap
#if PIC
/* A special bootstrap variant. */
void *
@ -353,11 +343,8 @@ WRAPPER(void *, mmap,
return result;
}
#endif
#ifdef WRAP_munmap
#if PIC
/* A special bootstrap variant. */
int
@ -395,11 +382,8 @@ WRAPPER(int , munmap, void *start, size_t length)
}
return result;
}
#endif
#ifdef WRAP_alloca
/* This wrapper is a little different, as it's called indirectly from
__mf_fini also to clean up pending allocations. */
void *
@ -428,7 +412,9 @@ __mf_wrap_alloca_indirect (size_t c)
/* Free any previously alloca'd blocks that belong to deeper-nested functions,
which must therefore have exited by now. */
#define DEEPER_THAN < /* for x86 */
#define DEEPER_THAN < /* XXX: for x86; steal find_stack_direction() from libiberty/alloca.c */
while (alloca_history &&
((uintptr_t) alloca_history->stack DEEPER_THAN (uintptr_t) stack))
{
@ -474,5 +460,3 @@ WRAPPER(void *, alloca, size_t c)
return __mf_wrap_alloca_indirect (c);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* Mudflap: narrow-pointer bounds-checking by tree rewriting.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
Contributed by Frank Ch. Eigler <fche@redhat.com>
and Graydon Hoare <graydon@redhat.com>
@ -59,6 +59,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include <errno.h>
#include <limits.h>
#include <sched.h>
#include <fcntl.h>
#include "mf-runtime.h"
#include "mf-impl.h"
@ -71,8 +72,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
/* Multithreading support hooks. */
#ifdef WRAP_pthreadstuff
#ifndef LIBMUDFLAPTH
#error "pthreadstuff is to be included only in libmudflapth"
@ -87,9 +86,12 @@ struct pthread_info
short dead_p; /* Is this thread dead? */
pthread_t self; /* The thread id. */
/* If libmudflapth allocated the stack, store its base/size. */
/* If libmudflapth allocated the stack, store its adjusted base/size. */
void *stack;
size_t stack_size;
/* The _alloc fields store unadjusted values from the moment of allocation. */
void *stack_alloc;
size_t stack_size_alloc;
int *thread_errno;
enum __mf_state_enum state;
@ -357,6 +359,8 @@ WRAPPER(int, pthread_create, pthread_t *thr, const pthread_attr_t *attr,
pthread_attr_t override_attr;
void *override_stack;
size_t override_stacksize;
void *override_stack_alloc = (void *) 0;
size_t override_stacksize_alloc = 0;
unsigned i;
TRACE ("pthread_create\n");
@ -381,9 +385,9 @@ WRAPPER(int, pthread_create, pthread_t *thr, const pthread_attr_t *attr,
if (pi->dead_p >= 10 /* XXX */)
{
if (pi->stack)
CALL_REAL (munmap, pi->stack, pi->stack_size);
CALL_REAL (munmap, pi->stack_alloc, pi->stack_size_alloc);
VERBOSE_TRACE ("slot %u freed, stack %p\n", i, pi->stack);
VERBOSE_TRACE ("slot %u freed, stack %p\n", i, pi->stack_alloc);
memset (pi, 0, sizeof (*pi));
/* One round of garbage collection is enough. */
@ -435,14 +439,32 @@ WRAPPER(int, pthread_create, pthread_t *thr, const pthread_attr_t *attr,
#define MF_MAP_ANON MAP_ANONYMOUS
#elif defined(MAP_ANON)
#define MF_MAP_ANON MAP_ANON
#else
#error "Cannot mmap anonymous memory."
#endif
#ifndef MAP_FAILED
#define MAP_FAILED ((void *) -1)
#endif
#ifdef MF_MAP_ANON
override_stack = CALL_REAL (mmap, NULL, override_stacksize,
PROT_READ|PROT_WRITE,
MAP_PRIVATE|MF_MAP_ANON,
0, 0);
#else
/* Try mapping /dev/zero instead. */
{
static int zerofd = -1;
if (zerofd == -1)
zerofd = open ("/dev/zero", O_RDWR);
if (zerofd == -1)
override_stack = MAP_FAILED;
else
override_stack = CALL_REAL (mmap, NULL, override_stacksize,
PROT_READ|PROT_WRITE,
MAP_PRIVATE, zerofd, 0);
}
#endif
if (override_stack == 0 || override_stack == MAP_FAILED)
{
errno = EAGAIN;
@ -452,10 +474,15 @@ WRAPPER(int, pthread_create, pthread_t *thr, const pthread_attr_t *attr,
VERBOSE_TRACE ("thread stack alloc %p size %lu\n",
override_stack, (unsigned long) override_stacksize);
/* Save the original allocated values for later deallocation. */
override_stack_alloc = override_stack;
override_stacksize_alloc = override_stacksize;
/* The stackaddr pthreads attribute is a candidate stack pointer.
It must point near the top or the bottom of this buffer, depending
on whether stack grows downward or upward, and suitably aligned.
On the x86, it grows down, so we set stackaddr near the top. */
/* XXX: port logic */
override_stack = (void *)
(((uintptr_t) override_stack + override_stacksize - alignment - perturb)
& (~(uintptr_t)(alignment-1)));
@ -504,6 +531,8 @@ WRAPPER(int, pthread_create, pthread_t *thr, const pthread_attr_t *attr,
/* Fill in remaining fields in pthread_info. */
pi->stack = override_stack;
pi->stack_size = override_stacksize;
pi->stack_alloc = override_stack_alloc;
pi->stack_size_alloc = override_stacksize_alloc;
/* XXX: this might be too late for future heuristics that attempt
to use thread stack bounds. We may need to put the new thread
to sleep. */
@ -563,11 +592,3 @@ WRAPPER(void, pthread_exit, void *rc)
CALL_REAL (pthread_exit, rc);
/* NOTREACHED */
}
#endif /* pthreadstuff */

View File

@ -1,5 +1,5 @@
/* Mudflap: narrow-pointer bounds-checking by tree rewriting.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
Contributed by Frank Ch. Eigler <fche@redhat.com>
and Graydon Hoare <graydon@redhat.com>
@ -2244,7 +2244,8 @@ __mf_violation (void *ptr, size_t sz, uintptr_t pc,
abort ();
break;
case viol_gdb:
snprintf (buf, 128, "gdb --pid=%d", getpid ());
snprintf (buf, 128, "gdb --pid=%u", (unsigned) getpid ());
system (buf);
/* XXX: should probably fork() && sleep(GDB_WAIT_PARAMETER)
instead, and let the forked child execlp() gdb. That way, this

View File

@ -9,10 +9,3 @@ EXPECT = `if [ -f ../../expect/expect ] ; then \
RUNTEST = `if [ -f ${srcdir}/../../dejagnu/runtest ] ; then \
echo ${srcdir}/../../dejagnu/runtest ; \
else echo runtest ; fi`
all-local: site.exp
if LIBMUDFLAPTH
echo 'set libmudflapth 1' >> site.exp
else
echo 'set libmudflapth 0' >> site.exp
endif

View File

@ -1,8 +1,8 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# Makefile.in generated by automake 1.7.8 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
# Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@ -13,6 +13,7 @@
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
@ -20,6 +21,7 @@ pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
@ -36,21 +38,6 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = testsuite
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
DEJATOOL = $(PACKAGE)
RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
@ -99,6 +86,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SECTION_FLAGS = @SECTION_FLAGS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
@ -116,6 +104,7 @@ bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_libmudflapth = @build_libmudflapth@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
@ -136,7 +125,6 @@ libexecdir = @libexecdir@
libtool_VERSION = @libtool_VERSION@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
multi_basedir = @multi_basedir@
oldincludedir = @oldincludedir@
prefix = @prefix@
@ -151,47 +139,35 @@ target_os = @target_os@
target_vendor = @target_vendor@
toolexecdir = @toolexecdir@
toolexeclibdir = @toolexeclibdir@
AUTOMAKE_OPTIONS = foreign dejagnu
EXPECT = `if [ -f ../../expect/expect ] ; then \
echo ../../expect/expect ; \
else echo expect ; fi`
RUNTEST = `if [ -f ${srcdir}/../../dejagnu/runtest ] ; then \
echo ${srcdir}/../../dejagnu/runtest ; \
else echo runtest ; fi`
subdir = testsuite
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = mfconfig.exp
DIST_SOURCES =
DIST_COMMON = $(srcdir)/Makefile.in Makefile.am mfconfig.exp.in
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign testsuite/Makefile'; \
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign testsuite/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
mfconfig.exp: $(top_builddir)/config.status mfconfig.exp.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
mostlyclean-libtool:
-rm -f *.lo
@ -208,6 +184,9 @@ TAGS:
ctags: CTAGS
CTAGS:
RUNTESTFLAGS =
DEJATOOL = $(PACKAGE)
RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
check-DEJAGNU: site.exp
srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \
@ -244,6 +223,10 @@ distclean-DEJAGNU:
-l='$(DEJATOOL)'; for tool in $$l; do \
rm -f $$tool.sum $$tool.log; \
done
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
top_distdir = ..
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
@ -257,7 +240,7 @@ distdir: $(DISTFILES)
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
$(mkinstalldirs) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
@ -275,7 +258,8 @@ distdir: $(DISTFILES)
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU
check: check-am
all-am: Makefile all-local
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
@ -288,7 +272,7 @@ install-am: all-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
@ -314,8 +298,6 @@ dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
@ -348,21 +330,16 @@ ps-am:
uninstall-am: uninstall-info-am
.PHONY: all all-am all-local check check-DEJAGNU check-am clean \
clean-generic clean-libtool distclean distclean-DEJAGNU \
distclean-generic distclean-libtool distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \
uninstall-info-am
.PHONY: all all-am check check-DEJAGNU check-am clean clean-generic \
clean-libtool distclean distclean-DEJAGNU distclean-generic \
distclean-libtool distdir dvi dvi-am info info-am install \
install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
uninstall uninstall-am uninstall-info-am
all-local: site.exp
@LIBMUDFLAPTH_TRUE@ echo 'set libmudflapth 1' >> site.exp
@LIBMUDFLAPTH_FALSE@ echo 'set libmudflapth 0' >> site.exp
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -1,2 +1,3 @@
load_lib standard.exp
load_lib libmudflap.exp
load_lib mfconfig.exp

View File

@ -17,10 +17,10 @@
# Define libmudflap callbacks for dg.exp.
# This file is a copy of libstdc++-v3's dejagnu driver, with minor changes.
load_lib mfdg.exp
load_lib libgloss.exp
proc libmudflap-init { language } {
global srcdir
global outdir
@ -92,6 +92,10 @@ proc libmudflap-init { language } {
}
}
global mfconfig_libs
global add_flags
append add_flags " $mfconfig_libs"
verbose -log "ld_library_path=$ld_library_path"
setenv LD_LIBRARY_PATH $ld_library_path
setenv SHLIB_PATH $ld_library_path
@ -152,6 +156,9 @@ proc libmudflap-dg-test { prog do_what extra_tool_flags } {
lappend options "additional_flags=$extra_tool_flags"
}
global mfconfig_libs
lappend options "libs=$mfconfig_libs"
set comp_output [libmudflap_target_compile "$prog" "$output_file" "$compile_type" $options];
set comp_output [prune_gcc_output $comp_output ];
@ -244,14 +251,12 @@ proc libmudflap-list-sourcefiles { } {
proc prune_gcc_output { text } {
regsub -all {(^|\n)[^\n]*ld: warning: libgcc_s[^\n]*not found[^\n]*try using[^\n]*} $text "" text
regsub -all {(^|\n)[^\n]*In function.*pthread_create[^\n]*} $text "" text
regsub -all {(^|\n)[^\n]*the use of .pthread.*is deprecated[^\n]*} $text "" text
regsub -all {(^|\n)[^\n]*Dwarf Error:.*FORM value: 14[^\n]*} $text "" text
regsub -all {(^|\n)[^\n]*In function[^\n]*} $text "" text
regsub -all {(^|\n)[^\n]*Using.*in statically linked applications requires[^\n]*} $text "" text
return $text
}

View File

@ -9,7 +9,7 @@ foreach flags [list {} {-static} {-O2} {-O3}] {
foreach srcfile [lsort [glob -nocomplain ${srcdir}/libmudflap.c++/*.cxx]] {
set bsrc [file tail $srcfile]
setenv MUDFLAP_OPTIONS "-no-heur-proc-map -viol-segv"
dg-runtest $srcfile $flags "-fmudflap"
dg-runtest $srcfile $flags "-fmudflap -lmudflap"
}
}

View File

@ -8,7 +8,7 @@ foreach flags [list {} {-static} {-O2} {-O3}] {
foreach srcfile [lsort [glob -nocomplain ${srcdir}/libmudflap.c/*.c]] {
set bsrc [file tail $srcfile]
setenv MUDFLAP_OPTIONS "-viol-segv"
dg-runtest $srcfile $flags "-fmudflap"
dg-runtest $srcfile $flags "-fmudflap -lmudflap"
}
}

View File

@ -15,4 +15,4 @@ int main ()
int m = boo [l % 2 + 12]; /* should not be instrumented */
return m & strlen (""); /* a fancy way of saying "0" */
}
/* { dg-options "-fmudflap -fmudflapir -Wall" } */
/* { dg-options "-fmudflap -fmudflapir -lmudflap -Wall" } */

View File

@ -12,7 +12,7 @@ foreach flags [list {} {-static -DSTATIC} {-O2} {-O3}] {
# --noinhibit-exec works around a ld problem that causes
# "Dwarf Error: Invalid or unhandled FORM value: 14"
# to fail builds unnecessarily.
dg-runtest $srcfile $flags "-fmudflapth -Wl,--noinhibit-exec"
dg-runtest $srcfile $flags "-fmudflapth -lmudflapth -lpthread -Wl,--noinhibit-exec"
} else {
if {$flags != ""} {set f " ($flags)"} {set f ""}
untested "libmudflap.cth/$bsrc$f"

View File

@ -0,0 +1,4 @@
global mfconfig_libs
set mfconfig_libs "@LIBS@"
global libmudflapth
set libmudflapth "@build_libmudflapth@"