--- src/Makefile.am 2007/01/29 04:34:05 1.1 +++ src/Makefile.am 2007/01/30 15:23:08 @@ -2,6 +2,8 @@ AUTOMAKE_OPTIONS = foreign lib_LTLIBRARIES = libsandbox.la bin_PROGRAMS = sandbox +noinst_LTLIBRARIES = libptmalloc3.la \ + libmalloc.la AM_CPPFLAGS = \ -DPIC -fPIC -D_REENTRANT \ @@ -11,12 +13,32 @@ AM_CPPFLAGS = \ LOCAL_INCLUDES = $(top_srcdir)/localdecls.h +libmalloc_la_SOURCES = malloc.c +libmalloc_la_CPPFLAGS = -D_GNU_SOURCE \ + -DHAVE_MORECORE=0 \ + -DONLY_MSPACES -DUSE_LOCKS=0 +libptmalloc3_la_SOURCES = ptmalloc3.c \ + malloc-2.8.3.h \ + malloc-private.h \ + sysdeps/pthread/malloc-machine.h \ + sysdeps/pthread/thread-st.h \ + sysdeps/generic/malloc-machine.h \ + sysdeps/generic/atomic.h \ + sysdeps/generic/thread-st.h +libptmalloc3_la_CPPFLAGS = -D_GNU_SOURCE \ + -DMSPACES=1 \ + -DUSE_TSD_DATA_HACK -DTHREAD_STATS=1 \ + -Isysdeps/pthread -Isysdeps/generic +libptmalloc3_la_LIBADD = -lpthread \ + libmalloc.la + # We need -fexceptions here, else we do not catch exceptions # (nptl/tst-cancelx4.c in glibc among others fails for wrapped functions). libsandbox_la_CFLAGS = -fexceptions # Do not add -nostdlib or -nostartfiles, as then our constructor # and destructor will not be executed ... -libsandbox_la_LIBADD = -lc $(LIBDL) +libsandbox_la_LIBADD = libptmalloc3.la \ + -lc $(LIBDL) libsandbox_la_LDFLAGS = \ -nodefaultlibs \ -Wl,--version-script,libsandbox.map @@ -32,6 +54,7 @@ sandbox_SOURCES = \ sandbox.h \ sandbox_utils.c \ $(LOCAL_INCLUDES) +sandbox_LDADD = libptmalloc3.la libsandbox.c: libsandbox.map symbols.h --- src/sandbox_utils.c 2007/01/29 03:13:46 1.1 +++ src/sandbox_utils.c 2007/01/30 16:13:45 @@ -175,7 +175,7 @@ char * gstrndup (const char *str, size_t return NULL; /* Check lenght of str without breaching the size limit */ - for (len = 0; (len < size) && ('\0' != str[len]); len++); + for (len = 0; (size == -1 || len < size) && ('\0' != str[len]); len++); new_str = malloc (len + 1); if (NULL == new_str) --- src/sandbox.h 2007/01/30 16:12:19 1.1 +++ src/sandbox.h 2007/01/30 16:14:39 @@ -103,6 +103,10 @@ long file_length(int fd); /* Compat functions for GNU extensions */ char *gstrndup (const char *str, size_t size); +#ifdef strdup +#undef strdup +#endif +#define strdup(s) gstrndup((s), -1) /* Same as basename(3), but do not modify path */ char *gbasename (const char *path);