On Fri, Jan 13, 2017 at 11:19:19AM +0300, Maxim Ostapenko wrote:
> as mentioned in PR, Linux kernel 4.9 fails to build with ASan due to wrong
> handling of emitted ODR indicator symbols. Although this might be a kernel
> bug (relying on specific pattern in symbol name sounds questionable), kernel
> doesn't need ODR indicators at all thus we can just disable them if
> -fsanitize=kernel-address is present.
> Tested on x86_64-unknown-linux-gnu, OK for trunk?

> gcc/ChangeLog:
> 
> 2017-01-13  Maxim Ostapenko  <m.ostape...@samsung.com>
> 
>       PR sanitizer/78887
>       * asan.c (asan_needs_odr_indicator_p): Don't emit ODR indicators
>       if -fsanitize=kernel-address is present.
> 
> diff --git a/gcc/asan.c b/gcc/asan.c
> index bc7ebc8..157d468 100644
> --- a/gcc/asan.c
> +++ b/gcc/asan.c
> @@ -2360,7 +2360,8 @@ create_odr_indicator (tree decl, tree type)
>  static bool
>  asan_needs_odr_indicator_p (tree decl)
>  {
> -  return !DECL_ARTIFICIAL (decl) && !DECL_WEAK (decl) && TREE_PUBLIC (decl);
> +  return !(flag_sanitize & SANITIZE_KERNEL_ADDRESS) && !DECL_ARTIFICIAL 
> (decl)
> +      && !DECL_WEAK (decl) && TREE_PUBLIC (decl);

As the condition is longer than a line, please use
  return (!(flag_sanitize & SANITIZE_KERNEL_ADDRESS)
          && !DECL_ARTIFICIAL (decl)
          && !DECL_WEAK (decl)
          && TREE_PUBLIC (decl));
instead (i.e. one sub-condition per line, and ()s around the whole
condition.  Perhaps a short comment why we don't emit those for
-fsanitize=kernel-address would be useful too.

Ok for trunk with those changes.

        Jakub

Reply via email to