public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
@ 2015-03-18 11:56 Ilya Enkovich
  2015-03-18 12:03 ` H.J. Lu
  2015-03-23 10:19 ` Ilya Enkovich
  0 siblings, 2 replies; 49+ messages in thread
From: Ilya Enkovich @ 2015-03-18 11:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: ubizjak

Hi,

This patch fixes PR target/65444 by passing '-z bndplt' to linker when appropriate.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  Will commit it to trunk in a couple of days if no objections arise.

Thanks,
Ilya
--
gcc/

2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>

	PR driver/65444
	* config/i386/linux-common.h (MPX_SPEC): New.
	(CHKP_SPEC): Add MPX_SPEC.

libmpx/

2015-03-18  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.


diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
index 9c6560b..dd79ec6 100644
--- a/gcc/config/i386/linux-common.h
+++ b/gcc/config/i386/linux-common.h
@@ -59,6 +59,11 @@ along with GCC; see the file COPYING3.  If not see
  %: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 "\
@@ -89,5 +94,5 @@ along with GCC; see the file COPYING3.  If not see
 
 #ifndef CHKP_SPEC
 #define CHKP_SPEC "\
-%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
+%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
 #endif
diff --git a/libmpx/configure.ac b/libmpx/configure.ac
index fe0d3f2..3f8b50f 100644
--- a/libmpx/configure.ac
+++ b/libmpx/configure.ac
@@ -40,7 +40,18 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
 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(, ..)
diff --git a/libmpx/libmpx.spec.in b/libmpx/libmpx.spec.in
index a265e28..34d0bdf 100644
--- a/libmpx/libmpx.spec.in
+++ b/libmpx/libmpx.spec.in
@@ -1,3 +1,5 @@
 # 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@

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 11:56 [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX Ilya Enkovich
@ 2015-03-18 12:03 ` H.J. Lu
  2015-03-18 12:05   ` Ilya Enkovich
  2015-03-23 10:19 ` Ilya Enkovich
  1 sibling, 1 reply; 49+ messages in thread
From: H.J. Lu @ 2015-03-18 12:03 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: GCC Patches, Uros Bizjak

On Wed, Mar 18, 2015 at 4:56 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> Hi,
>
> This patch fixes PR target/65444 by passing '-z bndplt' to linker when appropriate.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  Will commit it to trunk in a couple of days if no objections arise.
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>
>         PR driver/65444
>         * config/i386/linux-common.h (MPX_SPEC): New.
>         (CHKP_SPEC): Add MPX_SPEC.
>
> libmpx/
>
> 2015-03-18  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.
>
>
> diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
> index 9c6560b..dd79ec6 100644
> --- a/gcc/config/i386/linux-common.h
> +++ b/gcc/config/i386/linux-common.h
> @@ -59,6 +59,11 @@ along with GCC; see the file COPYING3.  If not see
>   %: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 "\
> @@ -89,5 +94,5 @@ along with GCC; see the file COPYING3.  If not see
>
>  #ifndef CHKP_SPEC
>  #define CHKP_SPEC "\
> -%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
> +%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
>  #endif
> diff --git a/libmpx/configure.ac b/libmpx/configure.ac
> index fe0d3f2..3f8b50f 100644
> --- a/libmpx/configure.ac
> +++ b/libmpx/configure.ac
> @@ -40,7 +40,18 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
>  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)
>

Without -z bndplt, MPX won't work correctly.  We should always pass -z bndplt
to linker.  If linker doesn't support it, ld will issue a warning, not
error and users
will know their linker is too old.  When they update linker, they don't have to
rebuild GCC.


-- 
H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 12:03 ` H.J. Lu
@ 2015-03-18 12:05   ` Ilya Enkovich
  2015-03-18 12:08     ` H.J. Lu
  0 siblings, 1 reply; 49+ messages in thread
From: Ilya Enkovich @ 2015-03-18 12:05 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GCC Patches, Uros Bizjak

2015-03-18 15:02 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
> On Wed, Mar 18, 2015 at 4:56 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> Hi,
>>
>> This patch fixes PR target/65444 by passing '-z bndplt' to linker when appropriate.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  Will commit it to trunk in a couple of days if no objections arise.
>>
>> Thanks,
>> Ilya
>> --
>> gcc/
>>
>> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>>
>>         PR driver/65444
>>         * config/i386/linux-common.h (MPX_SPEC): New.
>>         (CHKP_SPEC): Add MPX_SPEC.
>>
>> libmpx/
>>
>> 2015-03-18  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.
>>
>>
>> diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
>> index 9c6560b..dd79ec6 100644
>> --- a/gcc/config/i386/linux-common.h
>> +++ b/gcc/config/i386/linux-common.h
>> @@ -59,6 +59,11 @@ along with GCC; see the file COPYING3.  If not see
>>   %: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 "\
>> @@ -89,5 +94,5 @@ along with GCC; see the file COPYING3.  If not see
>>
>>  #ifndef CHKP_SPEC
>>  #define CHKP_SPEC "\
>> -%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
>> +%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
>>  #endif
>> diff --git a/libmpx/configure.ac b/libmpx/configure.ac
>> index fe0d3f2..3f8b50f 100644
>> --- a/libmpx/configure.ac
>> +++ b/libmpx/configure.ac
>> @@ -40,7 +40,18 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
>>  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)
>>
>
> Without -z bndplt, MPX won't work correctly.  We should always pass -z bndplt
> to linker.  If linker doesn't support it, ld will issue a warning, not
> error and users
> will know their linker is too old.  When they update linker, they don't have to
> rebuild GCC.

If ld issues a warning instead of an error, then configure test passes
and we pass '-z bndplt' to linker.

Ilya

>1
>
> --
> H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 12:05   ` Ilya Enkovich
@ 2015-03-18 12:08     ` H.J. Lu
  2015-03-18 12:13       ` Ilya Enkovich
  0 siblings, 1 reply; 49+ messages in thread
From: H.J. Lu @ 2015-03-18 12:08 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: GCC Patches, Uros Bizjak

On Wed, Mar 18, 2015 at 5:05 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> 2015-03-18 15:02 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>> On Wed, Mar 18, 2015 at 4:56 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>> Hi,
>>>
>>> This patch fixes PR target/65444 by passing '-z bndplt' to linker when appropriate.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  Will commit it to trunk in a couple of days if no objections arise.
>>>
>>> Thanks,
>>> Ilya
>>> --
>>> gcc/
>>>
>>> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>>>
>>>         PR driver/65444
>>>         * config/i386/linux-common.h (MPX_SPEC): New.
>>>         (CHKP_SPEC): Add MPX_SPEC.
>>>
>>> libmpx/
>>>
>>> 2015-03-18  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.
>>>
>>>
>>> diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
>>> index 9c6560b..dd79ec6 100644
>>> --- a/gcc/config/i386/linux-common.h
>>> +++ b/gcc/config/i386/linux-common.h
>>> @@ -59,6 +59,11 @@ along with GCC; see the file COPYING3.  If not see
>>>   %: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 "\
>>> @@ -89,5 +94,5 @@ along with GCC; see the file COPYING3.  If not see
>>>
>>>  #ifndef CHKP_SPEC
>>>  #define CHKP_SPEC "\
>>> -%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
>>> +%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
>>>  #endif
>>> diff --git a/libmpx/configure.ac b/libmpx/configure.ac
>>> index fe0d3f2..3f8b50f 100644
>>> --- a/libmpx/configure.ac
>>> +++ b/libmpx/configure.ac
>>> @@ -40,7 +40,18 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
>>>  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)
>>>
>>
>> Without -z bndplt, MPX won't work correctly.  We should always pass -z bndplt
>> to linker.  If linker doesn't support it, ld will issue a warning, not
>> error and users
>> will know their linker is too old.  When they update linker, they don't have to
>> rebuild GCC.
>
> If ld issues a warning instead of an error, then configure test passes
> and we pass '-z bndplt' to linker.
>

Can you verify it with an older linker? The unknown XXX in -z XXX is always
warned and ignored in Linux linker.  If testing it on Linux always passes,
it is useless.

-- 
H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 12:08     ` H.J. Lu
@ 2015-03-18 12:13       ` Ilya Enkovich
  2015-03-18 12:25         ` H.J. Lu
  0 siblings, 1 reply; 49+ messages in thread
From: Ilya Enkovich @ 2015-03-18 12:13 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GCC Patches, Uros Bizjak

2015-03-18 15:08 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
> On Wed, Mar 18, 2015 at 5:05 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> 2015-03-18 15:02 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>> On Wed, Mar 18, 2015 at 4:56 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>> Hi,
>>>>
>>>> This patch fixes PR target/65444 by passing '-z bndplt' to linker when appropriate.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  Will commit it to trunk in a couple of days if no objections arise.
>>>>
>>>> Thanks,
>>>> Ilya
>>>> --
>>>> gcc/
>>>>
>>>> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>>>>
>>>>         PR driver/65444
>>>>         * config/i386/linux-common.h (MPX_SPEC): New.
>>>>         (CHKP_SPEC): Add MPX_SPEC.
>>>>
>>>> libmpx/
>>>>
>>>> 2015-03-18  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.
>>>>
>>>>
>>>> diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
>>>> index 9c6560b..dd79ec6 100644
>>>> --- a/gcc/config/i386/linux-common.h
>>>> +++ b/gcc/config/i386/linux-common.h
>>>> @@ -59,6 +59,11 @@ along with GCC; see the file COPYING3.  If not see
>>>>   %: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 "\
>>>> @@ -89,5 +94,5 @@ along with GCC; see the file COPYING3.  If not see
>>>>
>>>>  #ifndef CHKP_SPEC
>>>>  #define CHKP_SPEC "\
>>>> -%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
>>>> +%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
>>>>  #endif
>>>> diff --git a/libmpx/configure.ac b/libmpx/configure.ac
>>>> index fe0d3f2..3f8b50f 100644
>>>> --- a/libmpx/configure.ac
>>>> +++ b/libmpx/configure.ac
>>>> @@ -40,7 +40,18 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
>>>>  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)
>>>>
>>>
>>> Without -z bndplt, MPX won't work correctly.  We should always pass -z bndplt
>>> to linker.  If linker doesn't support it, ld will issue a warning, not
>>> error and users
>>> will know their linker is too old.  When they update linker, they don't have to
>>> rebuild GCC.
>>
>> If ld issues a warning instead of an error, then configure test passes
>> and we pass '-z bndplt' to linker.
>>
>
> Can you verify it with an older linker? The unknown XXX in -z XXX is always
> warned and ignored in Linux linker.  If testing it on Linux always passes,
> it is useless.

Old ld issues a warning:

ld: warning: -z bndplt ignored.

But gold issues an error:

ld.gold: bndplt: unknown -z option
ld.gold: use the --help option for usage information

Ilya

>
> --
> H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 12:13       ` Ilya Enkovich
@ 2015-03-18 12:25         ` H.J. Lu
  2015-03-18 12:42           ` Richard Biener
  0 siblings, 1 reply; 49+ messages in thread
From: H.J. Lu @ 2015-03-18 12:25 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: GCC Patches, Uros Bizjak

On Wed, Mar 18, 2015 at 5:13 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> 2015-03-18 15:08 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>> On Wed, Mar 18, 2015 at 5:05 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>> 2015-03-18 15:02 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>> On Wed, Mar 18, 2015 at 4:56 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>> Hi,
>>>>>
>>>>> This patch fixes PR target/65444 by passing '-z bndplt' to linker when appropriate.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  Will commit it to trunk in a couple of days if no objections arise.
>>>>>
>>>>> Thanks,
>>>>> Ilya
>>>>> --
>>>>> gcc/
>>>>>
>>>>> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>>>>>
>>>>>         PR driver/65444
>>>>>         * config/i386/linux-common.h (MPX_SPEC): New.
>>>>>         (CHKP_SPEC): Add MPX_SPEC.
>>>>>
>>>>> libmpx/
>>>>>
>>>>> 2015-03-18  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.
>>>>>
>>>>>
>>>>> diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
>>>>> index 9c6560b..dd79ec6 100644
>>>>> --- a/gcc/config/i386/linux-common.h
>>>>> +++ b/gcc/config/i386/linux-common.h
>>>>> @@ -59,6 +59,11 @@ along with GCC; see the file COPYING3.  If not see
>>>>>   %: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 "\
>>>>> @@ -89,5 +94,5 @@ along with GCC; see the file COPYING3.  If not see
>>>>>
>>>>>  #ifndef CHKP_SPEC
>>>>>  #define CHKP_SPEC "\
>>>>> -%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
>>>>> +%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
>>>>>  #endif
>>>>> diff --git a/libmpx/configure.ac b/libmpx/configure.ac
>>>>> index fe0d3f2..3f8b50f 100644
>>>>> --- a/libmpx/configure.ac
>>>>> +++ b/libmpx/configure.ac
>>>>> @@ -40,7 +40,18 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
>>>>>  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)
>>>>>
>>>>
>>>> Without -z bndplt, MPX won't work correctly.  We should always pass -z bndplt
>>>> to linker.  If linker doesn't support it, ld will issue a warning, not
>>>> error and users
>>>> will know their linker is too old.  When they update linker, they don't have to
>>>> rebuild GCC.
>>>
>>> If ld issues a warning instead of an error, then configure test passes
>>> and we pass '-z bndplt' to linker.
>>>
>>
>> Can you verify it with an older linker? The unknown XXX in -z XXX is always
>> warned and ignored in Linux linker.  If testing it on Linux always passes,
>> it is useless.
>
> Old ld issues a warning:
>
> ld: warning: -z bndplt ignored.

Does configure test pass?

> But gold issues an error:
>
> ld.gold: bndplt: unknown -z option
> ld.gold: use the --help option for usage information

If gold is used, MPX won't work.  What should we do here?
Should we hardcode -fuse-ld=bfd for MPX?

-- 
H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 12:25         ` H.J. Lu
@ 2015-03-18 12:42           ` Richard Biener
  2015-03-18 13:24             ` Ilya Enkovich
  0 siblings, 1 reply; 49+ messages in thread
