Message ID | 20150318115630.GA64546@msticlxl57.ims.intel.com |
---|---|
State | New |
Headers | show |
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.
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.
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.
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.
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?
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.
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.
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.
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.
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.
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.
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
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.
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.
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 ...
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.
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.
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.
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.
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.
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.
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.
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.
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@
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@