public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Mips: Fix the ASAN shadow offset hook for the n32 ABI
@ 2022-06-06  9:28 Dimitrije Milosevic
  2022-06-07  8:17 ` Xi Ruoyao
  2022-07-30 13:22 ` Maciej W. Rozycki
  0 siblings, 2 replies; 5+ messages in thread
From: Dimitrije Milosevic @ 2022-06-06  9:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Djordje Todorovic

Fix the ASAN shadow offset hook for the n32 ABI.

gcc/ChangeLog:

        * config/mips/mips.cc (mips_asan_shadow_offset): Reformat
        to handle the N32 ABI.
        * config/mips/mips.h (SUBTARGET_SHADOW_OFFSET): Remove
        the macro, as it is not needed anymore.

---

 gcc/config/mips/mips.cc | 7 ++++++-
 gcc/config/mips/mips.h  | 7 -------
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
index 2dce4007678..91e651c458e 100644
--- a/gcc/config/mips/mips.cc
+++ b/gcc/config/mips/mips.cc
@@ -22745,7 +22745,12 @@ mips_constant_alignment (const_tree exp, HOST_WIDE_INT align)
 static unsigned HOST_WIDE_INT
 mips_asan_shadow_offset (void)
 {
-  return SUBTARGET_SHADOW_OFFSET;
+  if (mips_abi == ABI_N32)
+    return (HOST_WIDE_INT_1 << 29);
+  if (POINTER_SIZE == 64)
+    return (HOST_WIDE_INT_1 << 37);
+  else
+    return HOST_WIDE_INT_C (0x0aaa0000);
 }

 /* 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 858bbba3a36..0029864fdcd 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -3463,10 +3463,3 @@ 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

---


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Mips: Fix the ASAN shadow offset hook for the n32 ABI
  2022-06-06  9:28 [PATCH] Mips: Fix the ASAN shadow offset hook for the n32 ABI Dimitrije Milosevic
@ 2022-06-07  8:17 ` Xi Ruoyao
  2022-06-07 10:12   ` Dimitrije Milosevic
  2022-07-30 13:22 ` Maciej W. Rozycki
  1 sibling, 1 reply; 5+ messages in thread
From: Xi Ruoyao @ 2022-06-07  8:17 UTC (permalink / raw)
  To: Dimitrije Milosevic, gcc-patches; +Cc: Djordje Todorovic

On Mon, 2022-06-06 at 09:28 +0000, Dimitrije Milosevic wrote:
> Fix the ASAN shadow offset hook for the n32 ABI.
> 
> gcc/ChangeLog:
> 
>         * config/mips/mips.cc (mips_asan_shadow_offset): Reformat
>         to handle the N32 ABI.
>         * config/mips/mips.h (SUBTARGET_SHADOW_OFFSET): Remove
>         the macro, as it is not needed anymore.
> 
> ---
> 
>  gcc/config/mips/mips.cc | 7 ++++++-
>  gcc/config/mips/mips.h  | 7 -------
>  2 files changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
> index 2dce4007678..91e651c458e 100644
> --- a/gcc/config/mips/mips.cc
> +++ b/gcc/config/mips/mips.cc
> @@ -22745,7 +22745,12 @@ mips_constant_alignment (const_tree exp,
> HOST_WIDE_INT align)
>  static unsigned HOST_WIDE_INT
>  mips_asan_shadow_offset (void)
>  {
> -  return SUBTARGET_SHADOW_OFFSET;
> +  if (mips_abi == ABI_N32)
> +    return (HOST_WIDE_INT_1 << 29);
> +  if (POINTER_SIZE == 64)
> +    return (HOST_WIDE_INT_1 << 37);
> +  else
> +    return HOST_WIDE_INT_C (0x0aaa0000);
>  }
> 
>  /* 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 858bbba3a36..0029864fdcd 100644
> --- a/gcc/config/mips/mips.h
> +++ b/gcc/config/mips/mips.h
> @@ -3463,10 +3463,3 @@ 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
> 
> ---

I think this depends on https://reviews.llvm.org/D127096 (not committed
yet)?

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Mips: Fix the ASAN shadow offset hook for the n32 ABI
  2022-06-07  8:17 ` Xi Ruoyao
@ 2022-06-07 10:12   ` Dimitrije Milosevic
  0 siblings, 0 replies; 5+ messages in thread
From: Dimitrije Milosevic @ 2022-06-07 10:12 UTC (permalink / raw)
  To: Xi Ruoyao, gcc-patches; +Cc: Djordje Todorovic

Correct, it should be committed very soon.
________________________________
From: Xi Ruoyao <xry111@xry111.site>
Sent: Tuesday, June 7, 2022 10:17 AM
To: Dimitrije Milosevic <Dimitrije.Milosevic@Syrmia.com>; gcc-patches@gcc.gnu.org <gcc-patches@gcc.gnu.org>
Cc: Djordje Todorovic <Djordje.Todorovic@syrmia.com>
Subject: Re: [PATCH] Mips: Fix the ASAN shadow offset hook for the n32 ABI

On Mon, 2022-06-06 at 09:28 +0000, Dimitrije Milosevic wrote:
> Fix the ASAN shadow offset hook for the n32 ABI.
>
> gcc/ChangeLog:
>
>         * config/mips/mips.cc (mips_asan_shadow_offset): Reformat
>         to handle the N32 ABI.
>         * config/mips/mips.h (SUBTARGET_SHADOW_OFFSET): Remove
>         the macro, as it is not needed anymore.
>
> ---
>
>  gcc/config/mips/mips.cc | 7 ++++++-
>  gcc/config/mips/mips.h  | 7 -------
>  2 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
> index 2dce4007678..91e651c458e 100644
> --- a/gcc/config/mips/mips.cc
> +++ b/gcc/config/mips/mips.cc
> @@ -22745,7 +22745,12 @@ mips_constant_alignment (const_tree exp,
> HOST_WIDE_INT align)
>  static unsigned HOST_WIDE_INT
>  mips_asan_shadow_offset (void)
>  {
> -  return SUBTARGET_SHADOW_OFFSET;
> +  if (mips_abi == ABI_N32)
> +    return (HOST_WIDE_INT_1 << 29);
> +  if (POINTER_SIZE == 64)
> +    return (HOST_WIDE_INT_1 << 37);
> +  else
> +    return HOST_WIDE_INT_C (0x0aaa0000);
>  }
>
>  /* 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 858bbba3a36..0029864fdcd 100644
> --- a/gcc/config/mips/mips.h
> +++ b/gcc/config/mips/mips.h
> @@ -3463,10 +3463,3 @@ 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
>
> ---

I think this depends on https://reviews.llvm.org/D127096 (not committed
yet)?

--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Mips: Fix the ASAN shadow offset hook for the n32 ABI
  2022-06-06  9:28 [PATCH] Mips: Fix the ASAN shadow offset hook for the n32 ABI Dimitrije Milosevic
  2022-06-07  8:17 ` Xi Ruoyao
@ 2022-07-30 13:22 ` Maciej W. Rozycki
  2022-08-03  1:17   ` Xi Ruoyao
  1 sibling, 1 reply; 5+ messages in thread
From: Maciej W. Rozycki @ 2022-07-30 13:22 UTC (permalink / raw)
  To: Dimitrije Milosevic; +Cc: gcc-patches, Djordje Todorovic

On Mon, 6 Jun 2022, Dimitrije Milosevic wrote:

>         * config/mips/mips.cc (mips_asan_shadow_offset): Reformat
>         to handle the N32 ABI.

 That's not what the change does.

>         * config/mips/mips.h (SUBTARGET_SHADOW_OFFSET): Remove
>         the macro, as it is not needed anymore.

 Why is the macro not needed anymore?

 I can see the change has already been committed, but no proper review was 
done and I can hardly see how anyone can know why this change is correct.  
If someone looks at it say in 10 years' time they can only try to guess.

  Maciej

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Mips: Fix the ASAN shadow offset hook for the n32 ABI
  2022-07-30 13:22 ` Maciej W. Rozycki
@ 2022-08-03  1:17   ` Xi Ruoyao
  0 siblings, 0 replies; 5+ messages in thread
From: Xi Ruoyao @ 2022-08-03  1:17 UTC (permalink / raw)
  To: Maciej W. Rozycki, Dimitrije Milosevic; +Cc: Djordje Todorovic, gcc-patches

On Sat, 2022-07-30 at 14:22 +0100, Maciej W. Rozycki wrote:
> On Mon, 6 Jun 2022, Dimitrije Milosevic wrote:
> 
> >         * config/mips/mips.cc (mips_asan_shadow_offset): Reformat
> >         to handle the N32 ABI.
> 
>  That's not what the change does.
> 
> >         * config/mips/mips.h (SUBTARGET_SHADOW_OFFSET): Remove
> >         the macro, as it is not needed anymore.
> 
>  Why is the macro not needed anymore?

Because it's only used by mips_asan_shadow_offset and now we directly
code its content into mips_asan_shadow_offset.

SUBTARGET_SHADOW_OFFSET is only needed if a different subtarget (say,
mips64el-freebsd) needs a different shadow offset.  But for MIPS we
don't have any subtarget other than mips*-linux-gnu* supporting ASAN so
we can omit SUBTARGET_SHADOW_OFFSET and fold the content directly into
the asan_shadow_offset target hook.  RISCV port does the same.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-03  1:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-06  9:28 [PATCH] Mips: Fix the ASAN shadow offset hook for the n32 ABI Dimitrije Milosevic
2022-06-07  8:17 ` Xi Ruoyao
2022-06-07 10:12   ` Dimitrije Milosevic
2022-07-30 13:22 ` Maciej W. Rozycki
2022-08-03  1:17   ` Xi Ruoyao

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).