From: Richard Biener @ 2015-03-18 12:42 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Ilya Enkovich, GCC Patches, Uros Bizjak

On Wed, Mar 18, 2015 at 1:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Mar 18, 2015 at 5:13 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> 2015-03-18 15:08 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>> On Wed, Mar 18, 2015 at 5:05 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>> 2015-03-18 15:02 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>>> On Wed, Mar 18, 2015 at 4:56 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> This patch fixes PR target/65444 by passing '-z bndplt' to linker when appropriate.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  Will commit it to trunk in a couple of days if no objections arise.
>>>>>>
>>>>>> Thanks,
>>>>>> Ilya
>>>>>> --
>>>>>> gcc/
>>>>>>
>>>>>> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>>>>>>
>>>>>>         PR driver/65444
>>>>>>         * config/i386/linux-common.h (MPX_SPEC): New.
>>>>>>         (CHKP_SPEC): Add MPX_SPEC.
>>>>>>
>>>>>> libmpx/
>>>>>>
>>>>>> 2015-03-18  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.
>>>>>>
>>>>>>
>>>>>> diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
>>>>>> index 9c6560b..dd79ec6 100644
>>>>>> --- a/gcc/config/i386/linux-common.h
>>>>>> +++ b/gcc/config/i386/linux-common.h
>>>>>> @@ -59,6 +59,11 @@ along with GCC; see the file COPYING3.  If not see
>>>>>>   %: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 "\
>>>>>> @@ -89,5 +94,5 @@ along with GCC; see the file COPYING3.  If not see
>>>>>>
>>>>>>  #ifndef CHKP_SPEC
>>>>>>  #define CHKP_SPEC "\
>>>>>> -%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
>>>>>> +%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
>>>>>>  #endif
>>>>>> diff --git a/libmpx/configure.ac b/libmpx/configure.ac
>>>>>> index fe0d3f2..3f8b50f 100644
>>>>>> --- a/libmpx/configure.ac
>>>>>> +++ b/libmpx/configure.ac
>>>>>> @@ -40,7 +40,18 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
>>>>>>  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)
>>>>>>
>>>>>
>>>>> Without -z bndplt, MPX won't work correctly.  We should always pass -z bndplt
>>>>> to linker.  If linker doesn't support it, ld will issue a warning, not
>>>>> error and users
>>>>> will know their linker is too old.  When they update linker, they don't have to
>>>>> rebuild GCC.
>>>>
>>>> If ld issues a warning instead of an error, then configure test passes
>>>> and we pass '-z bndplt' to linker.
>>>>
>>>
>>> Can you verify it with an older linker? The unknown XXX in -z XXX is always
>>> warned and ignored in Linux linker.  If testing it on Linux always passes,
>>> it is useless.
>>
>> Old ld issues a warning:
>>
>> ld: warning: -z bndplt ignored.
>
> Does configure test pass?
>
>> But gold issues an error:
>>
>> ld.gold: bndplt: unknown -z option
>> ld.gold: use the --help option for usage information
>
> If gold is used, MPX won't work.  What should we do here?
> Should we hardcode -fuse-ld=bfd for MPX?

Is MPX disabled when the host linker is gold and gld isn't available?

Richard.

> --
> H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 12:42           ` Richard Biener
@ 2015-03-18 13:24             ` Ilya Enkovich
  2015-03-18 13:32               ` H.J. Lu
  0 siblings, 1 reply; 49+ messages in thread
From: Ilya Enkovich @ 2015-03-18 13:24 UTC (permalink / raw)
  To: Richard Biener; +Cc: H.J. Lu, GCC Patches, Uros Bizjak

2015-03-18 15:42 GMT+03:00 Richard Biener <richard.guenther@gmail.com>:
> On Wed, Mar 18, 2015 at 1:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Wed, Mar 18, 2015 at 5:13 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>> 2015-03-18 15:08 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>> On Wed, Mar 18, 2015 at 5:05 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>> 2015-03-18 15:02 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>>>> On Wed, Mar 18, 2015 at 4:56 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> This patch fixes PR target/65444 by passing '-z bndplt' to linker when appropriate.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  Will commit it to trunk in a couple of days if no objections arise.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Ilya
>>>>>>> --
>>>>>>> gcc/
>>>>>>>
>>>>>>> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>>>>>>>
>>>>>>>         PR driver/65444
>>>>>>>         * config/i386/linux-common.h (MPX_SPEC): New.
>>>>>>>         (CHKP_SPEC): Add MPX_SPEC.
>>>>>>>
>>>>>>> libmpx/
>>>>>>>
>>>>>>> 2015-03-18  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.
>>>>>>>
>>>>>>>
>>>>>>> diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
>>>>>>> index 9c6560b..dd79ec6 100644
>>>>>>> --- a/gcc/config/i386/linux-common.h
>>>>>>> +++ b/gcc/config/i386/linux-common.h
>>>>>>> @@ -59,6 +59,11 @@ along with GCC; see the file COPYING3.  If not see
>>>>>>>   %: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 "\
>>>>>>> @@ -89,5 +94,5 @@ along with GCC; see the file COPYING3.  If not see
>>>>>>>
>>>>>>>  #ifndef CHKP_SPEC
>>>>>>>  #define CHKP_SPEC "\
>>>>>>> -%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
>>>>>>> +%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
>>>>>>>  #endif
>>>>>>> diff --git a/libmpx/configure.ac b/libmpx/configure.ac
>>>>>>> index fe0d3f2..3f8b50f 100644
>>>>>>> --- a/libmpx/configure.ac
>>>>>>> +++ b/libmpx/configure.ac
>>>>>>> @@ -40,7 +40,18 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
>>>>>>>  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)
>>>>>>>
>>>>>>
>>>>>> Without -z bndplt, MPX won't work correctly.  We should always pass -z bndplt
>>>>>> to linker.  If linker doesn't support it, ld will issue a warning, not
>>>>>> error and users
>>>>>> will know their linker is too old.  When they update linker, they don't have to
>>>>>> rebuild GCC.
>>>>>
>>>>> If ld issues a warning instead of an error, then configure test passes
>>>>> and we pass '-z bndplt' to linker.
>>>>>
>>>>
>>>> Can you verify it with an older linker? The unknown XXX in -z XXX is always
>>>> warned and ignored in Linux linker.  If testing it on Linux always passes,
>>>> it is useless.
>>>
>>> Old ld issues a warning:
>>>
>>> ld: warning: -z bndplt ignored.
>>
>> Does configure test pass?
>>
>>> But gold issues an error:
>>>
>>> ld.gold: bndplt: unknown -z option
>>> ld.gold: use the --help option for usage information
>>
>> If gold is used, MPX won't work.  What should we do here?
>> Should we hardcode -fuse-ld=bfd for MPX?
>
> Is MPX disabled when the host linker is gold and gld isn't available?

No. You may use MPX with gold and old ld but you would loose passed
bounds when make a call via plt.

Ilya

>
> Richard.
>
>> --
>> H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 13:24             ` Ilya Enkovich
@ 2015-03-18 13:32               ` H.J. Lu
  2015-03-18 13:41                 ` Ilya Enkovich
  0 siblings, 1 reply; 49+ messages in thread
From: H.J. Lu @ 2015-03-18 13:32 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Richard Biener, GCC Patches, Uros Bizjak

On Wed, Mar 18, 2015 at 6:24 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> 2015-03-18 15:42 GMT+03:00 Richard Biener <richard.guenther@gmail.com>:
>> On Wed, Mar 18, 2015 at 1:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Wed, Mar 18, 2015 at 5:13 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>> 2015-03-18 15:08 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>>> On Wed, Mar 18, 2015 at 5:05 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>>> 2015-03-18 15:02 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>>>>> On Wed, Mar 18, 2015 at 4:56 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> This patch fixes PR target/65444 by passing '-z bndplt' to linker when appropriate.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  Will commit it to trunk in a couple of days if no objections arise.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Ilya
>>>>>>>> --
>>>>>>>> gcc/
>>>>>>>>
>>>>>>>> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>>>>>>>>
>>>>>>>>         PR driver/65444
>>>>>>>>         * config/i386/linux-common.h (MPX_SPEC): New.
>>>>>>>>         (CHKP_SPEC): Add MPX_SPEC.
>>>>>>>>
>>>>>>>> libmpx/
>>>>>>>>
>>>>>>>> 2015-03-18  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.
>>>>>>>>
>>>>>>>>
>>>>>>>> diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
>>>>>>>> index 9c6560b..dd79ec6 100644
>>>>>>>> --- a/gcc/config/i386/linux-common.h
>>>>>>>> +++ b/gcc/config/i386/linux-common.h
>>>>>>>> @@ -59,6 +59,11 @@ along with GCC; see the file COPYING3.  If not see
>>>>>>>>   %: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 "\
>>>>>>>> @@ -89,5 +94,5 @@ along with GCC; see the file COPYING3.  If not see
>>>>>>>>
>>>>>>>>  #ifndef CHKP_SPEC
>>>>>>>>  #define CHKP_SPEC "\
>>>>>>>> -%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
>>>>>>>> +%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
>>>>>>>>  #endif
>>>>>>>> diff --git a/libmpx/configure.ac b/libmpx/configure.ac
>>>>>>>> index fe0d3f2..3f8b50f 100644
>>>>>>>> --- a/libmpx/configure.ac
>>>>>>>> +++ b/libmpx/configure.ac
>>>>>>>> @@ -40,7 +40,18 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
>>>>>>>>  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)
>>>>>>>>
>>>>>>>
>>>>>>> Without -z bndplt, MPX won't work correctly.  We should always pass -z bndplt
>>>>>>> to linker.  If linker doesn't support it, ld will issue a warning, not
>>>>>>> error and users
>>>>>>> will know their linker is too old.  When they update linker, they don't have to
>>>>>>> rebuild GCC.
>>>>>>
>>>>>> If ld issues a warning instead of an error, then configure test passes
>>>>>> and we pass '-z bndplt' to linker.
>>>>>>
>>>>>
>>>>> Can you verify it with an older linker? The unknown XXX in -z XXX is always
>>>>> warned and ignored in Linux linker.  If testing it on Linux always passes,
>>>>> it is useless.
>>>>
>>>> Old ld issues a warning:
>>>>
>>>> ld: warning: -z bndplt ignored.
>>>
>>> Does configure test pass?
>>>
>>>> But gold issues an error:
>>>>
>>>> ld.gold: bndplt: unknown -z option
>>>> ld.gold: use the --help option for usage information
>>>
>>> If gold is used, MPX won't work.  What should we do here?
>>> Should we hardcode -fuse-ld=bfd for MPX?
>>
>> Is MPX disabled when the host linker is gold and gld isn't available?
>
> No. You may use MPX with gold and old ld but you would loose passed
> bounds when make a call via plt.
>

If gold is default linker, the configure test will fail and we never pass
-z bndplt to linker even if ld.bfd is available and ld.gold is fixed later.
I'd rather always pass -z bndplt to ld.

-- 
H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 13:32               ` H.J. Lu
@ 2015-03-18 13:41                 ` Ilya Enkovich
  2015-03-18 13:52                   ` H.J. Lu
  0 siblings, 1 reply; 49+ messages in thread
From: Ilya Enkovich @ 2015-03-18 13:41 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Richard Biener, GCC Patches, Uros Bizjak

2015-03-18 16:31 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
> On Wed, Mar 18, 2015 at 6:24 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> 2015-03-18 15:42 GMT+03:00 Richard Biener <richard.guenther@gmail.com>:
>>> On Wed, Mar 18, 2015 at 1:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> On Wed, Mar 18, 2015 at 5:13 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>> 2015-03-18 15:08 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>>>> On Wed, Mar 18, 2015 at 5:05 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>>>> 2015-03-18 15:02 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>>>>>> On Wed, Mar 18, 2015 at 4:56 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> This patch fixes PR target/65444 by passing '-z bndplt' to linker when appropriate.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  Will commit it to trunk in a couple of days if no objections arise.
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> Ilya
>>>>>>>>> --
>>>>>>>>> gcc/
>>>>>>>>>
>>>>>>>>> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>>>>>>>>>
>>>>>>>>>         PR driver/65444
>>>>>>>>>         * config/i386/linux-common.h (MPX_SPEC): New.
>>>>>>>>>         (CHKP_SPEC): Add MPX_SPEC.
>>>>>>>>>
>>>>>>>>> libmpx/
>>>>>>>>>
>>>>>>>>> 2015-03-18  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.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
>>>>>>>>> index 9c6560b..dd79ec6 100644
>>>>>>>>> --- a/gcc/config/i386/linux-common.h
>>>>>>>>> +++ b/gcc/config/i386/linux-common.h
>>>>>>>>> @@ -59,6 +59,11 @@ along with GCC; see the file COPYING3.  If not see
>>>>>>>>>   %: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 "\
>>>>>>>>> @@ -89,5 +94,5 @@ along with GCC; see the file COPYING3.  If not see
>>>>>>>>>
>>>>>>>>>  #ifndef CHKP_SPEC
>>>>>>>>>  #define CHKP_SPEC "\
>>>>>>>>> -%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
>>>>>>>>> +%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
>>>>>>>>>  #endif
>>>>>>>>> diff --git a/libmpx/configure.ac b/libmpx/configure.ac
>>>>>>>>> index fe0d3f2..3f8b50f 100644
>>>>>>>>> --- a/libmpx/configure.ac
>>>>>>>>> +++ b/libmpx/configure.ac
>>>>>>>>> @@ -40,7 +40,18 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
>>>>>>>>>  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)
>>>>>>>>>
>>>>>>>>
>>>>>>>> Without -z bndplt, MPX won't work correctly.  We should always pass -z bndplt
>>>>>>>> to linker.  If linker doesn't support it, ld will issue a warning, not
>>>>>>>> error and users
>>>>>>>> will know their linker is too old.  When they update linker, they don't have to
>>>>>>>> rebuild GCC.
>>>>>>>
>>>>>>> If ld issues a warning instead of an error, then configure test passes
>>>>>>> and we pass '-z bndplt' to linker.
>>>>>>>
>>>>>>
>>>>>> Can you verify it with an older linker? The unknown XXX in -z XXX is always
>>>>>> warned and ignored in Linux linker.  If testing it on Linux always passes,
>>>>>> it is useless.
>>>>>
>>>>> Old ld issues a warning:
>>>>>
>>>>> ld: warning: -z bndplt ignored.
>>>>
>>>> Does configure test pass?
>>>>
>>>>> But gold issues an error:
>>>>>
>>>>> ld.gold: bndplt: unknown -z option
>>>>> ld.gold: use the --help option for usage information
>>>>
>>>> If gold is used, MPX won't work.  What should we do here?
>>>> Should we hardcode -fuse-ld=bfd for MPX?
>>>
>>> Is MPX disabled when the host linker is gold and gld isn't available?
>>
>> No. You may use MPX with gold and old ld but you would loose passed
>> bounds when make a call via plt.
>>
>
> If gold is default linker, the configure test will fail and we never pass
> -z bndplt to linker even if ld.bfd is available and ld.gold is fixed later.
> I'd rather always pass -z bndplt to ld.

If gold is used and it doesn't support '-z bndplt' then it doesn't
mean user can't use MPX.

Ilya

>
> --
> H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 13:41                 ` Ilya Enkovich
@ 2015-03-18 13:52                   ` H.J. Lu
  2015-03-18 13:59                     ` Ilya Enkovich
  0 siblings, 1 reply; 49+ messages in thread
