@@ -119,6 +119,9 @@ static const uint64_t kNetBSDKasan_ShadowOffset64 = 0xdfff900000000000;
119
119
static const uint64_t kPS_ShadowOffset64 = 1ULL << 40 ;
120
120
static const uint64_t kWindowsShadowOffset32 = 3ULL << 28 ;
121
121
static const uint64_t kEmscriptenShadowOffset = 0 ;
122
+ static const uint64_t kAIXShadowOffset32 = 0x40000000 ;
123
+ // 64-BIT AIX is not yet ready.
124
+ static const uint64_t kAIXShadowOffset64 = 0x0a01000000000000ULL ;
122
125
123
126
// The shadow memory space is dynamically allocated.
124
127
static const uint64_t kWindowsShadowOffset64 = kDynamicShadowSentinel ;
@@ -128,6 +131,8 @@ static const size_t kMaxStackMallocSize = 1 << 16; // 64K
128
131
static const uintptr_t kCurrentStackFrameMagic = 0x41B58AB3 ;
129
132
static const uintptr_t kRetiredStackFrameMagic = 0x45E0360E ;
130
133
134
+ static const uint32_t kAIXHighBits = 6 ;
135
+
131
136
const char kAsanModuleCtorName [] = " asan.module_ctor" ;
132
137
const char kAsanModuleDtorName [] = " asan.module_dtor" ;
133
138
static const uint64_t kAsanCtorAndDtorPriority = 1 ;
@@ -468,6 +473,7 @@ namespace {
468
473
// / shadow = (mem >> Scale) + &__asan_shadow
469
474
struct ShadowMapping {
470
475
int Scale;
476
+ int HighBits;
471
477
uint64_t Offset;
472
478
bool OrShadowOffset;
473
479
bool InGlobal;
@@ -487,6 +493,7 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize,
487
493
bool IsLinux = TargetTriple.isOSLinux ();
488
494
bool IsPPC64 = TargetTriple.getArch () == Triple::ppc64 ||
489
495
TargetTriple.getArch () == Triple::ppc64le;
496
+ bool IsAIX = TargetTriple.isOSAIX ();
490
497
bool IsSystemZ = TargetTriple.getArch () == Triple::systemz;
491
498
bool IsX86_64 = TargetTriple.getArch () == Triple::x86_64;
492
499
bool IsMIPSN32ABI = TargetTriple.isABIN32 ();
@@ -526,14 +533,18 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize,
526
533
Mapping.Offset = kWindowsShadowOffset32 ;
527
534
else if (IsEmscripten)
528
535
Mapping.Offset = kEmscriptenShadowOffset ;
536
+ else if (IsAIX)
537
+ Mapping.Offset = kAIXShadowOffset32 ;
529
538
else
530
539
Mapping.Offset = kDefaultShadowOffset32 ;
531
540
} else { // LongSize == 64
532
541
// Fuchsia is always PIE, which means that the beginning of the address
533
542
// space is always available.
534
543
if (IsFuchsia)
535
544
Mapping.Offset = 0 ;
536
- else if (IsPPC64)
545
+ else if (IsAIX)
546
+ Mapping.Offset = kAIXShadowOffset64 ;
547
+ else if (IsPPC64 && !IsAIX)
537
548
Mapping.Offset = kPPC64_ShadowOffset64 ;
538
549
else if (IsSystemZ)
539
550
Mapping.Offset = kSystemZ_ShadowOffset64 ;
@@ -592,13 +603,16 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize,
592
603
// SystemZ, we could OR the constant in a single instruction, but it's more
593
604
// efficient to load it once and use indexed addressing.
594
605
Mapping.OrShadowOffset = !IsAArch64 && !IsPPC64 && !IsSystemZ && !IsPS &&
595
- !IsRISCV64 && !IsLoongArch64 &&
606
+ !IsRISCV64 && !IsLoongArch64 && !IsAIX &&
596
607
!(Mapping.Offset & (Mapping.Offset - 1 )) &&
597
608
Mapping.Offset != kDynamicShadowSentinel ;
598
609
bool IsAndroidWithIfuncSupport =
599
610
IsAndroid && !TargetTriple.isAndroidVersionLT (21 );
600
611
Mapping.InGlobal = ClWithIfunc && IsAndroidWithIfuncSupport && IsArmOrThumb;
601
612
613
+ if (IsAIX && LongSize == 64 )
614
+ Mapping.HighBits = kAIXHighBits ;
615
+
602
616
return Mapping;
603
617
}
604
618
@@ -1326,7 +1340,11 @@ static bool isUnsupportedAMDGPUAddrspace(Value *Addr) {
1326
1340
1327
1341
Value *AddressSanitizer::memToShadow (Value *Shadow, IRBuilder<> &IRB) {
1328
1342
// Shadow >> scale
1329
- Shadow = IRB.CreateLShr (Shadow, Mapping.Scale );
1343
+ if (TargetTriple.isOSAIX () && TargetTriple.getArch () == Triple::ppc64)
1344
+ Shadow = IRB.CreateLShr (IRB.CreateShl (Shadow, Mapping.HighBits ),
1345
+ Mapping.Scale + Mapping.HighBits );
1346
+ else
1347
+ Shadow = IRB.CreateLShr (Shadow, Mapping.Scale );
1330
1348
if (Mapping.Offset == 0 ) return Shadow;
1331
1349
// (Shadow >> scale) | offset
1332
1350
Value *ShadowBase;
0 commit comments