Indu Bhagat <indu.bha...@oracle.com> writes:
> In context of stack tagging, the AArch64 Memtag ABI Extension to ELF
> specifies the usage of two dynamic tags for the dynamic loader to do the
> necessary tasks:
>   - If DT_AARCH64_MEMTAG_MODE is present, the dynamic loader should (in
>     a platform-specific specific way) enable MTE for the process.
>   - If DT_AARCH64_MEMTAG_STACK is present, the dynamic loader should
>     enable tagging for the main stack and thread stacks.
>
> Make changes in the link spec so appropriate command line options can be
> passed to ld.
>
> The two (proposed) command line options added to ld are:
>   -z memtag-mode=<mode>
>   -z memtag-stack
>
> On the GCC side, the user can:
>   - Enable MTE stack tagging using -fsanitize=memtag
>   - Select the MTE mode by using -fsanitize-memtag-mode=mode.
>
> TBD:
>  - We need to check explicitly for stack tagging; sanitize(memtag) does
>    not appear to be enough.  Because -fsanitize=memtag will also be used
>    for MTE tagging of globals later.  On a related note, clang has two
>    explicit options: -fsanitize=memtag-stack and -fsanitize=memtag-globals.

Yeah, I think we should aim for option compatibility with Clang unless
there's a specific reason not to.  In a way, getting rid of the associated
--params is a feature, since --params are supposed to be developer options
that can go away at any time.

Thanks,
Richard

> gcc/ChangeLog:
>
>         * config/aarch64/aarch64-linux.h: Update LINUX_TARGET_LINK_SPEC
>       macro.
>         * gcc.cc (sanitize_spec_function): Add check for memtag.
>
> ---
> [New in RFC V2]
> ---
>  gcc/config/aarch64/aarch64-linux.h | 4 +++-
>  gcc/gcc.cc                         | 2 ++
>  2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/config/aarch64/aarch64-linux.h 
> b/gcc/config/aarch64/aarch64-linux.h
> index 116bb4e69f37..a5e5f8bb5ac5 100644
> --- a/gcc/config/aarch64/aarch64-linux.h
> +++ b/gcc/config/aarch64/aarch64-linux.h
> @@ -48,7 +48,9 @@
>     %{static-pie:-Bstatic -pie --no-dynamic-linker -z text} \
>     -X                                                \
>     %{mbig-endian:-EB} %{mlittle-endian:-EL}     \
> -   -maarch64linux%{mabi=ilp32:32}%{mbig-endian:b}"
> +   -maarch64linux%{mabi=ilp32:32}%{mbig-endian:b} \
> +   %{%:sanitize(memtag):%{!fsanitize-memtag-mode:-z memtag-stack -z 
> memtag-mode=sync}} \
> +   %{%:sanitize(memtag):%{fsanitize-memtag-mode=*:-z memtag-stack -z 
> memtag-mode=%}}"
>  
>  
>  #define LINK_SPEC LINUX_TARGET_LINK_SPEC AARCH64_ERRATA_LINK_SPEC
> diff --git a/gcc/gcc.cc b/gcc/gcc.cc
> index aac33e91a9a0..5beb793b075c 100644
> --- a/gcc/gcc.cc
> +++ b/gcc/gcc.cc
> @@ -10443,6 +10443,8 @@ sanitize_spec_function (int argc, const char **argv)
>      return (flag_sanitize & SANITIZE_KERNEL_ADDRESS) ? "" : NULL;
>    if (strcmp (argv[0], "kernel-hwaddress") == 0)
>      return (flag_sanitize & SANITIZE_KERNEL_HWADDRESS) ? "" : NULL;
> +  if (strcmp (argv[0], "memtag") == 0)
> +    return (flag_sanitize & SANITIZE_MEMTAG) ? "" : NULL;
>    if (strcmp (argv[0], "thread") == 0)
>      return (flag_sanitize & SANITIZE_THREAD) ? "" : NULL;
>    if (strcmp (argv[0], "undefined") == 0)

Reply via email to