From: H.J. Lu @ 2015-03-18 13:52 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Richard Biener, GCC Patches, Uros Bizjak

On Wed, Mar 18, 2015 at 6:41 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> 2015-03-18 16:31 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>> On Wed, Mar 18, 2015 at 6:24 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>> 2015-03-18 15:42 GMT+03:00 Richard Biener <richard.guenther@gmail.com>:
>>>> On Wed, Mar 18, 2015 at 1:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>> On Wed, Mar 18, 2015 at 5:13 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>>> 2015-03-18 15:08 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>>>>> On Wed, Mar 18, 2015 at 5:05 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>>>>> 2015-03-18 15:02 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>>>>>>> On Wed, Mar 18, 2015 at 4:56 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> This patch fixes PR target/65444 by passing '-z bndplt' to linker when appropriate.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  Will commit it to trunk in a couple of days if no objections arise.
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>> Ilya
>>>>>>>>>> --
>>>>>>>>>> gcc/
>>>>>>>>>>
>>>>>>>>>> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>>>>>>>>>>
>>>>>>>>>>         PR driver/65444
>>>>>>>>>>         * config/i386/linux-common.h (MPX_SPEC): New.
>>>>>>>>>>         (CHKP_SPEC): Add MPX_SPEC.
>>>>>>>>>>
>>>>>>>>>> libmpx/
>>>>>>>>>>
>>>>>>>>>> 2015-03-18  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.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
>>>>>>>>>> index 9c6560b..dd79ec6 100644
>>>>>>>>>> --- a/gcc/config/i386/linux-common.h
>>>>>>>>>> +++ b/gcc/config/i386/linux-common.h
>>>>>>>>>> @@ -59,6 +59,11 @@ along with GCC; see the file COPYING3.  If not see
>>>>>>>>>>   %: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 "\
>>>>>>>>>> @@ -89,5 +94,5 @@ along with GCC; see the file COPYING3.  If not see
>>>>>>>>>>
>>>>>>>>>>  #ifndef CHKP_SPEC
>>>>>>>>>>  #define CHKP_SPEC "\
>>>>>>>>>> -%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
>>>>>>>>>> +%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
>>>>>>>>>>  #endif
>>>>>>>>>> diff --git a/libmpx/configure.ac b/libmpx/configure.ac
>>>>>>>>>> index fe0d3f2..3f8b50f 100644
>>>>>>>>>> --- a/libmpx/configure.ac
>>>>>>>>>> +++ b/libmpx/configure.ac
>>>>>>>>>> @@ -40,7 +40,18 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
>>>>>>>>>>  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)
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Without -z bndplt, MPX won't work correctly.  We should always pass -z bndplt
>>>>>>>>> to linker.  If linker doesn't support it, ld will issue a warning, not
>>>>>>>>> error and users
>>>>>>>>> will know their linker is too old.  When they update linker, they don't have to
>>>>>>>>> rebuild GCC.
>>>>>>>>
>>>>>>>> If ld issues a warning instead of an error, then configure test passes
>>>>>>>> and we pass '-z bndplt' to linker.
>>>>>>>>
>>>>>>>
>>>>>>> Can you verify it with an older linker? The unknown XXX in -z XXX is always
>>>>>>> warned and ignored in Linux linker.  If testing it on Linux always passes,
>>>>>>> it is useless.
>>>>>>
>>>>>> Old ld issues a warning:
>>>>>>
>>>>>> ld: warning: -z bndplt ignored.
>>>>>
>>>>> Does configure test pass?
>>>>>
>>>>>> But gold issues an error:
>>>>>>
>>>>>> ld.gold: bndplt: unknown -z option
>>>>>> ld.gold: use the --help option for usage information
>>>>>
>>>>> If gold is used, MPX won't work.  What should we do here?
>>>>> Should we hardcode -fuse-ld=bfd for MPX?
>>>>
>>>> Is MPX disabled when the host linker is gold and gld isn't available?
>>>
>>> No. You may use MPX with gold and old ld but you would loose passed
>>> bounds when make a call via plt.
>>>
>>
>> If gold is default linker, the configure test will fail and we never pass
>> -z bndplt to linker even if ld.bfd is available and ld.gold is fixed later.
>> I'd rather always pass -z bndplt to ld.
>
> If gold is used and it doesn't support '-z bndplt' then it doesn't
> mean user can't use MPX.

They can use -fuse-ld=bfd to select bfd linker if gold fails to generate
proper MPX binary.


-- 
H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 13:52                   ` H.J. Lu
@ 2015-03-18 13:59                     ` Ilya Enkovich
  2015-03-18 14:02                       ` Jakub Jelinek
  2015-03-18 14:03                       ` Robert Dewar
  0 siblings, 2 replies; 49+ messages in thread
From: Ilya Enkovich @ 2015-03-18 13:59 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Richard Biener, GCC Patches, Uros Bizjak

2015-03-18 16:52 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
> On Wed, Mar 18, 2015 at 6:41 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> 2015-03-18 16:31 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>> On Wed, Mar 18, 2015 at 6:24 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>> 2015-03-18 15:42 GMT+03:00 Richard Biener <richard.guenther@gmail.com>:
>>>>> On Wed, Mar 18, 2015 at 1:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>>> On Wed, Mar 18, 2015 at 5:13 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>>>> 2015-03-18 15:08 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>>>>>> On Wed, Mar 18, 2015 at 5:05 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>>>>>> 2015-03-18 15:02 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>>>>>>>> On Wed, Mar 18, 2015 at 4:56 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>>>>>>>> Hi,
>>>>>>>>>>>
>>>>>>>>>>> This patch fixes PR target/65444 by passing '-z bndplt' to linker when appropriate.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  Will commit it to trunk in a couple of days if no objections arise.
>>>>>>>>>>>
>>>>>>>>>>> Thanks,
>>>>>>>>>>> Ilya
>>>>>>>>>>> --
>>>>>>>>>>> gcc/
>>>>>>>>>>>
>>>>>>>>>>> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>>>>>>>>>>>
>>>>>>>>>>>         PR driver/65444
>>>>>>>>>>>         * config/i386/linux-common.h (MPX_SPEC): New.
>>>>>>>>>>>         (CHKP_SPEC): Add MPX_SPEC.
>>>>>>>>>>>
>>>>>>>>>>> libmpx/
>>>>>>>>>>>
>>>>>>>>>>> 2015-03-18  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.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
>>>>>>>>>>> index 9c6560b..dd79ec6 100644
>>>>>>>>>>> --- a/gcc/config/i386/linux-common.h
>>>>>>>>>>> +++ b/gcc/config/i386/linux-common.h
>>>>>>>>>>> @@ -59,6 +59,11 @@ along with GCC; see the file COPYING3.  If not see
>>>>>>>>>>>   %: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 "\
>>>>>>>>>>> @@ -89,5 +94,5 @@ along with GCC; see the file COPYING3.  If not see
>>>>>>>>>>>
>>>>>>>>>>>  #ifndef CHKP_SPEC
>>>>>>>>>>>  #define CHKP_SPEC "\
>>>>>>>>>>> -%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
>>>>>>>>>>> +%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
>>>>>>>>>>>  #endif
>>>>>>>>>>> diff --git a/libmpx/configure.ac b/libmpx/configure.ac
>>>>>>>>>>> index fe0d3f2..3f8b50f 100644
>>>>>>>>>>> --- a/libmpx/configure.ac
>>>>>>>>>>> +++ b/libmpx/configure.ac
>>>>>>>>>>> @@ -40,7 +40,18 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
>>>>>>>>>>>  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)
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Without -z bndplt, MPX won't work correctly.  We should always pass -z bndplt
>>>>>>>>>> to linker.  If linker doesn't support it, ld will issue a warning, not
>>>>>>>>>> error and users
>>>>>>>>>> will know their linker is too old.  When they update linker, they don't have to
>>>>>>>>>> rebuild GCC.
>>>>>>>>>
>>>>>>>>> If ld issues a warning instead of an error, then configure test passes
>>>>>>>>> and we pass '-z bndplt' to linker.
>>>>>>>>>
>>>>>>>>
>>>>>>>> Can you verify it with an older linker? The unknown XXX in -z XXX is always
>>>>>>>> warned and ignored in Linux linker.  If testing it on Linux always passes,
>>>>>>>> it is useless.
>>>>>>>
>>>>>>> Old ld issues a warning:
>>>>>>>
>>>>>>> ld: warning: -z bndplt ignored.
>>>>>>
>>>>>> Does configure test pass?
>>>>>>
>>>>>>> But gold issues an error:
>>>>>>>
>>>>>>> ld.gold: bndplt: unknown -z option
>>>>>>> ld.gold: use the --help option for usage information
>>>>>>
>>>>>> If gold is used, MPX won't work.  What should we do here?
>>>>>> Should we hardcode -fuse-ld=bfd for MPX?
>>>>>
>>>>> Is MPX disabled when the host linker is gold and gld isn't available?
>>>>
>>>> No. You may use MPX with gold and old ld but you would loose passed
>>>> bounds when make a call via plt.
>>>>
>>>
>>> If gold is default linker, the configure test will fail and we never pass
>>> -z bndplt to linker even if ld.bfd is available and ld.gold is fixed later.
>>> I'd rather always pass -z bndplt to ld.
>>
>> If gold is used and it doesn't support '-z bndplt' then it doesn't
>> mean user can't use MPX.
>
> They can use -fuse-ld=bfd to select bfd linker if gold fails to generate
> proper MPX binary.

Which is a weird thing to do just to have a warning instead of an
error. You don't guarantee MPX PLT generation by always passing '-z
bndplt' but remove an opportunity to use gold at all. With current
check you may use any linker and manually provide additional options
if you want to.

Ilya

>
>
> --
> H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 13:59                     ` Ilya Enkovich
@ 2015-03-18 14:02                       ` Jakub Jelinek
  2015-03-18 14:31                         ` H.J. Lu
  2015-03-18 14:03                       ` Robert Dewar
  1 sibling, 1 reply; 49+ messages in thread
From: Jakub Jelinek @ 2015-03-18 14:02 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: H.J. Lu, Richard Biener, GCC Patches, Uros Bizjak

On Wed, Mar 18, 2015 at 04:59:05PM +0300, Ilya Enkovich wrote:
> Which is a weird thing to do just to have a warning instead of an
> error. You don't guarantee MPX PLT generation by always passing '-z
> bndplt' but remove an opportunity to use gold at all. With current
> check you may use any linker and manually provide additional options
> if you want to.

Yeah, I agree, the configure check is a reasonable thing to do.

	Jakub

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 13:59                     ` Ilya Enkovich
  2015-03-18 14:02                       ` Jakub Jelinek
@ 2015-03-18 14:03                       ` Robert Dewar
  2015-03-18 14:33                         ` Markus Trippelsdorf
  1 sibling, 1 reply; 49+ messages in thread
From: Robert Dewar @ 2015-03-18 14:03 UTC (permalink / raw)
  To: Ilya Enkovich, H.J. Lu; +Cc: Richard Biener, GCC Patches, Uros Bizjak

Do we really want to quote to this level? This message has 11 levels of 
quotes, the most I have ever seen. If everyone does this, the whole 
thread is in every message and that seems unnecessary. I don't know if 
there are gcc guidelines on this???

