* [PATCH 4/4] ASAN for MIPS: Add gcc port bits for MIPS to support -fsanitize=address.
@ 2018-03-23 4:04 Hans-Peter Nilsson
0 siblings, 0 replies; only message in thread
From: Hans-Peter Nilsson @ 2018-03-23 4:04 UTC (permalink / raw)
To: gcc-patches; +Cc: xiaoyur347, clm, matthew.fortune
Attribution to Jean Lee for spotting the right shadow-offset for
MIPS and for cheering on. :) See xtensa and rs6000 back-ends for
the FRAME_GROWS_DOWNWARD construct.
gcc:
2018-03-22 Hans-Peter Nilsson <hp@axis.com>
Jean Lee <xiaoyur347@gmail.com>
* config/mips/mips.c (mips_asan_shadow_offset): New function.
(TARGET_ASAN_SHADOW_OFFSET): Define.
* config/mips/mips.h (FRAME_GROWS_DOWNWARD): Augment to also be
true for -fsanitize=address.
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index aabd4b1..bfe64bb 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -22307,6 +22307,14 @@ mips_constant_alignment (const_tree exp, HOST_WIDE_INT align)
return align;
}
+/* Implement the TARGET_ASAN_SHADOW_OFFSET hook. */
+
+static unsigned HOST_WIDE_INT
+mips_asan_shadow_offset (void)
+{
+ return 0x0aaa0000;
+}
+
/* Implement TARGET_STARTING_FRAME_OFFSET. See mips_compute_frame_info
for details about the frame layout. */
@@ -22618,6 +22626,9 @@ mips_starting_frame_offset (void)
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT mips_constant_alignment
+#undef TARGET_ASAN_SHADOW_OFFSET
+#define TARGET_ASAN_SHADOW_OFFSET mips_asan_shadow_offset
+
#undef TARGET_STARTING_FRAME_OFFSET
#define TARGET_STARTING_FRAME_OFFSET mips_starting_frame_offset
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index 84ae675..f290560 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -2289,7 +2289,8 @@ enum reg_class
#define STACK_GROWS_DOWNWARD 1
-#define FRAME_GROWS_DOWNWARD flag_stack_protect
+#define FRAME_GROWS_DOWNWARD (flag_stack_protect != 0 \
+ || (flag_sanitize & SANITIZE_ADDRESS) != 0)
/* Size of the area allocated in the frame to save the GP. */
--
2.1.4
brgds, H-P
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-03-23 3:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-23 4:04 [PATCH 4/4] ASAN for MIPS: Add gcc port bits for MIPS to support -fsanitize=address Hans-Peter Nilsson
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).