[PATCH] libphobos: Include <cet.h> to generate the CET marker for -fcf-protection

H.J. Lu hjl.tools@gmail.com
Wed Sep 9 17:08:53 GMT 2020


On Mon, Sep 7, 2020 at 7:09 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Mon, Sep 7, 2020 at 2:35 PM Iain Buclaw <ibuclaw@gdcproject.org> wrote:
> >
> > Hi,
> >
> > This patch removes whatever CET support was in the switchContext routine
> > for x86 D runtime, and instead uses the ucontext fallback, which propely
> > handles shadow stack handling.
> >
> > Rather than implementing support within D runtime itself, use libc
> > getcontext/setcontext functions if CET is enabled instead.
> >
> > HJ, does this look reasonable before I commit it?  The detection has
> > been done at configure-time, rather than adding a predefined version
> > condition for CET within the compiler.
> >
> > Done regression testing on x86_64-linux-gnu/-m32/-mx32.
> >
> > Regards
> > Iain.
> >
> > ---
> > libphobos/ChangeLog:
> >
> >         PR d/95680
> >         * Makefile.in: Regenerate.
> >         * configure: Regenerate.
> >         * configure.ac (DCFG_ENABLE_CET): Substitute.
> >         * libdruntime/Makefile.in: Regenerate.
> >         * libdruntime/config/x86/switchcontext.S: Remove CET support code.
> >         * libdruntime/core/thread.d: Import gcc.config.  Don't set version
> >         AsmExternal when GNU_Enable_CET is true.
> >         * libdruntime/gcc/config.d.in (GNU_Enable_CET): Define.
> >         * src/Makefile.in: Regenerate.
> >         * testsuite/Makefile.in: Regenerate.
>
> Looks good.  I can try it on Tiger Lake after it has been checked in.
>

Here is the patch to enable the CET marker for -fcf-protection.
I saw some D run-time failures.  I will investigate them.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-libphobos-Include-cet.h-to-generate-the-CET-marker-f.patch
Type: text/x-patch
Size: 1328 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200909/d0d06ab9/attachment.bin>


More information about the Gcc-patches mailing list