On 3/18/2015 9:59 AM, Ilya Enkovich wrote:
> 2015-03-18 16:52 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>> On Wed, Mar 18, 2015 at 6:41 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>> 2015-03-18 16:31 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>> On Wed, Mar 18, 2015 at 6:24 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>> 2015-03-18 15:42 GMT+03:00 Richard Biener <richard.guenther@gmail.com>:
>>>>>> On Wed, Mar 18, 2015 at 1:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>>>> On Wed, Mar 18, 2015 at 5:13 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>>>>> 2015-03-18 15:08 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>>>>>>> On Wed, Mar 18, 2015 at 5:05 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>>>>>>> 2015-03-18 15:02 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>>>>>>>>> On Wed, Mar 18, 2015 at 4:56 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>>>>>>>>> Hi,
>>>>>>>>>>>>
>>>>>>>>>>>> This patch fixes PR target/65444 by passing '-z bndplt' to linker when appropriate.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  Will commit it to trunk in a couple of days if no objections arise.
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks,
>>>>>>>>>>>> Ilya
>>>>>>>>>>>> --
>>>>>>>>>>>> gcc/
>>>>>>>>>>>>
>>>>>>>>>>>> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>>>>>>>>>>>>
>>>>>>>>>>>>          PR driver/65444
>>>>>>>>>>>>          * config/i386/linux-common.h (MPX_SPEC): New.
>>>>>>>>>>>>          (CHKP_SPEC): Add MPX_SPEC.
>>>>>>>>>>>>
>>>>>>>>>>>> libmpx/
>>>>>>>>>>>>
>>>>>>>>>>>> 2015-03-18  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.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
>>>>>>>>>>>> index 9c6560b..dd79ec6 100644
>>>>>>>>>>>> --- a/gcc/config/i386/linux-common.h
>>>>>>>>>>>> +++ b/gcc/config/i386/linux-common.h
>>>>>>>>>>>> @@ -59,6 +59,11 @@ along with GCC; see the file COPYING3.  If not see
>>>>>>>>>>>>    %: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 "\
>>>>>>>>>>>> @@ -89,5 +94,5 @@ along with GCC; see the file COPYING3.  If not see
>>>>>>>>>>>>
>>>>>>>>>>>>   #ifndef CHKP_SPEC
>>>>>>>>>>>>   #define CHKP_SPEC "\
>>>>>>>>>>>> -%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
>>>>>>>>>>>> +%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
>>>>>>>>>>>>   #endif
>>>>>>>>>>>> diff --git a/libmpx/configure.ac b/libmpx/configure.ac
>>>>>>>>>>>> index fe0d3f2..3f8b50f 100644
>>>>>>>>>>>> --- a/libmpx/configure.ac
>>>>>>>>>>>> +++ b/libmpx/configure.ac
>>>>>>>>>>>> @@ -40,7 +40,18 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
>>>>>>>>>>>>   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)
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Without -z bndplt, MPX won't work correctly.  We should always pass -z bndplt
>>>>>>>>>>> to linker.  If linker doesn't support it, ld will issue a warning, not
>>>>>>>>>>> error and users
>>>>>>>>>>> will know their linker is too old.  When they update linker, they don't have to
>>>>>>>>>>> rebuild GCC.
>>>>>>>>>>
>>>>>>>>>> If ld issues a warning instead of an error, then configure test passes
>>>>>>>>>> and we pass '-z bndplt' to linker.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Can you verify it with an older linker? The unknown XXX in -z XXX is always
>>>>>>>>> warned and ignored in Linux linker.  If testing it on Linux always passes,
>>>>>>>>> it is useless.
>>>>>>>>
>>>>>>>> Old ld issues a warning:
>>>>>>>>
>>>>>>>> ld: warning: -z bndplt ignored.
>>>>>>>
>>>>>>> Does configure test pass?
>>>>>>>
>>>>>>>> But gold issues an error:
>>>>>>>>
>>>>>>>> ld.gold: bndplt: unknown -z option
>>>>>>>> ld.gold: use the --help option for usage information
>>>>>>>
>>>>>>> If gold is used, MPX won't work.  What should we do here?
>>>>>>> Should we hardcode -fuse-ld=bfd for MPX?
>>>>>>
>>>>>> Is MPX disabled when the host linker is gold and gld isn't available?
>>>>>
>>>>> No. You may use MPX with gold and old ld but you would loose passed
>>>>> bounds when make a call via plt.
>>>>>
>>>>
>>>> If gold is default linker, the configure test will fail and we never pass
>>>> -z bndplt to linker even if ld.bfd is available and ld.gold is fixed later.
>>>> I'd rather always pass -z bndplt to ld.
>>>
>>> If gold is used and it doesn't support '-z bndplt' then it doesn't
>>> mean user can't use MPX.
>>
>> They can use -fuse-ld=bfd to select bfd linker if gold fails to generate
>> proper MPX binary.
>
> Which is a weird thing to do just to have a warning instead of an
> error. You don't guarantee MPX PLT generation by always passing '-z
> bndplt' but remove an opportunity to use gold at all. With current
> check you may use any linker and manually provide additional options
> if you want to.
>
> Ilya
>
>>
>>
>> --
>> H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 14:02                       ` Jakub Jelinek
@ 2015-03-18 14:31                         ` H.J. Lu
  2015-03-18 14:42                           ` H.J. Lu
  0 siblings, 1 reply; 49+ messages in thread
From: H.J. Lu @ 2015-03-18 14:31 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Ilya Enkovich, Richard Biener, GCC Patches, Uros Bizjak

On Wed, Mar 18, 2015 at 7:02 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Wed, Mar 18, 2015 at 04:59:05PM +0300, Ilya Enkovich wrote:
>> Which is a weird thing to do just to have a warning instead of an
>> error. You don't guarantee MPX PLT generation by always passing '-z
>> bndplt' but remove an opportunity to use gold at all. With current
>> check you may use any linker and manually provide additional options
>> if you want to.
>
> Yeah, I agree, the configure check is a reasonable thing to do.
>

We should either always pass -z bndplt to linker or disable
MPX.

-- 
H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 14:03                       ` Robert Dewar
@ 2015-03-18 14:33                         ` Markus Trippelsdorf
  0 siblings, 0 replies; 49+ messages in thread
From: Markus Trippelsdorf @ 2015-03-18 14:33 UTC (permalink / raw)
  To: Robert Dewar
  Cc: Ilya Enkovich, H.J. Lu, Richard Biener, GCC Patches, Uros Bizjak

On 2015.03.18 at 10:03 -0400, Robert Dewar wrote:
> Do we really want to quote to this level? This message has 11 levels of 
> quotes, the most I have ever seen. If everyone does this, the whole 
> thread is in every message and that seems unnecessary. I don't know if 
> there are gcc guidelines on this???

The only guideline I know of is that top-posts are to be avoided.

You could use local tools to handle this situation. I use t-prot with
mutt for example. It automatically shrinks the quote block, e.g.:

[---=| Quote block shrunk by t-prot: 114 lines snipped |=---]
... last few lines of message ...

-- 
Markus

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 14:31                         ` H.J. Lu
@ 2015-03-18 14:42                           ` H.J. Lu
  2015-03-18 16:14                             ` Ilya Enkovich
  0 siblings, 1 reply; 49+ messages in thread
From: H.J. Lu @ 2015-03-18 14:42 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Ilya Enkovich, Richard Biener, GCC Patches, Uros Bizjak

On Wed, Mar 18, 2015 at 7:31 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Mar 18, 2015 at 7:02 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>> On Wed, Mar 18, 2015 at 04:59:05PM +0300, Ilya Enkovich wrote:
>>> Which is a weird thing to do just to have a warning instead of an
>>> error. You don't guarantee MPX PLT generation by always passing '-z
>>> bndplt' but remove an opportunity to use gold at all. With current
>>> check you may use any linker and manually provide additional options
>>> if you want to.
>>
>> Yeah, I agree, the configure check is a reasonable thing to do.
>>
>
> We should either always pass -z bndplt to linker or disable
> MPX.
>

MPX is a security feature.  Knowing leaving a door open is a
bad idea.

-- 
H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 14:42                           ` H.J. Lu
@ 2015-03-18 16:14                             ` Ilya Enkovich
  2015-03-18 16:45                               ` H.J. Lu
  0 siblings, 1 reply; 49+ messages in thread
From: Ilya Enkovich @ 2015-03-18 16:14 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Jakub Jelinek, Richard Biener, GCC Patches, Uros Bizjak

2015-03-18 17:42 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
> On Wed, Mar 18, 2015 at 7:31 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Wed, Mar 18, 2015 at 7:02 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>>>
>>> Yeah, I agree, the configure check is a reasonable thing to do.
>>>
>>
>> We should either always pass -z bndplt to linker or disable
>> MPX.
>>
>
> MPX is a security feature.  Knowing leaving a door open is a
> bad idea.

Instrumented binary used with legacy libraries is a supported usage
model. Each user determines his own level of security.

Ilya

>
> --
> H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 16:14                             ` Ilya Enkovich
@ 2015-03-18 16:45                               ` H.J. Lu
  2015-03-18 17:13                                 ` Ilya Enkovich
  0 siblings, 1 reply; 49+ messages in thread
From: H.J. Lu @ 2015-03-18 16:45 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Jakub Jelinek, Richard Biener, GCC Patches, Uros Bizjak

On Wed, Mar 18, 2015 at 9:14 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> 2015-03-18 17:42 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>> On Wed, Mar 18, 2015 at 7:31 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Wed, Mar 18, 2015 at 7:02 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>>>>
>>>> Yeah, I agree, the configure check is a reasonable thing to do.
>>>>
>>>
>>> We should either always pass -z bndplt to linker or disable
>>> MPX.
>>>
>>
>> MPX is a security feature.  Knowing leaving a door open is a
>> bad idea.
>
> Instrumented binary used with legacy libraries is a supported usage
> model. Each user determines his own level of security.
>

It doesn't mean we should leave a door open.  Are we supposed to
detect this with MPX:

[hjl@skylakeclient bug-1]$ cat x.c
#include <string.h>

int
main ()
{
  char buf[10];
  memset(buf, 'a', 11);
  return 0;
}
[hjl@skylakeclient bug-1]$

I believe we should, not maybe.  We shouldn't silent fail it
when linker doesn't support -z bndplt.

-- 
H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 16:45                               ` H.J. Lu
@ 2015-03-18 17:13                                 ` Ilya Enkovich
  2015-03-18 17:14                                   ` H.J. Lu
  0 siblings, 1 reply; 49+ messages in thread
From: Ilya Enkovich @ 2015-03-18 17:13 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Jakub Jelinek, Richard Biener, GCC Patches, Uros Bizjak

2015-03-18 19:45 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
> On Wed, Mar 18, 2015 at 9:14 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> 2015-03-18 17:42 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>> On Wed, Mar 18, 2015 at 7:31 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>
>>> MPX is a security feature.  Knowing leaving a door open is a
>>> bad idea.
>>
>> Instrumented binary used with legacy libraries is a supported usage
>> model. Each user determines his own level of security.
>>
>
> It doesn't mean we should leave a door open.  Are we supposed to
> detect this with MPX:
>
> [hjl@skylakeclient bug-1]$ cat x.c
> #include <string.h>
>
> int
> main ()
> {
>   char buf[10];
>   memset(buf, 'a', 11);
>   return 0;
> }
> [hjl@skylakeclient bug-1]$
>
> I believe we should, not maybe.  We shouldn't silent fail it
> when linker doesn't support -z bndplt.

It depends on compiler flags and libraries used and is up to user to
decide. User may be warned during libmpx configuration.

Ilya

>
> --
> H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 17:13                                 ` Ilya Enkovich
@ 2015-03-18 17:14                                   ` H.J. Lu
  2015-03-18 17:34                                     ` Ilya Enkovich
  0 siblings, 1 reply; 49+ messages in thread
From: H.J. Lu @ 2015-03-18 17:14 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Jakub Jelinek, Richard Biener, GCC Patches, Uros Bizjak

On Wed, Mar 18, 2015 at 10:13 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> 2015-03-18 19:45 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>> On Wed, Mar 18, 2015 at 9:14 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>> 2015-03-18 17:42 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>>> On Wed, Mar 18, 2015 at 7:31 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>
>>>> MPX is a security feature.  Knowing leaving a door open is a
>>>> bad idea.
>>>
>>> Instrumented binary used with legacy libraries is a supported usage
>>> model. Each user determines his own level of security.
>>>
>>
>> It doesn't mean we should leave a door open.  Are we supposed to
>> detect this with MPX:
>>
>> [hjl@skylakeclient bug-1]$ cat x.c
>> #include <string.h>
>>
>> int
>> main ()
>> {
>>   char buf[10];
>>   memset(buf, 'a', 11);
>>   return 0;
>> }
>> [hjl@skylakeclient bug-1]$
>>
>> I believe we should, not maybe.  We shouldn't silent fail it
>> when linker doesn't support -z bndplt.
>
> It depends on compiler flags and libraries used and is up to user to
> decide. User may be warned during libmpx configuration.
>

What is "USER"?  The one who build GCC may not be same
person who uses GCC.


-- 
H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 17:14                                   ` H.J. Lu
@ 2015-03-18 17:34                                     ` Ilya Enkovich
  2015-03-18 17:39                                       ` H.J. Lu
  0 siblings, 1 reply; 49+ messages in thread
From: Ilya Enkovich @ 2015-03-18 17:34 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Jakub Jelinek, Richard Biener, GCC Patches, Uros Bizjak

2015-03-18 20:14 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
> On Wed, Mar 18, 2015 at 10:13 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> 2015-03-18 19:45 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>> On Wed, Mar 18, 2015 at 9:14 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>
>>>> Instrumented binary used with legacy libraries is a supported usage
>>>> model. Each user determines his own level of security.
>>>>
>>>
>>> It doesn't mean we should leave a door open.  Are we supposed to
>>> detect this with MPX:
>>>
>>> [hjl@skylakeclient bug-1]$ cat x.c
>>> #include <string.h>
>>>
>>> int
>>> main ()
>>> {
>>>   char buf[10];
>>>   memset(buf, 'a', 11);
>>>   return 0;
>>> }
>>> [hjl@skylakeclient bug-1]$
>>>
>>> I believe we should, not maybe.  We shouldn't silent fail it
>>> when linker doesn't support -z bndplt.
>>
>> It depends on compiler flags and libraries used and is up to user to
>> decide. User may be warned during libmpx configuration.
>>
>
> What is "USER"?  The one who build GCC may not be same
> person who uses GCC.
>

The person who build GCC determines its default behavior. User either
uses it with default settings or overwrites it with own flags. You may
warn the person who build GCC that his config has no '-z bndplt' by
default.

Ilya

>
> --
> H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 17:34                                     ` Ilya Enkovich
@ 2015-03-18 17:39                                       ` H.J. Lu
  2015-03-18 18:13                                         ` Ilya Enkovich
  0 siblings, 1 reply; 49+ messages in thread
