Commit d2d7e672 by Ilya Enkovich Committed by Ilya Enkovich

linux-common.h (LIBMPX_WRAPPERSSPEC): New.

gcc/

	* config/i386/linux-common.h (LIBMPX_WRAPPERSSPEC): New.
	(CHKP_SPEC): Add wrappers library.
	* c-family/c.opt (static-libmpxwrappers): New.

libmpx/

	* Makefile.am (SUBDIRS): Add mpxwrap when used
	AS supports MPX.
	(MAKEOVERRIDES): New.
	* Makefile.in: Regenerate.
	* configure.ac: Check AS supports MPX.  Add
	mpxintr/Makefile to config files.
	* configure: Regenerate.
	* mpxwrap/Makefile.am: New.
	* mpxwrap/Makefile.in: New.
	* mpxwrap/libtool-version: New.
	* mpxwrap/mpx_wrappers.cc: New.
	* mpxwrap/libmpxwrappers.map: New.

From-SVN: r221313
parent ee8f136a
2015-03-10 Ilya Enkovich <ilya.enkovich@intel.com>
* config/i386/linux-common.h (LIBMPX_WRAPPERSSPEC): New.
(CHKP_SPEC): Add wrappers library.
* c-family/c.opt (static-libmpxwrappers): New.
2015-03-10 Ilya Enkovich <ilya.enkovich@intel.com>
* config/i386/linux-common.h (LIBMPX_LIBS): New.
(LIBMPX_SPEC): New.
(CHKP_SPEC): New.
......
......@@ -1044,6 +1044,9 @@ Instrument only functions marked with bnd_instrument attribute.
static-libmpx
Driver
static-libmpxwrappers
Driver
fcilkplus
C ObjC C++ ObjC++ LTO Report Var(flag_cilkplus) Init(0)
Enable Cilk Plus
......
......@@ -73,7 +73,21 @@ along with GCC; see the file COPYING3. If not see
#endif
#endif
#ifndef LIBMPXWRAPPERS_SPEC
#if defined(HAVE_LD_STATIC_DYNAMIC)
#define LIBMPXWRAPPERS_SPEC "\
%{mmpx:%{fcheck-pointer-bounds:%{!fno-chkp-use-wrappers:\
%{static:-lmpxwrappers}\
%{!static:%{static-libmpxwrappers:" LD_STATIC_OPTION " --whole-archive}\
-lmpxwrappers %{static-libmpxwrappers:--no-whole-archive "\
LD_DYNAMIC_OPTION "}}}}}"
#else
#define LIBMPXWRAPPERS_SPEC "\
%{mmpx:%{fcheck-pointer-bounds:{!fno-chkp-use-wrappers:-lmpxwrappers}}}"
#endif
#endif
#ifndef CHKP_SPEC
#define CHKP_SPEC "\
%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC "}}"
%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
#endif
2015-03-10 Ilya Enkovich <ilya.enkovich@intel.com>
* Makefile.am (SUBDIRS): Add mpxwrap when used
AS supports MPX.
(MAKEOVERRIDES): New.
* Makefile.in: Regenerate.
* configure.ac: Check AS supports MPX. Add
mpxintr/Makefile to config files.
* configure: Regenerate.
* mpxwrap/Makefile.am: New.
* mpxwrap/Makefile.in: New.
* mpxwrap/libtool-version: New.
* mpxwrap/mpx_wrappers.cc: New.
* mpxwrap/libmpxwrappers.map: New.
2015-03-10 Ilya Enkovich <ilya.enkovich@intel.com>
Initial commit.
......@@ -2,6 +2,9 @@ ACLOCAL_AMFLAGS = -I .. -I ../config
if LIBMPX_SUPPORTED
SUBDIRS = mpxrt
if MPX_AS_SUPPORTED
SUBDIRS += mpxwrap
endif
nodist_toolexeclib_HEADERS = libmpx.spec
endif
......@@ -45,3 +48,5 @@ AM_MAKEFLAGS = \
"PICFLAG=$(PICFLAG)" \
"RANLIB=$(RANLIB)" \
"DESTDIR=$(DESTDIR)"
MAKEOVERRIDES =
......@@ -35,6 +35,7 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
@LIBMPX_SUPPORTED_TRUE@@MPX_AS_SUPPORTED_TRUE@am__append_1 = mpxwrap
subdir = .
DIST_COMMON = ChangeLog $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/configure $(am__configure_deps) \
......@@ -102,7 +103,7 @@ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = mpxrt
DIST_SUBDIRS = mpxrt mpxwrap
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
......@@ -232,7 +233,7 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
ACLOCAL_AMFLAGS = -I .. -I ../config
@LIBMPX_SUPPORTED_TRUE@SUBDIRS = mpxrt
@LIBMPX_SUPPORTED_TRUE@SUBDIRS = mpxrt $(am__append_1)
@LIBMPX_SUPPORTED_TRUE@nodist_toolexeclib_HEADERS = libmpx.spec
gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
......@@ -274,6 +275,7 @@ AM_MAKEFLAGS = \
"RANLIB=$(RANLIB)" \
"DESTDIR=$(DESTDIR)"
MAKEOVERRIDES =
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
......
......@@ -621,6 +621,8 @@ LD
FGREP
SED
LIBTOOL
MPX_AS_SUPPORTED_FALSE
MPX_AS_SUPPORTED_TRUE
RANLIB
AR
AS
......@@ -5544,6 +5546,30 @@ else
fi
# Check we may build wrappers library
echo "test: bndmov %bnd0, %bnd1" > conftest.s
if { ac_try='$AS -o conftest.o conftest.s 1>&5'
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
(eval $ac_try) 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }
then
mpx_as=yes
else
mpx_as=no
echo "configure: no MPX support fo as" >&5
fi
rm -f conftest.o conftest.s
if test "x$mpx_as" = "xyes"; then
MPX_AS_SUPPORTED_TRUE=
MPX_AS_SUPPORTED_FALSE='#'
else
MPX_AS_SUPPORTED_TRUE='#'
MPX_AS_SUPPORTED_FALSE=
fi
# Configure libtool
enable_dlopen=yes
......@@ -11622,7 +11648,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11625 "configure"
#line 11651 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
......@@ -11728,7 +11754,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11731 "configure"
#line 11757 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
......@@ -14997,7 +15023,7 @@ ac_config_files="$ac_config_files Makefile libmpx.spec"
ac_config_headers="$ac_config_headers config.h"
ac_config_files="$ac_config_files mpxrt/Makefile"
ac_config_files="$ac_config_files mpxrt/Makefile mpxwrap/Makefile"
cat >confcache <<\_ACEOF
......@@ -15113,6 +15139,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
as_fn_error "conditional \"MAINTAINER_MODE\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${MPX_AS_SUPPORTED_TRUE}" && test -z "${MPX_AS_SUPPORTED_FALSE}"; then
as_fn_error "conditional \"MPX_AS_SUPPORTED\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
: ${CONFIG_STATUS=./config.status}
ac_write_fail=0
......@@ -16085,6 +16115,7 @@ do
"libmpx.spec") CONFIG_FILES="$CONFIG_FILES libmpx.spec" ;;
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
"mpxrt/Makefile") CONFIG_FILES="$CONFIG_FILES mpxrt/Makefile" ;;
"mpxwrap/Makefile") CONFIG_FILES="$CONFIG_FILES mpxwrap/Makefile" ;;
*) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
......@@ -17498,6 +17529,17 @@ _EOF
. ${multi_basedir}/config-ml.in
{ ml_norecursion=; unset ml_norecursion;}
;;
"mpxwrap/Makefile":F) cat > vpsed$$ << \_EOF
s!`test -f '$<' || echo '$(srcdir)/'`!!
_EOF
sed -f vpsed$$ $ac_file > tmp$$
mv tmp$$ $ac_file
rm vpsed$$
echo 'MULTISUBDIR =' >> $ac_file
ml_norecursion=yes
. ${multi_basedir}/config-ml.in
{ ml_norecursion=; unset ml_norecursion;}
;;
esac
done # for ac_tag
......
......@@ -100,6 +100,18 @@ AC_CHECK_TOOL(AS, as)
AC_CHECK_TOOL(AR, ar)
AC_CHECK_TOOL(RANLIB, ranlib, :)
# Check we may build wrappers library
echo "test: bndmov %bnd0, %bnd1" > conftest.s
if AC_TRY_COMMAND([$AS -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
then
mpx_as=yes
else
mpx_as=no
echo "configure: no MPX support fo as" >&AS_MESSAGE_LOG_FD
fi
rm -f conftest.o conftest.s
AM_CONDITIONAL(MPX_AS_SUPPORTED, [test "x$mpx_as" = "xyes"])
# Configure libtool
AC_LIBTOOL_DLOPEN
AM_PROG_LIBTOOL
......@@ -117,7 +129,7 @@ fi
AC_CONFIG_FILES([Makefile libmpx.spec])
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_FILES(AC_FOREACH([DIR], [mpxrt], [DIR/Makefile]),
AC_CONFIG_FILES(AC_FOREACH([DIR], [mpxrt mpxwrap], [DIR/Makefile ]),
[cat > vpsed$$ << \_EOF
s!`test -f '$<' || echo '$(srcdir)/'`!!
_EOF
......
ALCLOCAL_AMFLAGS = -I .. -I ../config
# May be used by toolexeclibdir.
gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
libmpxwrappers_la_CFLAGS = -fcheck-pointer-bounds -mmpx -fno-chkp-check-read \
-fno-chkp-check-write -fno-chkp-use-wrappers -fPIC
libmpxwrappers_la_DEPENDENCIES = libmpxwrappers.map
libmpxwrappers_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libmpxwrappers.map
toolexeclib_LTLIBRARIES = libmpxwrappers.la
libmpxwrappers_la_SOURCES = mpx_wrappers.c
# Work around what appears to be a GNU make bug handling MAKEFLAGS
# values defined in terms of make variables, as is the case for CC and
# friends when we are called from the top level Makefile.
AM_MAKEFLAGS = \
"AR_FLAGS=$(AR_FLAGS)" \
"CC_FOR_BUILD=$(CC_FOR_BUILD)" \
"CFLAGS=$(CFLAGS)" \
"CXXFLAGS=$(CXXFLAGS)" \
"CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
"CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
"INSTALL=$(INSTALL)" \
"INSTALL_DATA=$(INSTALL_DATA)" \
"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
"INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
"JC1FLAGS=$(JC1FLAGS)" \
"LDFLAGS=$(LDFLAGS)" \
"LIBCFLAGS=$(LIBCFLAGS)" \
"LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
"MAKE=$(MAKE)" \
"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
"PICFLAG=$(PICFLAG)" \
"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
"SHELL=$(SHELL)" \
"RUNTESTFLAGS=$(RUNTESTFLAGS)" \
"exec_prefix=$(exec_prefix)" \
"infodir=$(infodir)" \
"libdir=$(libdir)" \
"prefix=$(prefix)" \
"includedir=$(includedir)" \
"AR=$(AR)" \
"AS=$(AS)" \
"LD=$(LD)" \
"LIBCFLAGS=$(LIBCFLAGS)" \
"NM=$(NM)" \
"PICFLAG=$(PICFLAG)" \
"RANLIB=$(RANLIB)" \
"DESTDIR=$(DESTDIR)"
MAKEOVERRIDES =
LIBMPXWRAPPERS_1.0
{
global:
__mpx_wrapper_malloc;
__mpx_wrapper_mmap;
__mpx_wrapper_realloc;
__mpx_wrapper_calloc;
__mpx_wrapper_memset;
__mpx_wrapper_bzero;
__mpx_wrapper_memmove;
__mpx_wrapper_memcpy;
__mpx_wrapper_mempcpy;
__mpx_wrapper_strncat;
__mpx_wrapper_strcat;
__mpx_wrapper_stpcpy;
__mpx_wrapper_stpncpy;
__mpx_wrapper_strcpy;
__mpx_wrapper_strncpy;
__mpx_wrapper_strlen;
local:
*;
};
# This file is used to maintain libtool version info for libmpxintr. See
# the libtool manual to understand the meaning of the fields. This is
# a separate file so that version updates don't involve re-running
# automake.
# CURRENT:REVISION:AGE
1:0:0
/* MPX Wrappers Library
Copyright (C) 2014 Free Software Foundation, Inc.
Contributed by Ilya Enkovich (ilya.enkovich@intel.com)
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#include "stdlib.h"
#include "string.h"
#include <sys/mman.h>
void *
__mpx_wrapper_malloc (size_t size)
{
void *p = (void *)malloc (size);
if (!p) return __bnd_null_ptr_bounds (p);
return __bnd_set_ptr_bounds (p, size);
}
void *
__mpx_wrapper_mmap (void *addr, size_t length, int prot, int flags,
int fd, off_t offset)
{
void *p = mmap (addr, length, prot, flags, fd, offset);
if (!p) return __bnd_null_ptr_bounds (p);
return __bnd_set_ptr_bounds (p, length);
}
void *
__mpx_wrapper_realloc (void *ptr, size_t n)
{
if (!ptr)
return __mpx_wrapper_malloc (n);
/* We don't kwnow how much data is copied by realloc
and therefore may check only lower bounds. */
__bnd_chk_ptr_lbounds (ptr);
ptr = realloc (ptr, n);
if (!ptr)
return __bnd_null_ptr_bounds (ptr);
return __bnd_set_ptr_bounds (ptr, n);
}
void *
__mpx_wrapper_calloc (size_t n_elements, size_t element_size)
{
void *p = calloc (n_elements, element_size);
if (!p)
return __bnd_null_ptr_bounds (p);
return __bnd_set_ptr_bounds (p, n_elements * element_size);
}
void *
__mpx_wrapper_memset (void *dstpp, int c, size_t len)
{
if (len > 0)
{
__bnd_chk_ptr_bounds (dstpp, len);
memset (dstpp, c, len);
}
return dstpp;
}
void
__mpx_wrapper_bzero (void *dst, size_t len)
{
__mpx_wrapper_memset (dst, 0, len);
}
void *
__mpx_wrapper_memmove (void *dst, const void *src, size_t n)
{
const char *s = (const char*)src;
char *d = (char*)dst;
void *ret = dst;
size_t offset_src = ((size_t) s) & (sizeof (void *) - 1);
size_t offset_dst = ((size_t) d) & (sizeof (void *) - 1);
__bnd_chk_ptr_bounds (dst, n);
__bnd_chk_ptr_bounds (src, n);
/* Different alignment means that even if
pointers exist in memory, we don't how
pointers are aligned and therefore cann't
copy bounds anyway. */
if (offset_src != offset_dst)
memmove (dst, src, n);
else
{
if (s < d)
{
d += n;
s += n;
offset_src = (offset_src + n) & (sizeof (void *) -1);
while (n-- && offset_src--)
*--d = *--s;
n++;
if (!n)
return ret;
void **d1 = (void **)d;
void **s1 = (void **)s;
/* This loop will also copy bounds. */
while (n >= sizeof (void *))
{
n -= sizeof (void *);
*--d1 = *--s1;
}
s = (char *)s1;
d = (char *)d1;
while (n--)
*--d = *--s;
}
else
{
offset_src = sizeof (void *) - offset_src;
while (n-- && offset_src--)
*d++ = *s++;
n++;
if (!n)
return ret;
void **d1 = (void **)d;
void **s1 = (void **)s;
/* This loop will also copy bounds. */
while (n >= sizeof (void *))
{
n -= sizeof (void *);
*d1++ = *s1++;
}
s = (char *)s1;
d = (char *)d1;
while (n--)
*d++ = *s++;
}
}
return ret;
}
void *
__mpx_wrapper_memcpy (void *dst, const void *src, size_t n)
{
return __mpx_wrapper_memmove (dst, src, n);
}
void *
__mpx_wrapper_mempcpy (void *dst, const void *src, size_t n)
{
return (char *)__mpx_wrapper_memcpy (dst, src, n) + n;
}
char *
__mpx_wrapper_strncat (char *dst, const char *src, size_t n)
{
size_t dst_size = strlen (dst);
size_t src_size = strnlen (src, n);
__bnd_chk_ptr_bounds (dst, dst_size + src_size + 1);
if (src_size < n)
__bnd_chk_ptr_bounds (src, src_size + 1);
else
__bnd_chk_ptr_bounds (src, src_size);
strncat (dst, src, n);
return dst;
}
char *
__mpx_wrapper_strcat (char *dst, const char *src)
{
size_t dst_size = strlen (dst);
size_t src_size = strlen (src);
__bnd_chk_ptr_bounds (dst, dst_size + src_size + 1);
__bnd_chk_ptr_bounds (src, src_size + 1);
strcat (dst, src);
return dst;
}
char *
__mpx_wrapper_stpcpy (char *dst, const char *src)
{
size_t src_size = strlen (src);
__bnd_chk_ptr_bounds (dst, src_size + 1);
__bnd_chk_ptr_bounds (src, src_size + 1);
memcpy (dst, src, src_size + 1);
return dst + src_size;
}
char *
__mpx_wrapper_stpncpy (char *dst, const char *src, size_t n)
{
size_t src_size = strnlen (src, n);
char *res;
__bnd_chk_ptr_bounds (dst, n);
if (src_size < n)
{
__bnd_chk_ptr_bounds (src, src_size + 1);
res = dst + src_size;
}
else
{
__bnd_chk_ptr_bounds (src, src_size);
res = dst + n;
}
memcpy (dst, src, src_size);
if (n > src_size)
memset (dst + src_size, 0, n - src_size);
return res;
}
char *
__mpx_wrapper_strcpy (char *dst, const char *src)
{
size_t src_size = strlen (src);
__bnd_chk_ptr_bounds (dst, src_size + 1);
__bnd_chk_ptr_bounds (src, src_size + 1);
memcpy (dst, src, src_size + 1);
return dst;
}
char *
__mpx_wrapper_strncpy (char *dst, const char *src, size_t n)
{
size_t src_size = strnlen (src, n);
__bnd_chk_ptr_bounds (dst, n);
if (src_size < n)
__bnd_chk_ptr_bounds (src, src_size + 1);
else
__bnd_chk_ptr_bounds (src, src_size);
memcpy (dst, src, src_size);
if (n > src_size)
memset (dst + src_size, 0, n - src_size);
return dst;
}
size_t
__mpx_wrapper_strlen (const char *s)
{
size_t length = strlen (s);
__bnd_chk_ptr_bounds (s, length + 1);
return length;
}
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