diff mbox

[9/17] Initial KAsan support

Message ID 2117376.AL8OH6CNAI@polaris
State New
Headers show

Commit Message

Eric Botcazou Oct. 17, 2014, 7:27 a.m. UTC
> The patch was slightly updated to take care of missing UBSan work
> (SANITIZE_FLOAT_DIVIDE, SANITIZE_FLOAT_CAST, SANITIZE_BOUNDS).

Why aren't you using opts->x_ here, like all the code just above?

Comments

Yury Gribov Oct. 17, 2014, 7:39 a.m. UTC | #1
On 10/17/2014 11:27 AM, Eric Botcazou wrote:
>> The patch was slightly updated to take care of missing UBSan work
>> (SANITIZE_FLOAT_DIVIDE, SANITIZE_FLOAT_CAST, SANITIZE_BOUNDS).
>
> --- a/gcc/opts.c
> +++ b/gcc/opts.c
> @@ -868,6 +868,20 @@ finish_options (struct gcc_options *opts, struct
> gcc_options *opts_set,
>     /* The -gsplit-dwarf option requires -gpubnames.  */
>     if (opts->x_dwarf_split_debug_info)
>       opts->x_debug_generate_pub_sections = 1;
> +
> +  /* Userspace and kernel ASan conflict with each other and with TSan.  */
> +
> +  if ((flag_sanitize & SANITIZE_USER_ADDRESS)
> +      && (flag_sanitize & SANITIZE_KERNEL_ADDRESS))
> +    error_at (loc,
> +              "-fsanitize=address is incompatible with "
> +              "-fsanitize=kernel-address");
> +
> +  if ((flag_sanitize & SANITIZE_ADDRESS)
> +      && (flag_sanitize & SANITIZE_THREAD))
> +    error_at (loc,
> +              "-fsanitize=address and -fsanitize=kernel-address "
> +              "are incompatible with -fsanitize=thread");
>   }
>
> Why aren't you using opts->x_ here, like all the code just above?

Well, that's a backport of ancient patch from trunk so all credits go 
there. And flag_sanitize is indeed handled differently from other 
compiler flags.

-Y
Eric Botcazou Oct. 17, 2014, 7:43 a.m. UTC | #2
> Well, that's a backport of ancient patch from trunk so all credits go
> there. And flag_sanitize is indeed handled differently from other
> compiler flags.

Really curious to know why...
Yury Gribov Oct. 17, 2014, 8:44 a.m. UTC | #3
On 10/17/2014 11:43 AM, Eric Botcazou wrote:
>> Well, that's a backport of ancient patch from trunk so all credits go
>> there. And flag_sanitize is indeed handled differently from other
>> compiler flags.
>
> Really curious to know why...

I bet this was a typo but let's wait for Jakub's comments.

-Y
Jakub Jelinek Oct. 17, 2014, 11:57 a.m. UTC | #4
On Fri, Oct 17, 2014 at 12:44:26PM +0400, Yury Gribov wrote:
> On 10/17/2014 11:43 AM, Eric Botcazou wrote:
> >>Well, that's a backport of ancient patch from trunk so all credits go
> >>there. And flag_sanitize is indeed handled differently from other
> >>compiler flags.
> >
> >Really curious to know why...
> 
> I bet this was a typo but let's wait for Jakub's comments.

The obvious change to replace the direct flag with opts->x_ preapproved.

	Jakub
diff mbox

Patch

--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -868,6 +868,20 @@  finish_options (struct gcc_options *opts, struct 
gcc_options *opts_set,
   /* The -gsplit-dwarf option requires -gpubnames.  */
   if (opts->x_dwarf_split_debug_info)
     opts->x_debug_generate_pub_sections = 1;
+
+  /* Userspace and kernel ASan conflict with each other and with TSan.  */
+
+  if ((flag_sanitize & SANITIZE_USER_ADDRESS)
+      && (flag_sanitize & SANITIZE_KERNEL_ADDRESS))
+    error_at (loc,
+              "-fsanitize=address is incompatible with "
+              "-fsanitize=kernel-address");
+
+  if ((flag_sanitize & SANITIZE_ADDRESS)
+      && (flag_sanitize & SANITIZE_THREAD))
+    error_at (loc,
+              "-fsanitize=address and -fsanitize=kernel-address "
+              "are incompatible with -fsanitize=thread");
 }