From: H.J. Lu @ 2015-03-18 17:39 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Jakub Jelinek, Richard Biener, GCC Patches, Uros Bizjak

On Wed, Mar 18, 2015 at 10:34 AM, Ilya Enkovich
>>>> It doesn't mean we should leave a door open.  Are we supposed to
>>>> detect this with MPX:
>>>>
>>>> [hjl@skylakeclient bug-1]$ cat x.c
>>>> #include <string.h>
>>>>
>>>> int
>>>> main ()
>>>> {
>>>>   char buf[10];
>>>>   memset(buf, 'a', 11);
>>>>   return 0;
>>>> }
>>>> [hjl@skylakeclient bug-1]$
>>>>
>>>> I believe we should, not maybe.  We shouldn't silent fail it
>>>> when linker doesn't support -z bndplt.
>>>
>>> It depends on compiler flags and libraries used and is up to user to
>>> decide. User may be warned during libmpx configuration.
>>>
>>
>> What is "USER"?  The one who build GCC may not be same
>> person who uses GCC.
>>
>
> The person who build GCC determines its default behavior. User either
> uses it with default settings or overwrites it with own flags. You may
> warn the person who build GCC that his config has no '-z bndplt' by
> default.
>

Person who use GCC have no idea about it.  That is why we
should always pass -z bndplt to ld if MPX is enabled.  Otherwise,
Person who use GCC may falsely believe him/her are covered by
MPX.

-- 
H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 17:39                                       ` H.J. Lu
@ 2015-03-18 18:13                                         ` Ilya Enkovich
  0 siblings, 0 replies; 49+ messages in thread
From: Ilya Enkovich @ 2015-03-18 18:13 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Jakub Jelinek, Richard Biener, GCC Patches, Uros Bizjak

2015-03-18 20:39 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
> On Wed, Mar 18, 2015 at 10:34 AM, Ilya Enkovich
>>>
>>> What is "USER"?  The one who build GCC may not be same
>>> person who uses GCC.
>>>
>>
>> The person who build GCC determines its default behavior. User either
>> uses it with default settings or overwrites it with own flags. You may
>> warn the person who build GCC that his config has no '-z bndplt' by
>> default.
>>
>
> Person who use GCC have no idea about it.  That is why we
> should always pass -z bndplt to ld if MPX is enabled.  Otherwise,
> Person who use GCC may falsely believe him/her are covered by
> MPX.

This person should be more careful because there are other ways to use
MPX including model with no bndplt.

Ilya

