[llvm] [llvm][docs] MemTagSanitizer is only supported on AArch64 Android (PR #120545)
David Spickett via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 20 02:23:05 PST 2024
https://github.com/DavidSpickett updated https://github.com/llvm/llvm-project/pull/120545
>From e5e1360234ab646c4337f44a7d80b27b51ce4ff4 Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at linaro.org>
Date: Thu, 19 Dec 2024 10:02:34 +0000
Subject: [PATCH 1/3] [llvm][docs] MemTagSanitizer is only supported on AArch64
Android
```
$ ./bin/clang /tmp/test.c -o /tmp/test.o -target aarch64-linux -march=armv8+memtag -fsanitize=memtag-stack
clang: error: unsupported option '-fsanitize=memtag*' for target 'aarch64-unknown-linux'
```
But this works:
```
$ ./bin/clang /tmp/test.c -o /tmp/test.o -target aarch64-linux-android -march=armv8+memtag -fsanitize=memtag-stack
```
Due to this check in Clang:
https://github.com/llvm/llvm-project/blob/2210da3b823ccf21fc634c858827c9f12c864b51/clang/lib/Driver/ToolChains/CommonArgs.cpp#L1651
Likely because the required notes and dynamic loader support only
exist for Android.
You can get around this, sort of, by not linking the file. However
this means you have to provide your own way of loading it, so it
doesn't change the statement that this feature is Android only.
---
llvm/docs/MemTagSanitizer.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/docs/MemTagSanitizer.rst b/llvm/docs/MemTagSanitizer.rst
index 62efbfb041cbd0..44d261bec028f9 100644
--- a/llvm/docs/MemTagSanitizer.rst
+++ b/llvm/docs/MemTagSanitizer.rst
@@ -29,9 +29,9 @@ Usage
=====
Compile and link your program with ``-fsanitize=memtag`` flag. This
-will only work when targeting AArch64 with MemTag extension. One
+will only work when targeting AArch64 Android with MemTag extension. One
possible way to achieve that is to add ``-target
-aarch64-linux -march=armv8+memtag`` to compilation flags.
+aarch64-linux-android -march=armv8+memtag`` to compilation flags.
Implementation
==============
>From 1c98a05dcb20f1d6e147e31d6416e1f57d23363c Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at linaro.org>
Date: Thu, 19 Dec 2024 13:46:46 +0000
Subject: [PATCH 2/3] suggest -xclang, clean up grammar
---
llvm/docs/MemTagSanitizer.rst | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/llvm/docs/MemTagSanitizer.rst b/llvm/docs/MemTagSanitizer.rst
index 44d261bec028f9..9633f3195c9d4f 100644
--- a/llvm/docs/MemTagSanitizer.rst
+++ b/llvm/docs/MemTagSanitizer.rst
@@ -28,10 +28,15 @@ memory bugs.
Usage
=====
-Compile and link your program with ``-fsanitize=memtag`` flag. This
-will only work when targeting AArch64 Android with MemTag extension. One
-possible way to achieve that is to add ``-target
-aarch64-linux-android -march=armv8+memtag`` to compilation flags.
+Compile and link your program with the ``-fsanitize=memtag`` flag. This
+will only work when targeting AArch64 Android with the memory tagging extension.
+One possible way to achieve that is to add ``-target
+aarch64-linux-android -march=armv8+memtag`` to your compilation flags.
+
+Note that doing this will override existing flags of the same type. Assuming that
+you are already targeting AArch64 Android, an alternative is to add
+``-Xclang -target-feature -Xclang +mte`` to your compilation flags. This
+adds the memory tagging feature, without changing anything else.
Implementation
==============
>From 8938f738ed474eadbc17704b2967eaa8d61912df Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at linaro.org>
Date: Fri, 20 Dec 2024 10:22:47 +0000
Subject: [PATCH 3/3] --target=
---
llvm/docs/MemTagSanitizer.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/docs/MemTagSanitizer.rst b/llvm/docs/MemTagSanitizer.rst
index 9633f3195c9d4f..8a0fffc0d38220 100644
--- a/llvm/docs/MemTagSanitizer.rst
+++ b/llvm/docs/MemTagSanitizer.rst
@@ -30,8 +30,8 @@ Usage
Compile and link your program with the ``-fsanitize=memtag`` flag. This
will only work when targeting AArch64 Android with the memory tagging extension.
-One possible way to achieve that is to add ``-target
-aarch64-linux-android -march=armv8+memtag`` to your compilation flags.
+One possible way to achieve that is to add ``--target=aarch64-linux-android -march=armv8+memtag``
+to your compilation flags.
Note that doing this will override existing flags of the same type. Assuming that
you are already targeting AArch64 Android, an alternative is to add
More information about the llvm-commits
mailing list