* [PATCH 1/2] libsanitizer: cherry-pick db7bca28638e from upstream
@ 2022-03-11 3:25 Xi Ruoyao
2022-03-11 3:27 ` [PATCH 2/2] Enable libsanitizer build on mips64 Xi Ruoyao
2022-03-14 16:12 ` [PATCH 1/2] libsanitizer: cherry-pick db7bca28638e from upstream Richard Sandiford
0 siblings, 2 replies; 5+ messages in thread
From: Xi Ruoyao @ 2022-03-11 3:25 UTC (permalink / raw)
To: gcc-patches; +Cc: Richard Sandiford, Richard Biener, Jeff Law, YunQiang Su
libsanitizer/
* sanitizer_common/sanitizer_atomic_clang.h: Ensures to only
include sanitizer_atomic_clang_mips.h for O32.
---
libsanitizer/sanitizer_common/sanitizer_atomic_clang.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h b/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h
index fc13ca52dda..ccf18f0786d 100644
--- a/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h
+++ b/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h
@@ -96,8 +96,8 @@ inline bool atomic_compare_exchange_weak(volatile T *a,
// This include provides explicit template instantiations for atomic_uint64_t
// on MIPS32, which does not directly support 8 byte atomics. It has to
// proceed the template definitions above.
-#if defined(_MIPS_SIM) && defined(_ABIO32)
- #include "sanitizer_atomic_clang_mips.h"
+#if defined(_MIPS_SIM) && defined(_ABIO32) && _MIPS_SIM == _ABIO32
+# include "sanitizer_atomic_clang_mips.h"
#endif
#undef ATOMIC_ORDER
--
2.35.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] Enable libsanitizer build on mips64
2022-03-11 3:25 [PATCH 1/2] libsanitizer: cherry-pick db7bca28638e from upstream Xi Ruoyao
@ 2022-03-11 3:27 ` Xi Ruoyao
2022-03-14 16:18 ` Richard Sandiford
2022-03-14 16:12 ` [PATCH 1/2] libsanitizer: cherry-pick db7bca28638e from upstream Richard Sandiford
1 sibling, 1 reply; 5+ messages in thread
From: Xi Ruoyao @ 2022-03-11 3:27 UTC (permalink / raw)
To: gcc-patches; +Cc: Richard Sandiford, YunQiang Su, Jeff Law
Bootstrapped and regtested on mips64el-linux-gnuabi64.
bootstrap-ubsan revealed 3 bugs (PR 104842, 104843, 104851).
bootstrap-asan did not reveal any new bug.
gcc/
* config/mips/mips.h (SUBTARGET_SHADOW_OFFSET): Define.
* config/mips/mips.cc (mips_option_override): Make
-fsanitize=address imply -fasynchronous-unwind-tables. This is
needed by libasan for stack backtrace on MIPS.
(mips_asan_shadow_offset): Return SUBTARGET_SHADOW_OFFSET.
gcc/testsuite:
* c-c++-common/asan/global-overflow-1.c: Skip for MIPS with some
optimization levels because inaccurate debug info is causing
dg-output mismatch on line numbers.
* g++.dg/asan/large-func-test-1.C: Likewise.
libsanitizer/
* configure.tgt: Enable build on mips64.
---
gcc/config/mips/mips.cc | 9 ++++++++-
gcc/config/mips/mips.h | 7 +++++++
gcc/testsuite/c-c++-common/asan/global-overflow-1.c | 1 +
gcc/testsuite/g++.dg/asan/large-func-test-1.C | 1 +
libsanitizer/configure.tgt | 4 ----
5 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
index 59eef515826..6b06c6380f6 100644
--- a/gcc/config/mips/mips.cc
+++ b/gcc/config/mips/mips.cc
@@ -19974,6 +19974,13 @@ mips_option_override (void)
target_flags |= MASK_64BIT;
}
+ /* -fsanitize=address needs to turn on -fasynchronous-unwind-tables in
+ order for tracebacks to be complete but not if any
+ -fasynchronous-unwind-table were already specified. */
+ if (flag_sanitize & SANITIZE_USER_ADDRESS
+ && !global_options_set.x_flag_asynchronous_unwind_tables)
+ flag_asynchronous_unwind_tables = 1;
+
if ((target_flags_explicit & MASK_FLOAT64) != 0)
{
if (mips_isa_rev >= 6 && !TARGET_FLOAT64)
@@ -22591,7 +22598,7 @@ mips_constant_alignment (const_tree exp, HOST_WIDE_INT align)
static unsigned HOST_WIDE_INT
mips_asan_shadow_offset (void)
{
- return 0x0aaa0000;
+ return SUBTARGET_SHADOW_OFFSET;
}
/* Implement TARGET_STARTING_FRAME_OFFSET. See mips_compute_frame_info
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index 0029864fdcd..858bbba3a36 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -3463,3 +3463,10 @@ struct GTY(()) machine_function {
&& !TARGET_MICROMIPS && !TARGET_FIX_24K)
#define NEED_INDICATE_EXEC_STACK 0
+
+/* Define the shadow offset for asan. Other OS's can override in the
+ respective tm.h files. */
+#ifndef SUBTARGET_SHADOW_OFFSET
+#define SUBTARGET_SHADOW_OFFSET \
+ (POINTER_SIZE == 64 ? HOST_WIDE_INT_1 << 37 : HOST_WIDE_INT_C (0x0aaa0000))
+#endif
diff --git a/gcc/testsuite/c-c++-common/asan/global-overflow-1.c b/gcc/testsuite/c-c++-common/asan/global-overflow-1.c
index 1092a316681..ec412231be0 100644
--- a/gcc/testsuite/c-c++-common/asan/global-overflow-1.c
+++ b/gcc/testsuite/c-c++-common/asan/global-overflow-1.c
@@ -22,6 +22,7 @@ int main() {
return res;
}
+/* { dg-skip-if "inaccurate debug info" { mips*-*-* } { "*" } { "-O0" } } */
/* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0.*(\n|\r\n|\r)" } */
/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*global-overflow-1.c:20|\[^\n\r]*:0|\[^\n\r]*\\+0x\[0-9a-z\]*)|\[(\])\[^\n\r]*(\n|\r\n|\r).*" } */
/* { dg-output "0x\[0-9a-f\]+ is located 0 bytes to the right of global variable" } */
diff --git a/gcc/testsuite/g++.dg/asan/large-func-test-1.C b/gcc/testsuite/g++.dg/asan/large-func-test-1.C
index b42c09e3b0d..ac9deb898c8 100644
--- a/gcc/testsuite/g++.dg/asan/large-func-test-1.C
+++ b/gcc/testsuite/g++.dg/asan/large-func-test-1.C
@@ -35,6 +35,7 @@ int main() {
delete x;
}
+// { dg-skip-if "inaccurate debug info" { mips*-*-* } { "-Os" } { "" } }
// { dg-output "ERROR: AddressSanitizer:? heap-buffer-overflow on address\[^\n\r]*" }
// { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" }
// { dg-output "\[^\n\r]*READ of size 4 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" }
diff --git a/libsanitizer/configure.tgt b/libsanitizer/configure.tgt
index 5a59ea6a1b5..fb89df4935c 100644
--- a/libsanitizer/configure.tgt
+++ b/libsanitizer/configure.tgt
@@ -54,10 +54,6 @@ case "${target}" in
;;
arm*-*-linux*)
;;
- mips*64*-*-linux*)
- # This clause is only here to not match the supported mips*-*-linux*.
- UNSUPPORTED=1
- ;;
mips*-*-linux*)
;;
aarch64*-*-linux*)
--
2.35.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] libsanitizer: cherry-pick db7bca28638e from upstream
2022-03-11 3:25 [PATCH 1/2] libsanitizer: cherry-pick db7bca28638e from upstream Xi Ruoyao
2022-03-11 3:27 ` [PATCH 2/2] Enable libsanitizer build on mips64 Xi Ruoyao
@ 2022-03-14 16:12 ` Richard Sandiford
1 sibling, 0 replies; 5+ messages in thread
From: Richard Sandiford @ 2022-03-14 16:12 UTC (permalink / raw)
To: Xi Ruoyao; +Cc: gcc-patches, Richard Biener, Jeff Law, YunQiang Su
Xi Ruoyao <xry111@mengyan1223.wang> writes:
> libsanitizer/
>
> * sanitizer_common/sanitizer_atomic_clang.h: Ensures to only
> include sanitizer_atomic_clang_mips.h for O32.
OK, thanks.
Richard
> ---
> libsanitizer/sanitizer_common/sanitizer_atomic_clang.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h b/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h
> index fc13ca52dda..ccf18f0786d 100644
> --- a/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h
> +++ b/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h
> @@ -96,8 +96,8 @@ inline bool atomic_compare_exchange_weak(volatile T *a,
> // This include provides explicit template instantiations for atomic_uint64_t
> // on MIPS32, which does not directly support 8 byte atomics. It has to
> // proceed the template definitions above.
> -#if defined(_MIPS_SIM) && defined(_ABIO32)
> - #include "sanitizer_atomic_clang_mips.h"
> +#if defined(_MIPS_SIM) && defined(_ABIO32) && _MIPS_SIM == _ABIO32
> +# include "sanitizer_atomic_clang_mips.h"
> #endif
>
> #undef ATOMIC_ORDER
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] Enable libsanitizer build on mips64
2022-03-11 3:27 ` [PATCH 2/2] Enable libsanitizer build on mips64 Xi Ruoyao
@ 2022-03-14 16:18 ` Richard Sandiford
2022-03-14 17:00 ` [pushed] " Xi Ruoyao
0 siblings, 1 reply; 5+ messages in thread
From: Richard Sandiford @ 2022-03-14 16:18 UTC (permalink / raw)
To: Xi Ruoyao; +Cc: gcc-patches, YunQiang Su, Jeff Law
Xi Ruoyao <xry111@mengyan1223.wang> writes:
> Bootstrapped and regtested on mips64el-linux-gnuabi64.
>
> bootstrap-ubsan revealed 3 bugs (PR 104842, 104843, 104851).
> bootstrap-asan did not reveal any new bug.
>
> gcc/
>
> * config/mips/mips.h (SUBTARGET_SHADOW_OFFSET): Define.
> * config/mips/mips.cc (mips_option_override): Make
> -fsanitize=address imply -fasynchronous-unwind-tables. This is
> needed by libasan for stack backtrace on MIPS.
> (mips_asan_shadow_offset): Return SUBTARGET_SHADOW_OFFSET.
>
> gcc/testsuite:
>
> * c-c++-common/asan/global-overflow-1.c: Skip for MIPS with some
> optimization levels because inaccurate debug info is causing
> dg-output mismatch on line numbers.
> * g++.dg/asan/large-func-test-1.C: Likewise.
>
> libsanitizer/
>
> * configure.tgt: Enable build on mips64.
OK, thanks.
Richard
> ---
> gcc/config/mips/mips.cc | 9 ++++++++-
> gcc/config/mips/mips.h | 7 +++++++
> gcc/testsuite/c-c++-common/asan/global-overflow-1.c | 1 +
> gcc/testsuite/g++.dg/asan/large-func-test-1.C | 1 +
> libsanitizer/configure.tgt | 4 ----
> 5 files changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
> index 59eef515826..6b06c6380f6 100644
> --- a/gcc/config/mips/mips.cc
> +++ b/gcc/config/mips/mips.cc
> @@ -19974,6 +19974,13 @@ mips_option_override (void)
> target_flags |= MASK_64BIT;
> }
>
> + /* -fsanitize=address needs to turn on -fasynchronous-unwind-tables in
> + order for tracebacks to be complete but not if any
> + -fasynchronous-unwind-table were already specified. */
> + if (flag_sanitize & SANITIZE_USER_ADDRESS
> + && !global_options_set.x_flag_asynchronous_unwind_tables)
> + flag_asynchronous_unwind_tables = 1;
> +
> if ((target_flags_explicit & MASK_FLOAT64) != 0)
> {
> if (mips_isa_rev >= 6 && !TARGET_FLOAT64)
> @@ -22591,7 +22598,7 @@ mips_constant_alignment (const_tree exp, HOST_WIDE_INT align)
> static unsigned HOST_WIDE_INT
> mips_asan_shadow_offset (void)
> {
> - return 0x0aaa0000;
> + return SUBTARGET_SHADOW_OFFSET;
> }
>
> /* Implement TARGET_STARTING_FRAME_OFFSET. See mips_compute_frame_info
> diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
> index 0029864fdcd..858bbba3a36 100644
> --- a/gcc/config/mips/mips.h
> +++ b/gcc/config/mips/mips.h
> @@ -3463,3 +3463,10 @@ struct GTY(()) machine_function {
> && !TARGET_MICROMIPS && !TARGET_FIX_24K)
>
> #define NEED_INDICATE_EXEC_STACK 0
> +
> +/* Define the shadow offset for asan. Other OS's can override in the
> + respective tm.h files. */
> +#ifndef SUBTARGET_SHADOW_OFFSET
> +#define SUBTARGET_SHADOW_OFFSET \
> + (POINTER_SIZE == 64 ? HOST_WIDE_INT_1 << 37 : HOST_WIDE_INT_C (0x0aaa0000))
> +#endif
> diff --git a/gcc/testsuite/c-c++-common/asan/global-overflow-1.c b/gcc/testsuite/c-c++-common/asan/global-overflow-1.c
> index 1092a316681..ec412231be0 100644
> --- a/gcc/testsuite/c-c++-common/asan/global-overflow-1.c
> +++ b/gcc/testsuite/c-c++-common/asan/global-overflow-1.c
> @@ -22,6 +22,7 @@ int main() {
> return res;
> }
>
> +/* { dg-skip-if "inaccurate debug info" { mips*-*-* } { "*" } { "-O0" } } */
> /* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0.*(\n|\r\n|\r)" } */
> /* { dg-output " #0 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*global-overflow-1.c:20|\[^\n\r]*:0|\[^\n\r]*\\+0x\[0-9a-z\]*)|\[(\])\[^\n\r]*(\n|\r\n|\r).*" } */
> /* { dg-output "0x\[0-9a-f\]+ is located 0 bytes to the right of global variable" } */
> diff --git a/gcc/testsuite/g++.dg/asan/large-func-test-1.C b/gcc/testsuite/g++.dg/asan/large-func-test-1.C
> index b42c09e3b0d..ac9deb898c8 100644
> --- a/gcc/testsuite/g++.dg/asan/large-func-test-1.C
> +++ b/gcc/testsuite/g++.dg/asan/large-func-test-1.C
> @@ -35,6 +35,7 @@ int main() {
> delete x;
> }
>
> +// { dg-skip-if "inaccurate debug info" { mips*-*-* } { "-Os" } { "" } }
> // { dg-output "ERROR: AddressSanitizer:? heap-buffer-overflow on address\[^\n\r]*" }
> // { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" }
> // { dg-output "\[^\n\r]*READ of size 4 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" }
> diff --git a/libsanitizer/configure.tgt b/libsanitizer/configure.tgt
> index 5a59ea6a1b5..fb89df4935c 100644
> --- a/libsanitizer/configure.tgt
> +++ b/libsanitizer/configure.tgt
> @@ -54,10 +54,6 @@ case "${target}" in
> ;;
> arm*-*-linux*)
> ;;
> - mips*64*-*-linux*)
> - # This clause is only here to not match the supported mips*-*-linux*.
> - UNSUPPORTED=1
> - ;;
> mips*-*-linux*)
> ;;
> aarch64*-*-linux*)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pushed] Enable libsanitizer build on mips64
2022-03-14 16:18 ` Richard Sandiford
@ 2022-03-14 17:00 ` Xi Ruoyao
0 siblings, 0 replies; 5+ messages in thread
From: Xi Ruoyao @ 2022-03-14 17:00 UTC (permalink / raw)
To: Richard Sandiford; +Cc: gcc-patches, YunQiang Su, Jeff Law
On Mon, 2022-03-14 at 16:18 +0000, Richard Sandiford wrote:
> Xi Ruoyao <xry111@mengyan1223.wang> writes:
> > * configure.tgt: Enable build on mips64.
I changed this to "mips*64*-*-linux*" to be more precise.
> OK, thanks.
>
> Richard
Two patches pushed as r12-7645 and r12-7646, with the minor changelog
modification above.
--
Xi Ruoyao <xry111@mengyan1223.wang>
School of Aerospace Science and Technology, Xidian University
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-14 17:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-11 3:25 [PATCH 1/2] libsanitizer: cherry-pick db7bca28638e from upstream Xi Ruoyao
2022-03-11 3:27 ` [PATCH 2/2] Enable libsanitizer build on mips64 Xi Ruoyao
2022-03-14 16:18 ` Richard Sandiford
2022-03-14 17:00 ` [pushed] " Xi Ruoyao
2022-03-14 16:12 ` [PATCH 1/2] libsanitizer: cherry-pick db7bca28638e from upstream Richard Sandiford
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).