[PATCH] Properly check stack alignment [BZ #27901]
H.J. Lu
hjl.tools@gmail.com
Mon May 24 13:08:34 GMT 2021
On Mon, May 24, 2021 at 3:56 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu via Libc-alpha:
>
> > 1. Replace
> >
> > if ((((uintptr_t) &_d) & (__alignof (double) - 1)) != 0)
> >
> > which may be optimized by compiler, with
> >
> > static int
> > __attribute__ ((noclone, noinline))
> > aligned (void *p, int align)
> > {
> > return (((uintptr_t) p) & (align - 1)) != 0;
> > }
>
> I think you need to use __attribute__ ((weak)) (and drop the static) for
> a fully effective compiler barrier. Due to the new global nature of the
> symbol, you probably should switch to a different identifier less prone
> to collisions.
I changed it to
int
__attribute__ ((weak, noclone, noinline))
is_aligned (void *p, int align)
{
return (((uintptr_t) p) & (align - 1)) != 0;
}
> GCC 8 also supports the noipa attribute, but that's too recent for us.
>
> Thanks,
> Florian
>
I sent out the v2 patch.
--
H.J.
More information about the Libc-alpha
mailing list