[compiler-rt] [asan] Implement address sanitizer on AIX: address descriptions (PR #138891)

Jake Egan via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 19 07:53:08 PDT 2025


https://github.com/jakeegan updated https://github.com/llvm/llvm-project/pull/138891

>From a3eda8d9b8a944f28f1ea290b80a3c7d74994060 Mon Sep 17 00:00:00 2001
From: Jake Egan <jake.egan at ibm.com>
Date: Wed, 7 May 2025 11:17:40 -0400
Subject: [PATCH 1/3] addressing

---
 compiler-rt/lib/asan/asan_descriptions.cpp | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/compiler-rt/lib/asan/asan_descriptions.cpp b/compiler-rt/lib/asan/asan_descriptions.cpp
index c9f3e4d682d95..b8d077fdaabcb 100644
--- a/compiler-rt/lib/asan/asan_descriptions.cpp
+++ b/compiler-rt/lib/asan/asan_descriptions.cpp
@@ -211,10 +211,10 @@ bool GetStackAddressInformation(uptr addr, uptr access_size,
   descr->frame_pc = access.frame_pc;
   descr->frame_descr = access.frame_descr;
 
-#if SANITIZER_PPC64V1
-  // On PowerPC64 ELFv1, the address of a function actually points to a
-  // three-doubleword data structure with the first field containing
-  // the address of the function's code.
+#if SANITIZER_PPC64V1 || SANITIZER_AIX
+  // On PowerPC64 ELFv1 or AIX, the address of a function actually points to a
+  // three-doubleword (or three-word for 32-bit AIX) data structure with 
+  // the first field containing the address of the function's code.
   descr->frame_pc = *reinterpret_cast<uptr *>(descr->frame_pc);
 #endif
   descr->frame_pc += 16;
@@ -444,6 +444,15 @@ AddressDescription::AddressDescription(uptr addr, uptr access_size,
     data.kind = kAddressKindShadow;
     return;
   }
+
+  // Check global first. On AIX, some global data defined in shared libraries
+  // are put to the STACK region for unknown reasons. Check global first can
+  // workaround this issue.
+  if (GetGlobalAddressInformation(addr, access_size, &data.global)) {
+    data.kind = kAddressKindGlobal;
+    return;
+  }
+
   if (GetHeapAddressInformation(addr, access_size, &data.heap)) {
     data.kind = kAddressKindHeap;
     return;
@@ -461,10 +470,6 @@ AddressDescription::AddressDescription(uptr addr, uptr access_size,
     return;
   }
 
-  if (GetGlobalAddressInformation(addr, access_size, &data.global)) {
-    data.kind = kAddressKindGlobal;
-    return;
-  }
   data.kind = kAddressKindWild;
   data.wild.addr = addr;
   data.wild.access_size = access_size;

>From 1a80a4284ac36cd466f66599502bc8ac4563f068 Mon Sep 17 00:00:00 2001
From: Jake Egan <jake.egan at ibm.com>
Date: Wed, 7 May 2025 11:21:26 -0400
Subject: [PATCH 2/3] Fix formatting

---
 compiler-rt/lib/asan/asan_descriptions.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/lib/asan/asan_descriptions.cpp b/compiler-rt/lib/asan/asan_descriptions.cpp
index b8d077fdaabcb..1cbf0e6b193f6 100644
--- a/compiler-rt/lib/asan/asan_descriptions.cpp
+++ b/compiler-rt/lib/asan/asan_descriptions.cpp
@@ -213,7 +213,7 @@ bool GetStackAddressInformation(uptr addr, uptr access_size,
 
 #if SANITIZER_PPC64V1 || SANITIZER_AIX
   // On PowerPC64 ELFv1 or AIX, the address of a function actually points to a
-  // three-doubleword (or three-word for 32-bit AIX) data structure with 
+  // three-doubleword (or three-word for 32-bit AIX) data structure with
   // the first field containing the address of the function's code.
   descr->frame_pc = *reinterpret_cast<uptr *>(descr->frame_pc);
 #endif

>From 6f7655e54c555fba33077f8c00ff210586a74b4c Mon Sep 17 00:00:00 2001
From: Jake Egan <jake.egan at ibm.com>
Date: Thu, 19 Jun 2025 10:52:52 -0400
Subject: [PATCH 3/3] Add TODO

---
 compiler-rt/lib/asan/asan_descriptions.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/compiler-rt/lib/asan/asan_descriptions.cpp b/compiler-rt/lib/asan/asan_descriptions.cpp
index 1cbf0e6b193f6..0c30959b23e28 100644
--- a/compiler-rt/lib/asan/asan_descriptions.cpp
+++ b/compiler-rt/lib/asan/asan_descriptions.cpp
@@ -448,6 +448,7 @@ AddressDescription::AddressDescription(uptr addr, uptr access_size,
   // Check global first. On AIX, some global data defined in shared libraries
   // are put to the STACK region for unknown reasons. Check global first can
   // workaround this issue.
+  // TODO: Look into whether there's a different solution to this problem.
   if (GetGlobalAddressInformation(addr, access_size, &data.global)) {
     data.kind = kAddressKindGlobal;
     return;



More information about the llvm-commits mailing list