Should the alignment check be moved into 'asan_protect_global' method?

David


On Thu, Oct 25, 2012 at 2:32 PM, Wei Mi <w...@google.com> wrote:
> Hi,
>
> A small patch to remove the bogus error reports exposed in the
> spec2000 testing. In varasm.c, asan_protected should be equivalent
> with asan_protect_global (decl) all the time, or else compiler will
> not insert redzones for some globals planned to be protected.
>
> gcc/ChangeLog:
> 2012-10-25   Wei Mi  <w...@google.com>
>
> A small fix to remove bogus error report of global buffer overflow.
> * varasm.c: correct the condition of asan_protected being true.
>
> Index: varasm.c
> ===================================================================
> --- varasm.c    (revision 192822)
> +++ varasm.c    (working copy)
> @@ -1991,11 +1991,10 @@ assemble_variable (tree decl, int top_le
>    align_variable (decl, dont_output_data);
>
>    if (flag_asan
> -      && asan_protect_global (decl)
> -      && DECL_ALIGN (decl) < ASAN_RED_ZONE_SIZE * BITS_PER_UNIT)
> +      && asan_protect_global (decl))
>      {
>        asan_protected = true;
> -      DECL_ALIGN (decl) = ASAN_RED_ZONE_SIZE * BITS_PER_UNIT;
> +      DECL_ALIGN (decl) = MAX (DECL_ALIGN (decl), ASAN_RED_ZONE_SIZE
> * BITS_PER_UNIT);
>      }
>
>    set_mem_align (decl_rtl, DECL_ALIGN (decl));
>
> Thanks,
> Wei.

Reply via email to