+2015-04-02 Ilya Enkovich <ilya.enkovich@intel.com>
+
+ PR driver/65444
+ * config/i386/linux-common.h (MPX_SPEC): New.
+ (CHKP_SPEC): Add MPX_SPEC.
+ * doc/invoke.texi (-fcheck-pointer-boudns): Document
+ possible issues with '-z bndplt' support in linker.
+
2015-04-02 Uros Bizjak <ubizjak@gmail.com>
* config/i386/sync.md (UNSPEC_FILD_ATOMIC, UNSPEC_FIST_ATOMIC): New.
%:include(libmpx.spec)%(link_libmpx)"
#endif
+#ifndef MPX_SPEC
+#define MPX_SPEC "\
+ %{mmpx:%{fcheck-pointer-bounds:%{!static:%:include(libmpx.spec)%(link_mpx)}}}"
+#endif
+
#ifndef LIBMPX_SPEC
#if defined(HAVE_LD_STATIC_DYNAMIC)
#define LIBMPX_SPEC "\
#ifndef CHKP_SPEC
#define CHKP_SPEC "\
-%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
+%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
#endif
a runtime library to enable MPX in hardware and handle bounds
violation signals. By default when @option{-fcheck-pointer-bounds}
and @option{-mmpx} options are used to link a program, the GCC driver
-links against the @file{libmpx} runtime library. MPX-based instrumentation
+links against the @file{libmpx} runtime library and @file{libmpxwrappers}
+library. It also passes '-z bndplt' to a linker in case it supports this
+option (which is checked on libmpx configuration). Note that old versions
+of linker may ignore option. Gold linker doesn't support '-z bndplt'
+option. With no '-z bndplt' support in linker all calls to dynamic libraries
+lose passed bounds reducing overall protection level. It's highly
+recommended to use linker with '-z bndplt' support. In case such linker
+is not available it is adviced to always use @option{-static-libmpxwrappers}
+for better protection level or use @option{-static} to completely avoid
+external calls to dynamic libraries. MPX-based instrumentation
may be used for debugging and also may be included in production code
to increase program security. Depending on usage, you may
have different requirements for the runtime library. The current version
+2015-04-02 Ilya Enkovich <ilya.enkovich@intel.com>
+
+ PR driver/65444
+ * configure.ac: Add check for '-z bndplt' support
+ by linker. Add link_mpx output variable.
+ * libmpx.spec.in (link_mpx): New.
+ * configure: Regenerate.
+
2015-03-12 Ilya Enkovich <ilya.enkovich@intel.com>
PR other/65384
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
+link_mpx
link_libmpx
LIBMPX_SUPPORTED_FALSE
LIBMPX_SUPPORTED_TRUE
link_libmpx="-lpthread"
+link_mpx=""
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ld accepts -z bndplt" >&5
+$as_echo_n "checking whether ld accepts -z bndplt... " >&6; }
+echo "int main() {};" > conftest.c
+if { ac_try='${CC} ${CFLAGS} -Wl,-z,bndplt -o conftest conftest.c 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
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ link_mpx="$link_mpx -z bndplt"
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
am__api_version='1.11'
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11651 "configure"
+#line 11671 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11757 "configure"
+#line 11777 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
AM_CONDITIONAL(LIBMPX_SUPPORTED, [test "x$LIBMPX_SUPPORTED" = "xyes"])
link_libmpx="-lpthread"
+link_mpx=""
+AC_MSG_CHECKING([whether ld accepts -z bndplt])
+echo "int main() {};" > conftest.c
+if AC_TRY_COMMAND([${CC} ${CFLAGS} -Wl,-z,bndplt -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
+then
+ AC_MSG_RESULT([yes])
+ link_mpx="$link_mpx -z bndplt"
+else
+ AC_MSG_RESULT([no])
+fi
AC_SUBST(link_libmpx)
+AC_SUBST(link_mpx)
AM_INIT_AUTOMAKE(foreign no-dist no-dependencies)
AM_ENABLE_MULTILIB(, ..)
# This spec file is read by gcc when linking. It is used to specify the
-# standard libraries we need in order to link with libcilkrts.
+# standard libraries we need in order to link with libmpx.
*link_libmpx: @link_libmpx@
+
+*link_mpx: @link_mpx@