From d2d7e672ad18c54aedfa766b7918d1631a22b4fa Mon Sep 17 00:00:00 2001 From: Ilya Enkovich Date: Tue, 10 Mar 2015 09:43:24 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 6 + gcc/c-family/c.opt | 3 + gcc/config/i386/linux-common.h | 16 +- libmpx/ChangeLog | 15 + libmpx/Makefile.am | 5 + libmpx/Makefile.in | 6 +- libmpx/configure | 48 ++- libmpx/configure.ac | 14 +- libmpx/mpxwrap/Makefile.am | 54 +++ libmpx/mpxwrap/Makefile.in | 542 ++++++++++++++++++++++++++++++ libmpx/mpxwrap/libmpxwrappers.map | 23 ++ libmpx/mpxwrap/libtool-version | 6 + libmpx/mpxwrap/mpx_wrappers.c | 278 +++++++++++++++ 13 files changed, 1009 insertions(+), 7 deletions(-) create mode 100644 libmpx/mpxwrap/Makefile.am create mode 100644 libmpx/mpxwrap/Makefile.in create mode 100644 libmpx/mpxwrap/libmpxwrappers.map create mode 100644 libmpx/mpxwrap/libtool-version create mode 100644 libmpx/mpxwrap/mpx_wrappers.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 60112885226..911c2ce7eee 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-03-10 Ilya Enkovich + + * 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 * config/i386/linux-common.h (LIBMPX_LIBS): New. diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index ac55d3c7142..5354500977a 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -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 diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h index 868274f2ea0..9c6560b695f 100644 --- a/gcc/config/i386/linux-common.h +++ b/gcc/config/i386/linux-common.h @@ -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 diff --git a/libmpx/ChangeLog b/libmpx/ChangeLog index 89dc042ee46..ccd706b1548 100644 --- a/libmpx/ChangeLog +++ b/libmpx/ChangeLog @@ -1,3 +1,18 @@ +2015-03-10 Ilya Enkovich + + * 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 Initial commit. diff --git a/libmpx/Makefile.am b/libmpx/Makefile.am index 6cee4ac00ac..bd0a8b6f93c 100644 --- a/libmpx/Makefile.am +++ b/libmpx/Makefile.am @@ -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 = diff --git a/libmpx/Makefile.in b/libmpx/Makefile.in index c61bd0a0a0f..203f08a6409 100644 --- a/libmpx/Makefile.in +++ b/libmpx/Makefile.in @@ -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 diff --git a/libmpx/configure b/libmpx/configure index 5c6e5608694..f3bd67d0443 100644 --- a/libmpx/configure +++ b/libmpx/configure @@ -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 @@ -17489,6 +17520,17 @@ _LT_EOF ;; "mpxrt/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;} + ;; + "mpxwrap/Makefile":F) cat > vpsed$$ << \_EOF +s!`test -f '$<' || echo '$(srcdir)/'`!! _EOF sed -f vpsed$$ $ac_file > tmp$$ mv tmp$$ $ac_file diff --git a/libmpx/configure.ac b/libmpx/configure.ac index dbfad023a99..4669525eabd 100644 --- a/libmpx/configure.ac +++ b/libmpx/configure.ac @@ -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 diff --git a/libmpx/mpxwrap/Makefile.am b/libmpx/mpxwrap/Makefile.am new file mode 100644 index 00000000000..72abccf8b8b --- /dev/null +++ b/libmpx/mpxwrap/Makefile.am @@ -0,0 +1,54 @@ +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 = + diff --git a/libmpx/mpxwrap/Makefile.in b/libmpx/mpxwrap/Makefile.in new file mode 100644 index 00000000000..9294d3e317d --- /dev/null +++ b/libmpx/mpxwrap/Makefile.in @@ -0,0 +1,542 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = mpxwrap +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/libstdc++-raw-cxx.m4 \ + $(top_srcdir)/../config/multi.m4 \ + $(top_srcdir)/../config/override.m4 \ + $(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \ + $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \ + $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac +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 = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(toolexeclibdir)" +LTLIBRARIES = $(toolexeclib_LTLIBRARIES) +libmpxwrappers_la_LIBADD = +am_libmpxwrappers_la_OBJECTS = libmpxwrappers_la-mpx_wrappers.lo +libmpxwrappers_la_OBJECTS = $(am_libmpxwrappers_la_OBJECTS) +libmpxwrappers_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(libmpxwrappers_la_CFLAGS) $(CFLAGS) \ + $(libmpxwrappers_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = +am__depfiles_maybe = +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libmpxwrappers_la_SOURCES) +ETAGS = etags +CTAGS = ctags +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBSTDCXX_RAW_CXX_CXXFLAGS = @LIBSTDCXX_RAW_CXX_CXXFLAGS@ +LIBSTDCXX_RAW_CXX_LDFLAGS = @LIBSTDCXX_RAW_CXX_LDFLAGS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XCFLAGS = @XCFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +enable_shared = @enable_shared@ +enable_static = @enable_static@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +link_libmpx = @link_libmpx@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +multi_basedir = @multi_basedir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_noncanonical = @target_noncanonical@ +target_os = @target_os@ +target_vendor = @target_vendor@ +toolexecdir = @toolexecdir@ +toolexeclibdir = @toolexeclibdir@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +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 = +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(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 ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign --ignore-deps mpxwrap/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign --ignore-deps mpxwrap/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 +$(am__aclocal_m4_deps): +install-toolexeclibLTLIBRARIES: $(toolexeclib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(toolexeclibdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibdir)" + @list='$(toolexeclib_LTLIBRARIES)'; test -n "$(toolexeclibdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(toolexeclibdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(toolexeclibdir)"; \ + } + +uninstall-toolexeclibLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(toolexeclib_LTLIBRARIES)'; test -n "$(toolexeclibdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(toolexeclibdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(toolexeclibdir)/$$f"; \ + done + +clean-toolexeclibLTLIBRARIES: + -test -z "$(toolexeclib_LTLIBRARIES)" || rm -f $(toolexeclib_LTLIBRARIES) + @list='$(toolexeclib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libmpxwrappers.la: $(libmpxwrappers_la_OBJECTS) $(libmpxwrappers_la_DEPENDENCIES) + $(libmpxwrappers_la_LINK) -rpath $(toolexeclibdir) $(libmpxwrappers_la_OBJECTS) $(libmpxwrappers_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +.c.o: + $(COMPILE) -c $< + +.c.obj: + $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: + $(LTCOMPILE) -c -o $@ $< + +libmpxwrappers_la-mpx_wrappers.lo: mpx_wrappers.c + $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmpxwrappers_la_CFLAGS) $(CFLAGS) -c -o libmpxwrappers_la-mpx_wrappers.lo `test -f 'mpx_wrappers.c' || echo '$(srcdir)/'`mpx_wrappers.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: + for dir in "$(DESTDIR)$(toolexeclibdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-toolexeclibLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-toolexeclibLTLIBRARIES + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-toolexeclibLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-toolexeclibLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip install-toolexeclibLTLIBRARIES installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-toolexeclibLTLIBRARIES + + +# 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: diff --git a/libmpx/mpxwrap/libmpxwrappers.map b/libmpx/mpxwrap/libmpxwrappers.map new file mode 100644 index 00000000000..c2912a7e18b --- /dev/null +++ b/libmpx/mpxwrap/libmpxwrappers.map @@ -0,0 +1,23 @@ +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: + *; +}; diff --git a/libmpx/mpxwrap/libtool-version b/libmpx/mpxwrap/libtool-version new file mode 100644 index 00000000000..bfe84c8af53 --- /dev/null +++ b/libmpx/mpxwrap/libtool-version @@ -0,0 +1,6 @@ +# 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 diff --git a/libmpx/mpxwrap/mpx_wrappers.c b/libmpx/mpxwrap/mpx_wrappers.c new file mode 100644 index 00000000000..ef4be8d0a39 --- /dev/null +++ b/libmpx/mpxwrap/mpx_wrappers.c @@ -0,0 +1,278 @@ +/* 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 + . */ + +#include "stdlib.h" +#include "string.h" +#include + +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; +} -- 2.30.2