* [PATCH] gcc: xtensa: enable address sanitizer
@ 2017-12-04 21:29 Max Filippov
2017-12-04 21:31 ` Jakub Jelinek
2017-12-05 5:37 ` augustine.sterling
0 siblings, 2 replies; 5+ messages in thread
From: Max Filippov @ 2017-12-04 21:29 UTC (permalink / raw)
To: gcc-patches; +Cc: linux-xtensa, Sterling Augustine, Max Filippov
gcc/
2017-12-04 Max Filippov <jcmvbkbc@gmail.com>
* config/xtensa/xtensa.c (xtensa_asan_shadow_offset): New
function.
(TARGET_ASAN_SHADOW_OFFSET): New macro definition.
* config/xtensa/xtensa.h (FRAME_GROWS_DOWNWARD): Set to 1 if
ASAN is enabled.
---
gcc/config/xtensa/xtensa.c | 12 ++++++++++++
gcc/config/xtensa/xtensa.h | 3 ++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
index 1e73b2f4405d..92b9a600df82 100644
--- a/gcc/config/xtensa/xtensa.c
+++ b/gcc/config/xtensa/xtensa.c
@@ -183,6 +183,7 @@ static bool xtensa_hard_regno_mode_ok (unsigned int, machine_mode);
static bool xtensa_modes_tieable_p (machine_mode, machine_mode);
static HOST_WIDE_INT xtensa_constant_alignment (const_tree, HOST_WIDE_INT);
static HOST_WIDE_INT xtensa_starting_frame_offset (void);
+static unsigned HOST_WIDE_INT xtensa_asan_shadow_offset (void);
\f
@@ -325,6 +326,9 @@ static HOST_WIDE_INT xtensa_starting_frame_offset (void);
#undef TARGET_STARTING_FRAME_OFFSET
#define TARGET_STARTING_FRAME_OFFSET xtensa_starting_frame_offset
+#undef TARGET_ASAN_SHADOW_OFFSET
+#define TARGET_ASAN_SHADOW_OFFSET xtensa_asan_shadow_offset
+
struct gcc_target targetm = TARGET_INITIALIZER;
\f
@@ -4413,4 +4417,12 @@ xtensa_starting_frame_offset (void)
return crtl->outgoing_args_size;
}
+/* Implement TARGET_ASAN_SHADOW_OFFSET. */
+
+static unsigned HOST_WIDE_INT
+xtensa_asan_shadow_offset (void)
+{
+ return HOST_WIDE_INT_UC (0x10000000);
+}
+
#include "gt-xtensa.h"
diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h
index b4cf53708b3e..1602fae3d9ea 100644
--- a/gcc/config/xtensa/xtensa.h
+++ b/gcc/config/xtensa/xtensa.h
@@ -430,7 +430,8 @@ enum reg_class
#define STACK_GROWS_DOWNWARD 1
-#define FRAME_GROWS_DOWNWARD flag_stack_protect
+#define FRAME_GROWS_DOWNWARD (flag_stack_protect \
+ || (flag_sanitize & SANITIZE_ADDRESS) != 0)
/* The ARG_POINTER and FRAME_POINTER are not real Xtensa registers, so
they are eliminated to either the stack pointer or hard frame pointer. */
--
2.1.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gcc: xtensa: enable address sanitizer
2017-12-04 21:29 [PATCH] gcc: xtensa: enable address sanitizer Max Filippov
@ 2017-12-04 21:31 ` Jakub Jelinek
2017-12-04 21:34 ` Max Filippov
2017-12-05 5:37 ` augustine.sterling
1 sibling, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2017-12-04 21:31 UTC (permalink / raw)
To: Max Filippov; +Cc: gcc-patches, linux-xtensa, Sterling Augustine
On Mon, Dec 04, 2017 at 01:28:53PM -0800, Max Filippov wrote:
> gcc/
> 2017-12-04 Max Filippov <jcmvbkbc@gmail.com>
>
> * config/xtensa/xtensa.c (xtensa_asan_shadow_offset): New
> function.
> (TARGET_ASAN_SHADOW_OFFSET): New macro definition.
> * config/xtensa/xtensa.h (FRAME_GROWS_DOWNWARD): Set to 1 if
> ASAN is enabled.
Is this just for -fsanitize=kernel-address ? Because I don't see any
libsanitizer/ changes (and those would need to go upstream first anyway).
Jakub
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gcc: xtensa: enable address sanitizer
2017-12-04 21:31 ` Jakub Jelinek
@ 2017-12-04 21:34 ` Max Filippov
0 siblings, 0 replies; 5+ messages in thread
From: Max Filippov @ 2017-12-04 21:34 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches, linux-xtensa, Sterling Augustine
On Mon, Dec 4, 2017 at 1:31 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Mon, Dec 04, 2017 at 01:28:53PM -0800, Max Filippov wrote:
>> gcc/
>> 2017-12-04 Max Filippov <jcmvbkbc@gmail.com>
>>
>> * config/xtensa/xtensa.c (xtensa_asan_shadow_offset): New
>> function.
>> (TARGET_ASAN_SHADOW_OFFSET): New macro definition.
>> * config/xtensa/xtensa.h (FRAME_GROWS_DOWNWARD): Set to 1 if
>> ASAN is enabled.
>
> Is this just for -fsanitize=kernel-address ? Because I don't see any
> libsanitizer/ changes (and those would need to go upstream first anyway).
Yes, it's for the -fsanitize=kernel-address. I'll port libsanitizer later.
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gcc: xtensa: enable address sanitizer
2017-12-04 21:29 [PATCH] gcc: xtensa: enable address sanitizer Max Filippov
2017-12-04 21:31 ` Jakub Jelinek
@ 2017-12-05 5:37 ` augustine.sterling
2017-12-05 14:33 ` Max Filippov
1 sibling, 1 reply; 5+ messages in thread
From: augustine.sterling @ 2017-12-05 5:37 UTC (permalink / raw)
To: Max Filippov; +Cc: gcc-patches, linux-xtensa
On Mon, Dec 4, 2017 at 1:28 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> gcc/
> 2017-12-04 Max Filippov <jcmvbkbc@gmail.com>
>
> * config/xtensa/xtensa.c (xtensa_asan_shadow_offset): New
> function.
> (TARGET_ASAN_SHADOW_OFFSET): New macro definition.
> * config/xtensa/xtensa.h (FRAME_GROWS_DOWNWARD): Set to 1 if
> ASAN is enabled.
This is OK.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gcc: xtensa: enable address sanitizer
2017-12-05 5:37 ` augustine.sterling
@ 2017-12-05 14:33 ` Max Filippov
0 siblings, 0 replies; 5+ messages in thread
From: Max Filippov @ 2017-12-05 14:33 UTC (permalink / raw)
To: augustine.sterling; +Cc: gcc-patches, linux-xtensa
On Mon, Dec 4, 2017 at 9:37 PM, augustine.sterling@gmail.com
<augustine.sterling@gmail.com> wrote:
> On Mon, Dec 4, 2017 at 1:28 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
>> gcc/
>> 2017-12-04 Max Filippov <jcmvbkbc@gmail.com>
>>
>> * config/xtensa/xtensa.c (xtensa_asan_shadow_offset): New
>> function.
>> (TARGET_ASAN_SHADOW_OFFSET): New macro definition.
>> * config/xtensa/xtensa.h (FRAME_GROWS_DOWNWARD): Set to 1 if
>> ASAN is enabled.
>
> This is OK.
Thanks! Applied to trunk and backported to gcc-7-branch.
-- Max
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-12-05 14:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-04 21:29 [PATCH] gcc: xtensa: enable address sanitizer Max Filippov
2017-12-04 21:31 ` Jakub Jelinek
2017-12-04 21:34 ` Max Filippov
2017-12-05 5:37 ` augustine.sterling
2017-12-05 14:33 ` Max Filippov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).