[compiler-rt] c62fc06 - [asan] Implement address sanitizer on AIX: platform support (#139587)

via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 19 06:44:26 PST 2025


Author: Jake Egan
Date: 2025-11-19T09:44:22-05:00
New Revision: c62fc065b4c10370c1aa68cad6f5fa980b640136

URL: https://github.com/llvm/llvm-project/commit/c62fc065b4c10370c1aa68cad6f5fa980b640136
DIFF: https://github.com/llvm/llvm-project/commit/c62fc065b4c10370c1aa68cad6f5fa980b640136.diff

LOG: [asan] Implement address sanitizer on AIX: platform support (#139587)

Adds some general changes for supporting asan on AIX.

Issue: #138916

Added: 
    compiler-rt/lib/asan/asan_aix.cpp

Modified: 
    compiler-rt/lib/asan/CMakeLists.txt
    compiler-rt/lib/asan/asan_posix.cpp
    compiler-rt/lib/asan/scripts/asan_symbolize.py

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt
index 7d07ec765c005..232bb2574a778 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -1,6 +1,7 @@
 # Build for the AddressSanitizer runtime support library.
 
 set(ASAN_SOURCES
+  asan_aix.cpp
   asan_allocator.cpp
   asan_activation.cpp
   asan_debugging.cpp

diff  --git a/compiler-rt/lib/asan/asan_aix.cpp b/compiler-rt/lib/asan/asan_aix.cpp
new file mode 100644
index 0000000000000..58a79ea5e7479
--- /dev/null
+++ b/compiler-rt/lib/asan/asan_aix.cpp
@@ -0,0 +1,48 @@
+//===-- asan_aix.cpp ------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of AddressSanitizer, an address sanity checker.
+//
+// AIX-specific details.
+//===----------------------------------------------------------------------===//
+
+#include "sanitizer_common/sanitizer_platform.h"
+
+#if SANITIZER_AIX
+#  include "asan_mapping.h"
+#  include "sanitizer_common/sanitizer_internal_defs.h"
+
+namespace __asan {
+
+void TryReExecWithoutASLR() {
+  // Allowed to fail and do nothing.
+}
+
+void AsanCheckIncompatibleRT() {}
+
+void AsanCheckDynamicRTPrereqs() {}
+
+void InitializePlatformExceptionHandlers() {}
+
+void* AsanDoesNotSupportStaticLinkage() { return 0; }
+
+void InitializePlatformInterceptors() {}
+void AsanApplyToGlobals(globals_op_fptr op, const void* needle) {}
+
+uptr FindDynamicShadowStart() {
+  UNREACHABLE("AIX does not use dynamic shadow offset!");
+  return 0;
+}
+
+void FlushUnneededASanShadowMemory(uptr p, uptr size) {
+  ReleaseMemoryPagesToOS(MemToShadow(p), MemToShadow(p + size));
+}
+
+}  // namespace __asan
+
+#endif  // SANITIZER_AIX

diff  --git a/compiler-rt/lib/asan/asan_posix.cpp b/compiler-rt/lib/asan/asan_posix.cpp
index fb66c871ea8a5..598a55d89bdd2 100644
--- a/compiler-rt/lib/asan/asan_posix.cpp
+++ b/compiler-rt/lib/asan/asan_posix.cpp
@@ -180,7 +180,7 @@ static void AfterFork(bool fork_child) {
 
 void InstallAtForkHandler() {
 #  if SANITIZER_SOLARIS || SANITIZER_NETBSD || SANITIZER_APPLE || \
-      (SANITIZER_LINUX && SANITIZER_SPARC) || SANITIZER_HAIKU
+      (SANITIZER_LINUX && SANITIZER_SPARC) || SANITIZER_HAIKU || SANITIZER_AIX
   // While other Linux targets use clone in internal_fork which doesn't
   // trigger pthread_atfork handlers, Linux/sparc64 uses __fork, causing a
   // hang.

diff  --git a/compiler-rt/lib/asan/scripts/asan_symbolize.py b/compiler-rt/lib/asan/scripts/asan_symbolize.py
index 091e9bcc9a796..dffe4dd6fc032 100755
--- a/compiler-rt/lib/asan/scripts/asan_symbolize.py
+++ b/compiler-rt/lib/asan/scripts/asan_symbolize.py
@@ -60,6 +60,7 @@ def is_valid_arch(s):
         "armv7k",
         "arm64",
         "arm64e",
+        "powerpc",
         "powerpc64",
         "powerpc64le",
         "s390x",
@@ -450,7 +451,14 @@ def __init__(self, plugin_proxy=None, dsym_hint_producer=None):
             # E.g. in Chrome several binaries may share a single .dSYM.
             self.dsym_hint_producer = dsym_hint_producer
             self.system = os.uname()[0]
-            if self.system not in ["Linux", "Darwin", "FreeBSD", "NetBSD", "SunOS"]:
+            if self.system not in [
+                "Linux",
+                "Darwin",
+                "FreeBSD",
+                "NetBSD",
+                "SunOS",
+                "AIX",
+            ]:
                 raise Exception("Unknown system")
             self.llvm_symbolizers = {}
             self.last_llvm_symbolizer = None


        


More information about the llvm-commits mailing list