Skip to content

Commit c62fc06

Browse files
authored
[asan] Implement address sanitizer on AIX: platform support (#139587)
Adds some general changes for supporting asan on AIX. Issue: #138916
1 parent 1723a51 commit c62fc06

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed

compiler-rt/lib/asan/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Build for the AddressSanitizer runtime support library.
22

33
set(ASAN_SOURCES
4+
asan_aix.cpp
45
asan_allocator.cpp
56
asan_activation.cpp
67
asan_debugging.cpp

compiler-rt/lib/asan/asan_aix.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//===-- asan_aix.cpp ------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file is a part of AddressSanitizer, an address sanity checker.
10+
//
11+
// AIX-specific details.
12+
//===----------------------------------------------------------------------===//
13+
14+
#include "sanitizer_common/sanitizer_platform.h"
15+
16+
#if SANITIZER_AIX
17+
# include "asan_mapping.h"
18+
# include "sanitizer_common/sanitizer_internal_defs.h"
19+
20+
namespace __asan {
21+
22+
void TryReExecWithoutASLR() {
23+
// Allowed to fail and do nothing.
24+
}
25+
26+
void AsanCheckIncompatibleRT() {}
27+
28+
void AsanCheckDynamicRTPrereqs() {}
29+
30+
void InitializePlatformExceptionHandlers() {}
31+
32+
void* AsanDoesNotSupportStaticLinkage() { return 0; }
33+
34+
void InitializePlatformInterceptors() {}
35+
void AsanApplyToGlobals(globals_op_fptr op, const void* needle) {}
36+
37+
uptr FindDynamicShadowStart() {
38+
UNREACHABLE("AIX does not use dynamic shadow offset!");
39+
return 0;
40+
}
41+
42+
void FlushUnneededASanShadowMemory(uptr p, uptr size) {
43+
ReleaseMemoryPagesToOS(MemToShadow(p), MemToShadow(p + size));
44+
}
45+
46+
} // namespace __asan
47+
48+
#endif // SANITIZER_AIX

compiler-rt/lib/asan/asan_posix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static void AfterFork(bool fork_child) {
180180

181181
void InstallAtForkHandler() {
182182
# if SANITIZER_SOLARIS || SANITIZER_NETBSD || SANITIZER_APPLE || \
183-
(SANITIZER_LINUX && SANITIZER_SPARC) || SANITIZER_HAIKU
183+
(SANITIZER_LINUX && SANITIZER_SPARC) || SANITIZER_HAIKU || SANITIZER_AIX
184184
// While other Linux targets use clone in internal_fork which doesn't
185185
// trigger pthread_atfork handlers, Linux/sparc64 uses __fork, causing a
186186
// hang.

compiler-rt/lib/asan/scripts/asan_symbolize.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def is_valid_arch(s):
6060
"armv7k",
6161
"arm64",
6262
"arm64e",
63+
"powerpc",
6364
"powerpc64",
6465
"powerpc64le",
6566
"s390x",
@@ -450,7 +451,14 @@ def __init__(self, plugin_proxy=None, dsym_hint_producer=None):
450451
# E.g. in Chrome several binaries may share a single .dSYM.
451452
self.dsym_hint_producer = dsym_hint_producer
452453
self.system = os.uname()[0]
453-
if self.system not in ["Linux", "Darwin", "FreeBSD", "NetBSD", "SunOS"]:
454+
if self.system not in [
455+
"Linux",
456+
"Darwin",
457+
"FreeBSD",
458+
"NetBSD",
459+
"SunOS",
460+
"AIX",
461+
]:
454462
raise Exception("Unknown system")
455463
self.llvm_symbolizers = {}
456464
self.last_llvm_symbolizer = None

0 commit comments

Comments
 (0)