>
> --
> H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-18 11:56 [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX Ilya Enkovich
  2015-03-18 12:03 ` H.J. Lu
@ 2015-03-23 10:19 ` Ilya Enkovich
  2015-03-31  9:47   ` Ilya Enkovich
  1 sibling, 1 reply; 49+ messages in thread
From: Ilya Enkovich @ 2015-03-23 10:19 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

Hi,

May this patch go into trunk at this point?  It is very important for
dynamic MPX codes.

Thanks,
Ilya

2015-03-18 14:56 GMT+03:00 Ilya Enkovich <enkovich.gnu@gmail.com>:
> Hi,
>
> This patch fixes PR target/65444 by passing '-z bndplt' to linker when appropriate.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  Will commit it to trunk in a couple of days if no objections arise.
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>
>         PR driver/65444
>         * config/i386/linux-common.h (MPX_SPEC): New.
>         (CHKP_SPEC): Add MPX_SPEC.
>
> libmpx/
>
> 2015-03-18  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.
>
>
> diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
> index 9c6560b..dd79ec6 100644
> --- a/gcc/config/i386/linux-common.h
> +++ b/gcc/config/i386/linux-common.h
> @@ -59,6 +59,11 @@ along with GCC; see the file COPYING3.  If not see
>   %: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 "\
> @@ -89,5 +94,5 @@ along with GCC; see the file COPYING3.  If not see
>
>  #ifndef CHKP_SPEC
>  #define CHKP_SPEC "\
> -%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
> +%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
>  #endif
> diff --git a/libmpx/configure.ac b/libmpx/configure.ac
> index fe0d3f2..3f8b50f 100644
> --- a/libmpx/configure.ac
> +++ b/libmpx/configure.ac
> @@ -40,7 +40,18 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
>  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(, ..)
> diff --git a/libmpx/libmpx.spec.in b/libmpx/libmpx.spec.in
> index a265e28..34d0bdf 100644
> --- a/libmpx/libmpx.spec.in
> +++ b/libmpx/libmpx.spec.in
> @@ -1,3 +1,5 @@
>  # 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@

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-23 10:19 ` Ilya Enkovich
@ 2015-03-31  9:47   ` Ilya Enkovich
  2015-04-02  4:34     ` Jeff Law
  2015-04-03 19:34     ` Joseph Myers
  0 siblings, 2 replies; 49+ messages in thread
From: Ilya Enkovich @ 2015-03-31  9:47 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On 23 Mar 13:19, Ilya Enkovich wrote:
> Hi,
> 
> May this patch go into trunk at this point?  It is very important for
> dynamic MPX codes.
> 
> Thanks,
> Ilya
> 

I additionally documented changes in invoke.texi.  OK for trunk?

Thanks,
Ilya
--
gcc/

2015-03-31  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.

libmpx/

2015-03-31  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.


diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
index 9c6560b..dd79ec6 100644
--- a/gcc/config/i386/linux-common.h
+++ b/gcc/config/i386/linux-common.h
@@ -59,6 +59,11 @@ along with GCC; see the file COPYING3.  If not see
  %: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 "\
@@ -89,5 +94,5 @@ along with GCC; see the file COPYING3.  If not see
 
 #ifndef CHKP_SPEC
 #define CHKP_SPEC "\
-%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}"
+%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC
 #endif
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index bf8afad..c058710 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -5857,7 +5857,16 @@ MPX-based instrumentation requires
 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
diff --git a/libmpx/configure.ac b/libmpx/configure.ac
index fe0d3f2..3f8b50f 100644
--- a/libmpx/configure.ac
+++ b/libmpx/configure.ac
@@ -40,7 +40,18 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
 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(, ..)
diff --git a/libmpx/libmpx.spec.in b/libmpx/libmpx.spec.in
index a265e28..34d0bdf 100644
--- a/libmpx/libmpx.spec.in
+++ b/libmpx/libmpx.spec.in
@@ -1,3 +1,5 @@
 # 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@

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-31  9:47   ` Ilya Enkovich
@ 2015-04-02  4:34     ` Jeff Law
  2015-04-02 11:01       ` H.J. Lu
  2015-04-03 19:34     ` Joseph Myers
  1 sibling, 1 reply; 49+ messages in thread
From: Jeff Law @ 2015-04-02  4:34 UTC (permalink / raw)
  To: Ilya Enkovich, Richard Biener; +Cc: gcc-patches

On 03/31/2015 03:47 AM, Ilya Enkovich wrote:
> On 23 Mar 13:19, Ilya Enkovich wrote:
>> Hi,
>>
>> May this patch go into trunk at this point?  It is very important for
>> dynamic MPX codes.
>>
>> Thanks,
>> Ilya
>>
>
> I additionally documented changes in invoke.texi.  OK for trunk?
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2015-03-31  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.
>
> libmpx/
>
> 2015-03-31  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.
Just to make sure I understand.  With this patch we conditionally pass 
-z bndplt based on whether or not it's supported by the linker we find 
when we configure GCC.

Failure to pass -z bndplt won't cause the program to misbehave, but will 
limit the effectiveness of MPX.

Gold doesn't support -z bndplt, just newer versions of the BFD linker.

Gold issues an error for -z bndplt, old BFD linkers will issue a warning.

There are, at least in theory, use cases where we might not have a PLT 
and thus -z bndplt wouldn't make sense anyway.

I guess the one thing I don't like here is that whether or not to pass 
-z bndplt is made at the time we configure GCC.  Yet, it's trivial for 
someone to change the system linker later, either to gold or from an old 
BFD linker that doesn't support -z bndplt to one that does support -z 
bndplt.

[ Note we have the same issue with certain assembler feature tests. ]

I'm not aware of any real infrastructure in GCC to query the behavior of 
the linker at link time and then customize the options passed.  So if 
it's going to be configurable, then that's the only time to do the test.

I strongly disagree with HJ's assertion that we should always pass the 
flag, regardless of the underlying linker.

So, in an ideal world, we'd query the linker at link time and pass the 
flag anytime we have a linker that supports the capability and perhaps 
warn if the linker doesn't support that capability.

Given we're not in that ideal world, I think Ilya's patch is reasonable 
and should be installed.

jeff

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-04-02  4:34     ` Jeff Law
@ 2015-04-02 11:01       ` H.J. Lu
  0 siblings, 0 replies; 49+ messages in thread
From: H.J. Lu @ 2015-04-02 11:01 UTC (permalink / raw)
  To: Jeff Law; +Cc: Ilya Enkovich, Richard Biener, gcc-patches

On Wed, Apr 1, 2015 at 9:34 PM, Jeff Law <law@redhat.com> wrote:
> On 03/31/2015 03:47 AM, Ilya Enkovich wrote:
>>
>> On 23 Mar 13:19, Ilya Enkovich wrote:
>>>
>>> Hi,
>>>
>>> May this patch go into trunk at this point?  It is very important for
>>> dynamic MPX codes.
>>>
>>> Thanks,
>>> Ilya
>>>
>>
>> I additionally documented changes in invoke.texi.  OK for trunk?
>>
>> Thanks,
>> Ilya
>> --
>> gcc/
>>
>> 2015-03-31  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.
>>
>> libmpx/
>>
>> 2015-03-31  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.
>
> Just to make sure I understand.  With this patch we conditionally pass -z
> bndplt based on whether or not it's supported by the linker we find when we
> configure GCC.
>
> Failure to pass -z bndplt won't cause the program to misbehave, but will
> limit the effectiveness of MPX.
>
> Gold doesn't support -z bndplt, just newer versions of the BFD linker.
>
> Gold issues an error for -z bndplt, old BFD linkers will issue a warning.
>
> There are, at least in theory, use cases where we might not have a PLT and
> thus -z bndplt wouldn't make sense anyway.
>
> I guess the one thing I don't like here is that whether or not to pass -z
> bndplt is made at the time we configure GCC.  Yet, it's trivial for someone
> to change the system linker later, either to gold or from an old BFD linker
> that doesn't support -z bndplt to one that does support -z bndplt.
>
> [ Note we have the same issue with certain assembler feature tests. ]
>
> I'm not aware of any real infrastructure in GCC to query the behavior of the
> linker at link time and then customize the options passed.  So if it's going
> to be configurable, then that's the only time to do the test.
>
> I strongly disagree with HJ's assertion that we should always pass the flag,
> regardless of the underlying linker.
>
> So, in an ideal world, we'd query the linker at link time and pass the flag
> anytime we have a linker that supports the capability and perhaps warn if
> the linker doesn't support that capability.
>
> Given we're not in that ideal world, I think Ilya's patch is reasonable and
> should be installed.

Without proper PLT for MPX, all external function calls will clear bound
registers.  MPX is a security feature. Cyber criminals only need to get
it right 1 time.  An organization who uses MPX for cyber security may
not realize they leave a door open due to an old linker.  What I want to
avoid is 2 years from now, bank of foobar comes out saying that they
thought they were protected by MPX, but somehow MPX didn't catch a
buffer overflow it was supposed to and there was no compiler error message
to warn programmers.


-- 
H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-03-31  9:47   ` Ilya Enkovich
  2015-04-02  4:34     ` Jeff Law
@ 2015-04-03 19:34     ` Joseph Myers
  2015-04-06  1:45       ` Sandra Loosemore
  1 sibling, 1 reply; 49+ messages in thread
From: Joseph Myers @ 2015-04-03 19:34 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Richard Biener, gcc-patches

On Tue, 31 Mar 2015, Ilya Enkovich wrote:

> +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

Use @samp{-z bndplt} rather than '' quoting (but Sandra may have further 
advice on the substance of this documentation).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-04-03 19:34     ` Joseph Myers
@ 2015-04-06  1:45       ` Sandra Loosemore
  2015-04-06  2:35         ` H.J. Lu
  2015-04-06 15:18         ` Ilya Enkovich
  0 siblings, 2 replies; 49+ messages in thread
From: Sandra Loosemore @ 2015-04-06  1:45 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Ilya Enkovich, Richard Biener, gcc-patches

On 04/03/2015 01:34 PM, Joseph Myers wrote:
> On Tue, 31 Mar 2015, Ilya Enkovich wrote:
>
>> +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
>
> Use @samp{-z bndplt} rather than '' quoting (but Sandra may have further
> advice on the substance of this documentation).

To tell the truth, I can't figure out what this means from a user 
perspective.  How does a user know whether the linker option is being 
ignored, or if they have a new enough linker?  If the linker available 
at configuration time doesn't support the option, does that mean the 
option will never be passed and users will never know that there are 
gaping holes in the pointer bounds checking?

My suggestion would be to pass the option unconditionally and make the 
documentation say something like

It also passes @option{-z bndplt} to the linker.  LD version xxx or 
later is required to use this feature.  If no linker support for 
@option{-z bndplt} is available, you should link with 
@option{-static-libmpxwrappers} or @option{-static} instead; otherwise 
calls to dynamic libraries lose bounds checking protection.

... where you need to fill in "version xxx" appropriately.

-Sandra

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-04-06  1:45       ` Sandra Loosemore
@ 2015-04-06  2:35         ` H.J. Lu
  2015-04-06  3:08           ` Sandra Loosemore
  2015-04-06 15:18         ` Ilya Enkovich
  1 sibling, 1 reply; 49+ messages in thread
From: H.J. Lu @ 2015-04-06  2:35 UTC (permalink / raw)
  To: Sandra Loosemore; +Cc: Joseph Myers, Ilya Enkovich, Richard Biener, gcc-patches

On Sun, Apr 5, 2015 at 6:44 PM, Sandra Loosemore
<sandra@codesourcery.com> wrote:
> On 04/03/2015 01:34 PM, Joseph Myers wrote:
>>
>> On Tue, 31 Mar 2015, Ilya Enkovich wrote:
>>
>>> +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
>>
>>
>> Use @samp{-z bndplt} rather than '' quoting (but Sandra may have further
>> advice on the substance of this documentation).
>
>
> To tell the truth, I can't figure out what this means from a user
> perspective.  How does a user know whether the linker option is being
> ignored, or if they have a new enough linker?  If the linker available at
> configuration time doesn't support the option, does that mean the option
> will never be passed and users will never know that there are gaping holes
> in the pointer bounds checking?
>
> My suggestion would be to pass the option unconditionally and make the
> documentation say something like

I totally agree with it.

> It also passes @option{-z bndplt} to the linker.  LD version xxx or later is
> required to use this feature.  If no linker support for @option{-z bndplt}
> is available, you should link with @option{-static-libmpxwrappers} or
> @option{-static} instead; otherwise calls to dynamic libraries lose bounds
> checking protection.
>

This implies that -static-libmpxwrappers will cover all dynamic libraries,
which isn't true.  -static-libmpxwrappers only covers calls to functions
defined in libmpxwrappers.so and leaves calls to functions defined in
other dynamic libraries open to buffer overflow.

-- 
H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-04-06  2:35         ` H.J. Lu
@ 2015-04-06  3:08           ` Sandra Loosemore
  0 siblings, 0 replies; 49+ messages in thread
From: Sandra Loosemore @ 2015-04-06  3:08 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Joseph Myers, Ilya Enkovich, Richard Biener, gcc-patches

On 04/05/2015 08:35 PM, H.J. Lu wrote:
> On Sun, Apr 5, 2015 at 6:44 PM, Sandra Loosemore
> <sandra@codesourcery.com> wrote:
>>  [snip snip]
>>
>> To tell the truth, I can't figure out what this means from a user
>> perspective.  How does a user know whether the linker option is being
>> ignored, or if they have a new enough linker?  If the linker available at
>> configuration time doesn't support the option, does that mean the option
>> will never be passed and users will never know that there are gaping holes
>> in the pointer bounds checking?
>>
>> My suggestion would be to pass the option unconditionally and make the
>> documentation say something like
>
> I totally agree with it.
>
>> It also passes @option{-z bndplt} to the linker.  LD version xxx or later is
>> required to use this feature.  If no linker support for @option{-z bndplt}
>> is available, you should link with @option{-static-libmpxwrappers} or
>> @option{-static} instead; otherwise calls to dynamic libraries lose bounds
>> checking protection.
>>
>
> This implies that -static-libmpxwrappers will cover all dynamic libraries,
> which isn't true.  -static-libmpxwrappers only covers calls to functions
> defined in libmpxwrappers.so and leaves calls to functions defined in
> other dynamic libraries open to buffer overflow.

See, I said I didn't really understand the details.  ;-)  Just strike 
the reference to -static-libmpxwrappers entirely, then.

-Sandra

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-04-06  1:45       ` Sandra Loosemore
  2015-04-06  2:35         ` H.J. Lu
@ 2015-04-06 15:18         ` Ilya Enkovich
  2015-04-06 15:28           ` Jeff Law
  2015-04-06 17:15           ` Sandra Loosemore
  1 sibling, 2 replies; 49+ messages in thread
From: Ilya Enkovich @ 2015-04-06 15:18 UTC (permalink / raw)
  To: Sandra Loosemore; +Cc: Joseph Myers, Richard Biener, gcc-patches

On 05 Apr 19:44, Sandra Loosemore wrote:
> On 04/03/2015 01:34 PM, Joseph Myers wrote:
> >On Tue, 31 Mar 2015, Ilya Enkovich wrote:
> >
> >>+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
> >
> >Use @samp{-z bndplt} rather than '' quoting (but Sandra may have further
> >advice on the substance of this documentation).
> 
> To tell the truth, I can't figure out what this means from a user
> perspective.  How does a user know whether the linker option is
> being ignored, or if they have a new enough linker?  If the linker
> available at configuration time doesn't support the option, does
> that mean the option will never be passed and users will never know
> that there are gaping holes in the pointer bounds checking?
> 
> My suggestion would be to pass the option unconditionally and make
> the documentation say something like

This option was rejected.

> 
> It also passes @option{-z bndplt} to the linker.  LD version xxx or
> later is required to use this feature.  If no linker support for
> @option{-z bndplt} is available, you should link with
> @option{-static-libmpxwrappers} or @option{-static} instead;
> otherwise calls to dynamic libraries lose bounds checking
> protection.
> 
> ... where you need to fill in "version xxx" appropriately.
> 
> -Sandra
> 

Thank you for comments.  Here is a doc update I'm going to install if nobody objects.

Ilya
--
2015-04-06  Ilya Enkovich  <ilya.enkovich@intel.com>

	* doc/invoke.texi (-fcheck-pointer-bounds): Fix
	formatting.


diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index c058710..72b9578 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -5858,12 +5858,12 @@ 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 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
+library.  It also passes @option{-z bndplt} to a linker in case it supports
+this option (which is checked on libmpx configuration).  LD supports it starting
+from version 2.25.  Gold linker doesn't support @option{-z bndplt}
+option.  With no @option{-z bndplt} support in a linker all calls to dynamic
+libraries lose passed bounds reducing overall protection level.  It's highly
+recommended to use linker with @option{-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

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-04-06 15:18         ` Ilya Enkovich
@ 2015-04-06 15:28           ` Jeff Law
  2015-04-06 15:54             ` Ilya Enkovich
  2015-05-26  9:26             ` Ilya Enkovich
  2015-04-06 17:15           ` Sandra Loosemore
  1 sibling, 2 replies; 49+ messages in thread
From: Jeff Law @ 2015-04-06 15:28 UTC (permalink / raw)
  To: Ilya Enkovich, Sandra Loosemore; +Cc: Joseph Myers, Richard Biener, gcc-patches

On 04/06/2015 09:17 AM, Ilya Enkovich wrote:
>>
>> To tell the truth, I can't figure out what this means from a user
>> perspective.  How does a user know whether the linker option is
>> being ignored, or if they have a new enough linker?  If the linker
>> available at configuration time doesn't support the option, does
>> that mean the option will never be passed and users will never know
>> that there are gaping holes in the pointer bounds checking?
>>
>> My suggestion would be to pass the option unconditionally and make
>> the documentation say something like
>
> This option was rejected.
Right.  There really isn't a good option here because we don't have the 
infrastructure to query the linker's capabilities at link time.

Though I do wonder if we could issue a warning in the case where the 
configure test indicated -z bndplt was not supported.

It'd obviously mean a link warning every time an end user tried to use 
that toolchain to create a DSO or executable with MPX protection.  But 
that may be better than silently leaving some code unprotected.


Jeff

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-04-06 15:28           ` Jeff Law
@ 2015-04-06 15:54             ` Ilya Enkovich
  2015-05-26  9:26             ` Ilya Enkovich
  1 sibling, 0 replies; 49+ messages in thread
From: Ilya Enkovich @ 2015-04-06 15:54 UTC (permalink / raw)
  To: Jeff Law; +Cc: Sandra Loosemore, Joseph Myers, Richard Biener, gcc-patches

2015-04-06 18:28 GMT+03:00 Jeff Law <law@redhat.com>:
> On 04/06/2015 09:17 AM, Ilya Enkovich wrote:
>>>
>>>
>>> To tell the truth, I can't figure out what this means from a user
>>> perspective.  How does a user know whether the linker option is
>>> being ignored, or if they have a new enough linker?  If the linker
>>> available at configuration time doesn't support the option, does
>>> that mean the option will never be passed and users will never know
>>> that there are gaping holes in the pointer bounds checking?
>>>
>>> My suggestion would be to pass the option unconditionally and make
>>> the documentation say something like
>>
>>
>> This option was rejected.
>
> Right.  There really isn't a good option here because we don't have the
> infrastructure to query the linker's capabilities at link time.
>
> Though I do wonder if we could issue a warning in the case where the
> configure test indicated -z bndplt was not supported.

I thought about such possibility. Just don't see a good place for
that. Probably introduce some WARNING_SPEC which targets may define to
issue a driver warning?

Ilya

>
> It'd obviously mean a link warning every time an end user tried to use that
> toolchain to create a DSO or executable with MPX protection.  But that may
> be better than silently leaving some code unprotected.
>
>
> Jeff
>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-04-06 15:18         ` Ilya Enkovich
  2015-04-06 15:28           ` Jeff Law
@ 2015-04-06 17:15           ` Sandra Loosemore
  2015-04-07 19:01             ` Jeff Law
  1 sibling, 1 reply; 49+ messages in thread
From: Sandra Loosemore @ 2015-04-06 17:15 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Joseph Myers, Richard Biener, gcc-patches

On 04/06/2015 09:17 AM, Ilya Enkovich wrote:
> On 05 Apr 19:44, Sandra Loosemore wrote:
>> On 04/03/2015 01:34 PM, Joseph Myers wrote:
>>> On Tue, 31 Mar 2015, Ilya Enkovich wrote:
>>>
>>>> +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
>>>
>>> Use @samp{-z bndplt} rather than '' quoting (but Sandra may have further
>>> advice on the substance of this documentation).
>>
>> To tell the truth, I can't figure out what this means from a user
>> perspective.  How does a user know whether the linker option is
>> being ignored, or if they have a new enough linker?  If the linker
>> available at configuration time doesn't support the option, does
>> that mean the option will never be passed and users will never know
>> that there are gaping holes in the pointer bounds checking?
>>
>> My suggestion would be to pass the option unconditionally and make
>> the documentation say something like
>
> This option was rejected.

Hrmmmm, how about then just *never* passing the magic option to the 
linker, and telling users they either have to pass it manually (and use 
a linker that supports it), use static linking, or do without bounds 
checking on dynamic libraries?

Remember that most GCC users do not configure GCC themselves...  they 
use whatever came with their distro or from their toolchain vendor, or 
was installed by their sysadmin.  So most GCC users have no way to know 
what linker their GCC binary was configured with and it's just confusing 
that this important linker option might or might not be included based 
on factors they don't know about or can't control.

> +++ b/gcc/doc/invoke.texi
> @@ -5858,12 +5858,12 @@ 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 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
> +library.  It also passes @option{-z bndplt} to a linker in case it supports
> +this option (which is checked on libmpx configuration).  LD supports it starting
> +from version 2.25.  Gold linker doesn't support @option{-z bndplt}
> +option.  With no @option{-z bndplt} support in a linker all calls to dynamic
> +libraries lose passed bounds reducing overall protection level.  It's highly
> +recommended to use linker with @option{-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

Besides being confusing, there are typos ("adviced") and grammatical 
errors here.

If we really cannot make the linker option either always used or always 
omitted, how about something like this?

If GCC was configured with a linker that supports @option{-z bndplt}, 
then this option is also passed when linking.  It is supported in LD 
starting with version 2.25, but not in the Gold linker.  You should pass 
@option{-z bndplt} on your link line explicitly if you are not certain 
how your GCC was configured.
Without this option and appropriate linker support, all calls to dynamic 
libraries lose bounds checking information.  If no linker support for 
@option{-z bndplt} is available, you should link with @option{-static} 
instead to avoid external calls to dynamic libraries.

...then add a paragraph break before "MPX-based instrumentation...."

-Sandra

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-04-06 17:15           ` Sandra Loosemore
@ 2015-04-07 19:01             ` Jeff Law
  2015-04-07 19:29               ` H.J. Lu
  0 siblings, 1 reply; 49+ messages in thread
From: Jeff Law @ 2015-04-07 19:01 UTC (permalink / raw)
  To: Sandra Loosemore, Ilya Enkovich; +Cc: Joseph Myers, Richard Biener, gcc-patches

On 04/06/2015 11:14 AM, Sandra Loosemore wrote:
> On 04/06/2015 09:17 AM, Ilya Enkovich wrote:
>> On 05 Apr 19:44, Sandra Loosemore wrote:
>>> On 04/03/2015 01:34 PM, Joseph Myers wrote:
>>>> On Tue, 31 Mar 2015, Ilya Enkovich wrote:
>>>>
>>>>> +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
>>>>
>>>> Use @samp{-z bndplt} rather than '' quoting (but Sandra may have
>>>> further
>>>> advice on the substance of this documentation).
>>>
>>> To tell the truth, I can't figure out what this means from a user
>>> perspective.  How does a user know whether the linker option is
>>> being ignored, or if they have a new enough linker?  If the linker
>>> available at configuration time doesn't support the option, does
>>> that mean the option will never be passed and users will never know
>>> that there are gaping holes in the pointer bounds checking?
>>>
>>> My suggestion would be to pass the option unconditionally and make
>>> the documentation say something like
>>
>> This option was rejected.
>
> Hrmmmm, how about then just *never* passing the magic option to the
> linker, and telling users they either have to pass it manually (and use
> a linker that supports it), use static linking, or do without bounds
> checking on dynamic libraries?
>
> Remember that most GCC users do not configure GCC themselves...  they
> use whatever came with their distro or from their toolchain vendor, or
> was installed by their sysadmin.  So most GCC users have no way to know
> what linker their GCC binary was configured with and it's just confusing
> that this important linker option might or might not be included based
> on factors they don't know about or can't control.
But the same arguments apply to forcing the user to manually pass the 
argument, select static linking, etc.

If I think about the most common case usage, it's going to be a 
compiler/binutils pair built by a distribution such as Fedora, Ubuntu, 
etc and the configure time test will do the right thing.  It's only 
cases where folks are updating components separately, or building 
themselves that the configure time test falls down.


Jeff

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-04-07 19:01             ` Jeff Law
@ 2015-04-07 19:29               ` H.J. Lu
  2015-04-07 20:12                 ` Markus Trippelsdorf
  0 siblings, 1 reply; 49+ messages in thread
From: H.J. Lu @ 2015-04-07 19:29 UTC (permalink / raw)
  To: Jeff Law
  Cc: Sandra Loosemore, Ilya Enkovich, Joseph Myers, Richard Biener,
	gcc-patches

On Tue, Apr 7, 2015 at 12:01 PM, Jeff Law <law@redhat.com> wrote:
> On 04/06/2015 11:14 AM, Sandra Loosemore wrote:
>>
>> On 04/06/2015 09:17 AM, Ilya Enkovich wrote:
>>>
>>> On 05 Apr 19:44, Sandra Loosemore wrote:
>>>>
>>>> On 04/03/2015 01:34 PM, Joseph Myers wrote:
>>>>>
>>>>> On Tue, 31 Mar 2015, Ilya Enkovich wrote:
>>>>>
>>>>>> +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
>>>>>
>>>>>
>>>>> Use @samp{-z bndplt} rather than '' quoting (but Sandra may have
>>>>> further
>>>>> advice on the substance of this documentation).
>>>>
>>>>
>>>> To tell the truth, I can't figure out what this means from a user
>>>> perspective.  How does a user know whether the linker option is
>>>> being ignored, or if they have a new enough linker?  If the linker
>>>> available at configuration time doesn't support the option, does
>>>> that mean the option will never be passed and users will never know
>>>> that there are gaping holes in the pointer bounds checking?
>>>>
>>>> My suggestion would be to pass the option unconditionally and make
>>>> the documentation say something like
>>>
>>>
>>> This option was rejected.
>>
>>
>> Hrmmmm, how about then just *never* passing the magic option to the
>> linker, and telling users they either have to pass it manually (and use
>> a linker that supports it), use static linking, or do without bounds
>> checking on dynamic libraries?
>>
>> Remember that most GCC users do not configure GCC themselves...  they
>> use whatever came with their distro or from their toolchain vendor, or
>> was installed by their sysadmin.  So most GCC users have no way to know
>> what linker their GCC binary was configured with and it's just confusing
>> that this important linker option might or might not be included based
>> on factors they don't know about or can't control.
>
> But the same arguments apply to forcing the user to manually pass the
> argument, select static linking, etc.
>
> If I think about the most common case usage, it's going to be a
> compiler/binutils pair built by a distribution such as Fedora, Ubuntu, etc
> and the configure time test will do the right thing.  It's only cases where
> folks are updating components separately, or building themselves that the
> configure time test falls down.

You can't have it both ways.  If the common usage is targeting
distributions, -z bndplt should always be passed to ld for MPX
since distributions should have the proper linker for MPX.

-- 
H.J.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-04-07 19:29               ` H.J. Lu
@ 2015-04-07 20:12                 ` Markus Trippelsdorf
  0 siblings, 0 replies; 49+ messages in thread
From: Markus Trippelsdorf @ 2015-04-07 20:12 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Jeff Law, Sandra Loosemore, Ilya Enkovich, Joseph Myers,
	Richard Biener, gcc-patches

On 2015.04.07 at 12:28 -0700, H.J. Lu wrote:
> You can't have it both ways.  If the common usage is targeting
> distributions, -z bndplt should always be passed to ld for MPX
> since distributions should have the proper linker for MPX.

Why don't you just implement -z bndplt for gold?

-- 
Markus

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-04-06 15:28           ` Jeff Law
  2015-04-06 15:54             ` Ilya Enkovich
@ 2015-05-26  9:26             ` Ilya Enkovich
  2015-05-27 15:35               ` Jeff Law
  1 sibling, 1 reply; 49+ messages in thread
From: Ilya Enkovich @ 2015-05-26  9:26 UTC (permalink / raw)
  To: Jeff Law; +Cc: Sandra Loosemore, Joseph Myers, Richard Biener, gcc-patches

On 06 Apr 09:28, Jeff Law wrote:
> On 04/06/2015 09:17 AM, Ilya Enkovich wrote:
> >>
> >>To tell the truth, I can't figure out what this means from a user
> >>perspective.  How does a user know whether the linker option is
> >>being ignored, or if they have a new enough linker?  If the linker
> >>available at configuration time doesn't support the option, does
> >>that mean the option will never be passed and users will never know
> >>that there are gaping holes in the pointer bounds checking?
> >>
> >>My suggestion would be to pass the option unconditionally and make
> >>the documentation say something like
> >
> >This option was rejected.
> Right.  There really isn't a good option here because we don't have
> the infrastructure to query the linker's capabilities at link time.
> 
> Though I do wonder if we could issue a warning in the case where the
> configure test indicated -z bndplt was not supported.
> 
> It'd obviously mean a link warning every time an end user tried to
> use that toolchain to create a DSO or executable with MPX
> protection.  But that may be better than silently leaving some code
> unprotected.
> 
> 
> Jeff
> 

Hi,

Here is a patch to add a note in case we build dynamic MPX codes and don't pass '-z bndplt'.  Does it look OK?

Thanks,
Ilya
--
gcc/

2015-05-26  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* config/i386/linux-common.h (MPX_SPEC): Add link
	warning.

libmpx/

2015-05-26  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* configure.ac: Add link_mpx_warning.
	* libmpx.spec.in: Likewise.
	* configure: Regenerate.


diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
index dd79ec6..fcaab81 100644
--- a/gcc/config/i386/linux-common.h
+++ b/gcc/config/i386/linux-common.h
@@ -61,7 +61,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #ifndef MPX_SPEC
 #define MPX_SPEC "\
- %{mmpx:%{fcheck-pointer-bounds:%{!static:%:include(libmpx.spec)%(link_mpx)}}}"
+ %{mmpx:%{fcheck-pointer-bounds:%{!static:%:include(libmpx.spec)%(link_mpx) \
+ %(link_mpx_warning)}}}"
 #endif
 
 #ifndef LIBMPX_SPEC
diff --git a/libmpx/configure.ac b/libmpx/configure.ac
index 463e855..7e9ef86 100644
--- a/libmpx/configure.ac
+++ b/libmpx/configure.ac
@@ -40,17 +40,22 @@ AM_CONDITIONAL(LIBMPX_SUPPORTED, [test "x$LIBMPX_SUPPORTED" = "xyes"])
 
 link_libmpx="-lpthread"
 link_mpx=""
+link_mpx_warning=""
 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"
+    link_mpx_warning="%{mmpx:}"
 else
     AC_MSG_RESULT([no])
+    link_mpx="%{mmpx:}"
+    link_mpx_warning="%nGCC was configured with a linker with no '-z bndplt' support. It significantly reduces MPX coverage for dynamic codes. It is strongly recommended to use GCC properly configured for MPX."
 fi
 AC_SUBST(link_libmpx)
 AC_SUBST(link_mpx)
+AC_SUBST(link_mpx_warning)
 
 AM_INIT_AUTOMAKE(foreign no-dist no-dependencies)
 AM_ENABLE_MULTILIB(, ..)
diff --git a/libmpx/libmpx.spec.in b/libmpx/libmpx.spec.in
index 34d0bdf..854f13d 100644
--- a/libmpx/libmpx.spec.in
+++ b/libmpx/libmpx.spec.in
@@ -3,3 +3,5 @@
 *link_libmpx: @link_libmpx@
 
 *link_mpx: @link_mpx@
+
+*link_mpx_warning: @link_mpx_warning@

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-05-26  9:26             ` Ilya Enkovich
@ 2015-05-27 15:35               ` Jeff Law
  2015-06-03  9:04                 ` Ilya Enkovich
  0 siblings, 1 reply; 49+ messages in thread
From: Jeff Law @ 2015-05-27 15:35 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Sandra Loosemore, Joseph Myers, Richard Biener, gcc-patches

On 05/26/2015 03:13 AM, Ilya Enkovich wrote:
> On 06 Apr 09:28, Jeff Law wrote:
>> On 04/06/2015 09:17 AM, Ilya Enkovich wrote:
>>>>
>>>> To tell the truth, I can't figure out what this means from a user
>>>> perspective.  How does a user know whether the linker option is
>>>> being ignored, or if they have a new enough linker?  If the linker
>>>> available at configuration time doesn't support the option, does
>>>> that mean the option will never be passed and users will never know
>>>> that there are gaping holes in the pointer bounds checking?
>>>>
>>>> My suggestion would be to pass the option unconditionally and make
>>>> the documentation say something like
>>>
>>> This option was rejected.
>> Right.  There really isn't a good option here because we don't have
>> the infrastructure to query the linker's capabilities at link time.
>>
>> Though I do wonder if we could issue a warning in the case where the
>> configure test indicated -z bndplt was not supported.
>>
>> It'd obviously mean a link warning every time an end user tried to
>> use that toolchain to create a DSO or executable with MPX
>> protection.  But that may be better than silently leaving some code
>> unprotected.
>>
>>
>> Jeff
>>
>
> Hi,
>
> Here is a patch to add a note in case we build dynamic MPX codes and don't pass '-z bndplt'.  Does it look OK?
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2015-05-26  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
> 	* config/i386/linux-common.h (MPX_SPEC): Add link
> 	warning.
>
> libmpx/
>
> 2015-05-26  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
> 	* configure.ac: Add link_mpx_warning.
> 	* libmpx.spec.in: Likewise.
> 	* configure: Regenerate.
Is there a way to do this outside of the specs mechanism?  If done in 
the specs, are these warnings translated for locales?

Jeff

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-05-27 15:35               ` Jeff Law
@ 2015-06-03  9:04                 ` Ilya Enkovich
  2015-06-03 15:29                   ` Joseph Myers
  0 siblings, 1 reply; 49+ messages in thread
From: Ilya Enkovich @ 2015-06-03  9:04 UTC (permalink / raw)
  To: Jeff Law; +Cc: Sandra Loosemore, Joseph Myers, Richard Biener, gcc-patches

2015-05-27 18:19 GMT+03:00 Jeff Law <law@redhat.com>:
> On 05/26/2015 03:13 AM, Ilya Enkovich wrote:
>>
>> On 06 Apr 09:28, Jeff Law wrote:
>>>
>>> On 04/06/2015 09:17 AM, Ilya Enkovich wrote:
>>>>>
>>>>>
>>>>> To tell the truth, I can't figure out what this means from a user
>>>>> perspective.  How does a user know whether the linker option is
>>>>> being ignored, or if they have a new enough linker?  If the linker
>>>>> available at configuration time doesn't support the option, does
>>>>> that mean the option will never be passed and users will never know
>>>>> that there are gaping holes in the pointer bounds checking?
>>>>>
>>>>> My suggestion would be to pass the option unconditionally and make
>>>>> the documentation say something like
>>>>
>>>>
>>>> This option was rejected.
>>>
>>> Right.  There really isn't a good option here because we don't have
>>> the infrastructure to query the linker's capabilities at link time.
>>>
>>> Though I do wonder if we could issue a warning in the case where the
>>> configure test indicated -z bndplt was not supported.
>>>
>>> It'd obviously mean a link warning every time an end user tried to
>>> use that toolchain to create a DSO or executable with MPX
>>> protection.  But that may be better than silently leaving some code
>>> unprotected.
>>>
>>>
>>> Jeff
>>>
>>
>> Hi,
>>
>> Here is a patch to add a note in case we build dynamic MPX codes and don't
>> pass '-z bndplt'.  Does it look OK?
>>
>> Thanks,
>> Ilya
>> --
>> gcc/
>>
>> 2015-05-26  Ilya Enkovich  <enkovich.gnu@gmail.com>
>>
>>         * config/i386/linux-common.h (MPX_SPEC): Add link
>>         warning.
>>
>> libmpx/
>>
>> 2015-05-26  Ilya Enkovich  <enkovich.gnu@gmail.com>
>>
>>         * configure.ac: Add link_mpx_warning.
>>         * libmpx.spec.in: Likewise.
>>         * configure: Regenerate.
>
> Is there a way to do this outside of the specs mechanism?  If done in the
> specs, are these warnings translated for locales?

Specs seem to be the least intrusive way to emit some target specific
message in the driver. I didn't want to add some new features into the
driver just for this single warning.

Spec files are not scanned by translator. I tried to split this spec
into two parts to move message into a header file but with no success.
Any ideas how it can be done?

Ilya

>
> Jeff
>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-06-03  9:04                 ` Ilya Enkovich
@ 2015-06-03 15:29                   ` Joseph Myers
  2015-06-03 15:59                     ` Ilya Enkovich
  0 siblings, 1 reply; 49+ messages in thread
From: Joseph Myers @ 2015-06-03 15:29 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Jeff Law, Sandra Loosemore, Richard Biener, gcc-patches

On Wed, 3 Jun 2015, Ilya Enkovich wrote:

> Spec files are not scanned by translator. I tried to split this spec
> into two parts to move message into a header file but with no success.
> Any ideas how it can be done?

If a spec in a .c or .h file contains %e or %n immediately followed by the 
message text (the message text being in the same string as the %e / %n - 
not split up with macros, etc.), then exgettext should extract the message 
for translation.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-06-03 15:29                   ` Joseph Myers
@ 2015-06-03 15:59                     ` Ilya Enkovich
  2015-06-03 16:03                       ` Joseph Myers
  0 siblings, 1 reply; 49+ messages in thread
From: Ilya Enkovich @ 2015-06-03 15:59 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Jeff Law, Sandra Loosemore, Richard Biener, gcc-patches

2015-06-03 18:25 GMT+03:00 Joseph Myers <joseph@codesourcery.com>:
> On Wed, 3 Jun 2015, Ilya Enkovich wrote:
>
>> Spec files are not scanned by translator. I tried to split this spec
>> into two parts to move message into a header file but with no success.
>> Any ideas how it can be done?
>
> If a spec in a .c or .h file contains %e or %n immediately followed by the
> message text (the message text being in the same string as the %e / %n -
> not split up with macros, etc.), then exgettext should extract the message
> for translation.

Right. But I need to enable/disable this message during configuration.
To do it I have a spec file with either note or an empty string. I
also tried to do smth like:

header:

#define MSG "%nsome msg"

#define NOTE_SPEC  "%(config_spec)" MSG "}"

spec file:

*config_spec = %{<some_opt>:

But that didn't work.

Thanks,
Ilya

>
> --
> Joseph S. Myers
> joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-06-03 15:59                     ` Ilya Enkovich
@ 2015-06-03 16:03                       ` Joseph Myers
  2015-06-04 14:14                         ` Ilya Enkovich
  0 siblings, 1 reply; 49+ messages in thread
From: Joseph Myers @ 2015-06-03 16:03 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Jeff Law, Sandra Loosemore, Richard Biener, gcc-patches

On Wed, 3 Jun 2015, Ilya Enkovich wrote:

> 2015-06-03 18:25 GMT+03:00 Joseph Myers <joseph@codesourcery.com>:
> > On Wed, 3 Jun 2015, Ilya Enkovich wrote:
> >
> >> Spec files are not scanned by translator. I tried to split this spec
> >> into two parts to move message into a header file but with no success.
> >> Any ideas how it can be done?
> >
> > If a spec in a .c or .h file contains %e or %n immediately followed by the
> > message text (the message text being in the same string as the %e / %n -
> > not split up with macros, etc.), then exgettext should extract the message
> > for translation.
> 
> Right. But I need to enable/disable this message during configuration.

You could, for example, have

#if SOMETHING
#define MSG "%nsome msg"
#else
#define MSG ""
#endif

and have another spec using MSG - that should work.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-06-03 16:03                       ` Joseph Myers
@ 2015-06-04 14:14                         ` Ilya Enkovich
  2015-06-04 15:55                           ` Joseph Myers
  0 siblings, 1 reply; 49+ messages in thread
From: Ilya Enkovich @ 2015-06-04 14:14 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Jeff Law, Sandra Loosemore, Richard Biener, gcc-patches

2015-06-03 18:59 GMT+03:00 Joseph Myers <joseph@codesourcery.com>:
> You could, for example, have
>
> #if SOMETHING
> #define MSG "%nsome msg"
> #else
> #define MSG ""
> #endif
>
> and have another spec using MSG - that should work.

In this case I should define SOMETHING in configure of gcc, not in
configure of libmpx, right? But it would mean I check host linker, not
target.

Ilya

>
> --
> Joseph S. Myers
> joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-06-04 14:14                         ` Ilya Enkovich
@ 2015-06-04 15:55                           ` Joseph Myers
  2015-06-05 14:44                             ` Ilya Enkovich
  0 siblings, 1 reply; 49+ messages in thread
From: Joseph Myers @ 2015-06-04 15:55 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Jeff Law, Sandra Loosemore, Richard Biener, gcc-patches

On Thu, 4 Jun 2015, Ilya Enkovich wrote:

> 2015-06-03 18:59 GMT+03:00 Joseph Myers <joseph@codesourcery.com>:
> > You could, for example, have
> >
> > #if SOMETHING
> > #define MSG "%nsome msg"
> > #else
> > #define MSG ""
> > #endif
> >
> > and have another spec using MSG - that should work.
> 
> In this case I should define SOMETHING in configure of gcc, not in
> configure of libmpx, right? But it would mean I check host linker, not
> target.

gcc/ configure tests on the linker generally test the build-x-target 
linker, which is required to have the same version and be configured the 
same as the host-x-target linker.  (The tests mustn't actually try to link 
anything, but they can e.g. see if a particular option is mentioned in 
--help output.  In general they also have version number checks for the 
case of an in-tree linker build.)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-06-04 15:55                           ` Joseph Myers
@ 2015-06-05 14:44                             ` Ilya Enkovich
  2015-06-25 19:00                               ` Jeff Law
  0 siblings, 1 reply; 49+ messages in thread
From: Ilya Enkovich @ 2015-06-05 14:44 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Jeff Law, Sandra Loosemore, Richard Biener, gcc-patches

On 04 Jun 15:53, Joseph Myers wrote:
> On Thu, 4 Jun 2015, Ilya Enkovich wrote:
> 
> > 2015-06-03 18:59 GMT+03:00 Joseph Myers <joseph@codesourcery.com>:
> > > You could, for example, have
> > >
> > > #if SOMETHING
> > > #define MSG "%nsome msg"
> > > #else
> > > #define MSG ""
> > > #endif
> > >
> > > and have another spec using MSG - that should work.
> > 
> > In this case I should define SOMETHING in configure of gcc, not in
> > configure of libmpx, right? But it would mean I check host linker, not
> > target.
> 
> gcc/ configure tests on the linker generally test the build-x-target 
> linker, which is required to have the same version and be configured the 
> same as the host-x-target linker.  (The tests mustn't actually try to link 
> anything, but they can e.g. see if a particular option is mentioned in 
> --help output.  In general they also have version number checks for the 
> case of an in-tree linker build.)
> 
> -- 
> Joseph S. Myers
> joseph@codesourcery.com

Thanks for help!  Here is a new patch version with a check moved into gcc/configure.  Does it look OK?

Thanks,
Ilya
--
gcc/

2015-06-05  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* config/i386/linux-common.h (LINK_MPX): New.
	(MPX_SPEC): Use LINK_MPX instead of %(link_mpx).
	* configure.ac: Add HAVE_LD_BNDPLT_SUPPORT macro
	indicating '-z bndplt' support by linker.
	* configure: Regenerate.
	* config.in: Regenerate.

libmpx/

2015-06-05  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* configure.ac: Remove link_mpx.
	* libmpx.spec.in: Likewise.
	* configure: Regenerate.


diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
index dd79ec6..63dd8d8 100644
--- a/gcc/config/i386/linux-common.h
+++ b/gcc/config/i386/linux-common.h
@@ -59,9 +59,20 @@ along with GCC; see the file COPYING3.  If not see
  %:include(libmpx.spec)%(link_libmpx)"
 #endif
 
+#ifndef LINK_MPX
+#if defined (HAVE_LD_BNDPLT_SUPPORT)
+#define LINK_MPX "-z bndplt "
+#else
+#define LINK_MPX \
+  "%nGCC was configured with a linker with no '-z bndplt' support. " \
+  "It significantly reduces MPX coverage for dynamic codes. " \
+  "It is strongly recommended to use GCC properly configured for MPX."
+#endif
+#endif
+
 #ifndef MPX_SPEC
 #define MPX_SPEC "\
- %{mmpx:%{fcheck-pointer-bounds:%{!static:%:include(libmpx.spec)%(link_mpx)}}}"
+ %{mmpx:%{fcheck-pointer-bounds:%{!static:" LINK_MPX "}}}"
 #endif
 
 #ifndef LIBMPX_SPEC
diff --git a/gcc/configure.ac b/gcc/configure.ac
index b27433e..7306a70 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5859,6 +5859,27 @@ if test "$gcc_cv_no_pie" = "yes"; then
 fi
 AC_SUBST([NO_PIE_FLAG])
 
+# Check linker supports '-z bndplt'
+ld_bndplt_support=no
+AC_MSG_CHECKING(linker -z bndplt option)
+if test x"$ld_is_gold" = xno; then
+  if test $in_tree_ld = yes ; then
+    if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 25 -o "$gcc_cv_gld_major_version" -gt 2; then
+      ld_bndplt_support=yes
+    fi
+  elif test x$gcc_cv_ld != x; then
+    # Check if linker supports -a bndplt option
+    if $gcc_cv_ld --help 2>/dev/null | grep -- '-z bndplt' > /dev/null; then
+      ld_bndplt_support=yes
+    fi
+  fi
+fi
+if test x"$ld_bndplt_support" = xyes; then
+  AC_DEFINE(HAVE_LD_BNDPLT_SUPPORT, 1,
+	[Define if your linker supports -z bndplt])
+fi
+AC_MSG_RESULT($ld_bndplt_support)
+
 # Configure the subdirectories
 # AC_CONFIG_SUBDIRS($subdirs)
 
diff --git a/libmpx/configure.ac b/libmpx/configure.ac
index 463e855..18ba687 100644
--- a/libmpx/configure.ac
+++ b/libmpx/configure.ac
@@ -39,18 +39,7 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
 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(, ..)
diff --git a/libmpx/libmpx.spec.in b/libmpx/libmpx.spec.in
index 34d0bdf..a80bba7 100644
--- a/libmpx/libmpx.spec.in
+++ b/libmpx/libmpx.spec.in
@@ -1,5 +1,3 @@
 # This spec file is read by gcc when linking.  It is used to specify the
 # standard libraries we need in order to link with libmpx.
 *link_libmpx: @link_libmpx@
-
-*link_mpx: @link_mpx@

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX
  2015-06-05 14:44                             ` Ilya Enkovich
@ 2015-06-25 19:00                               ` Jeff Law
  0 siblings, 0 replies; 49+ messages in thread
From: Jeff Law @ 2015-06-25 19:00 UTC (permalink / raw)
  To: Ilya Enkovich, Joseph Myers; +Cc: Sandra Loosemore, Richard Biener, gcc-patches

On 06/05/2015 08:01 AM, Ilya Enkovich wrote:
> On 04 Jun 15:53, Joseph Myers wrote:
>> On Thu, 4 Jun 2015, Ilya Enkovich wrote:
>>
>>> 2015-06-03 18:59 GMT+03:00 Joseph Myers <joseph@codesourcery.com>:
>>>> You could, for example, have
>>>>
>>>> #if SOMETHING
>>>> #define MSG "%nsome msg"
>>>> #else
>>>> #define MSG ""
>>>> #endif
>>>>
>>>> and have another spec using MSG - that should work.
>>>
>>> In this case I should define SOMETHING in configure of gcc, not in
>>> configure of libmpx, right? But it would mean I check host linker, not
>>> target.
>>
>> gcc/ configure tests on the linker generally test the build-x-target
>> linker, which is required to have the same version and be configured the
>> same as the host-x-target linker.  (The tests mustn't actually try to link
>> anything, but they can e.g. see if a particular option is mentioned in
>> --help output.  In general they also have version number checks for the
>> case of an in-tree linker build.)
>>
>> --
>> Joseph S. Myers
>> joseph@codesourcery.com
>
> Thanks for help!  Here is a new patch version with a check moved into gcc/configure.  Does it look OK?
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2015-06-05  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
> 	* config/i386/linux-common.h (LINK_MPX): New.
> 	(MPX_SPEC): Use LINK_MPX instead of %(link_mpx).
> 	* configure.ac: Add HAVE_LD_BNDPLT_SUPPORT macro
> 	indicating '-z bndplt' support by linker.
> 	* configure: Regenerate.
> 	* config.in: Regenerate.
>
> libmpx/
>
> 2015-06-05  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
> 	* configure.ac: Remove link_mpx.
> 	* libmpx.spec.in: Likewise.
> 	* configure: Regenerate.
OK.  Sorry for the long wait.

jeff

^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2015-06-25 18:52 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-18 11:56 [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX Ilya Enkovich
2015-03-18 12:03 ` H.J. Lu
2015-03-18 12:05   ` Ilya Enkovich
2015-03-18 12:08     ` H.J. Lu
2015-03-18 12:13       ` Ilya Enkovich
2015-03-18 12:25         ` H.J. Lu
2015-03-18 12:42           ` Richard Biener
2015-03-18 13:24             ` Ilya Enkovich
2015-03-18 13:32               ` H.J. Lu
2015-03-18 13:41                 ` Ilya Enkovich
2015-03-18 13:52                   ` H.J. Lu
2015-03-18 13:59                     ` Ilya Enkovich
2015-03-18 14:02                       ` Jakub Jelinek
2015-03-18 14:31                         ` H.J. Lu
2015-03-18 14:42                           ` H.J. Lu
2015-03-18 16:14                             ` Ilya Enkovich
2015-03-18 16:45                               ` H.J. Lu
2015-03-18 17:13                                 ` Ilya Enkovich
2015-03-18 17:14                                   ` H.J. Lu
2015-03-18 17:34                                     ` Ilya Enkovich
2015-03-18 17:39                                       ` H.J. Lu
2015-03-18 18:13                                         ` Ilya Enkovich
2015-03-18 14:03                       ` Robert Dewar
2015-03-18 14:33                         ` Markus Trippelsdorf
2015-03-23 10:19 ` Ilya Enkovich
2015-03-31  9:47   ` Ilya Enkovich
2015-04-02  4:34     ` Jeff Law
2015-04-02 11:01       ` H.J. Lu
2015-04-03 19:34     ` Joseph Myers
2015-04-06  1:45       ` Sandra Loosemore
2015-04-06  2:35         ` H.J. Lu
2015-04-06  3:08           ` Sandra Loosemore
2015-04-06 15:18         ` Ilya Enkovich
2015-04-06 15:28           ` Jeff Law
2015-04-06 15:54             ` Ilya Enkovich
2015-05-26  9:26             ` Ilya Enkovich
2015-05-27 15:35               ` Jeff Law
2015-06-03  9:04                 ` Ilya Enkovich
2015-06-03 15:29                   ` Joseph Myers
2015-06-03 15:59                     ` Ilya Enkovich
2015-06-03 16:03                       ` Joseph Myers
2015-06-04 14:14                         ` Ilya Enkovich
2015-06-04 15:55                           ` Joseph Myers
2015-06-05 14:44                             ` Ilya Enkovich
2015-06-25 19:00                               ` Jeff Law
2015-04-06 17:15           ` Sandra Loosemore
2015-04-07 19:01             ` Jeff Law
2015-04-07 19:29               ` H.J. Lu
2015-04-07 20:12                 ` Markus Trippelsdorf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).