This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] i386; Add -mmanual-endbr and cf_check function attribute
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Richard Guenther <richard dot guenther at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Uros Bizjak <ubizjak at gmail dot com>, "Tsimbalist, Igor V" <igor dot v dot tsimbalist at intel dot com>
- Date: Mon, 3 Dec 2018 05:45:07 -0800
- Subject: Re: [PATCH] i386; Add -mmanual-endbr and cf_check function attribute
- References: <20180615125949.GA114203@intel.com> <CAFiYyc28GR1ngBUqODN=Fs4gtu9sAWCVRaY+8e7GrNaeggqTRw@mail.gmail.com>
On Mon, Jun 18, 2018 at 2:20 AM Richard Biener
<richard.guenther@gmail.com> wrote:
>
> On Fri, Jun 15, 2018 at 2:59 PM H.J. Lu <hongjiu.lu@intel.com> wrote:
> >
> > Currently GCC inserts ENDBR instruction at entries of all non-static
> > functions, unless LTO compilation is used. Marking all functions,
> > which are not called indirectly with nocf_check attribute, is not
> > ideal since 99% of functions in a program may be of this kind.
> >
> > This patch adds -mmanual-endbr and cf_check function attribute. They
> > can be used together with -fcf-protection such that ENDBR instruction
> > is inserted only at entries of functions with cf_check attribute. It
> > can limit number of ENDBR instructions to reduce program size.
> >
> > OK for trubk?
>
> I wonder if the linker could assist with ENDBR creation by
> redirecting all non-direct call relocs to a linker-generated
> stub with ENBR and a direct branch?
>
The goal of this patch is to add as few as ENDBR as possible
to reduce program size as much as possible. Also there is no
relocation for indirect branch via register.
--
H.J.