[llvm] [llvm][docs] MemTagSanitizer is only supported on AArch64 Android (PR #120545)

David Spickett via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 19 02:05:39 PST 2024


https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/120545

```
$ ./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.

>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] [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
 ==============



More information about the llvm-commits mailing list