Skip to content

Commit 287b24e

Browse files
authored
[asan] Implement address sanitizer on AIX: address descriptions (#138891)
Adapt address description logic for AIX. Issue: #138916
1 parent ea1e181 commit 287b24e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

compiler-rt/lib/asan/asan_descriptions.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ bool GetStackAddressInformation(uptr addr, uptr access_size,
211211
descr->frame_pc = access.frame_pc;
212212
descr->frame_descr = access.frame_descr;
213213

214-
#if SANITIZER_PPC64V1
215-
// On PowerPC64 ELFv1, the address of a function actually points to a
216-
// three-doubleword data structure with the first field containing
217-
// the address of the function's code.
214+
#if SANITIZER_PPC64V1 || SANITIZER_AIX
215+
// On PowerPC64 ELFv1 or AIX, the address of a function actually points to a
216+
// three-doubleword (or three-word for 32-bit AIX) data structure with
217+
// the first field containing the address of the function's code.
218218
descr->frame_pc = *reinterpret_cast<uptr *>(descr->frame_pc);
219219
#endif
220220
descr->frame_pc += 16;
@@ -444,6 +444,16 @@ AddressDescription::AddressDescription(uptr addr, uptr access_size,
444444
data.kind = kAddressKindShadow;
445445
return;
446446
}
447+
448+
// Check global first. On AIX, some global data defined in shared libraries
449+
// are put to the STACK region for unknown reasons. Check global first can
450+
// workaround this issue.
451+
// TODO: Look into whether there's a different solution to this problem.
452+
if (GetGlobalAddressInformation(addr, access_size, &data.global)) {
453+
data.kind = kAddressKindGlobal;
454+
return;
455+
}
456+
447457
if (GetHeapAddressInformation(addr, access_size, &data.heap)) {
448458
data.kind = kAddressKindHeap;
449459
return;
@@ -461,10 +471,6 @@ AddressDescription::AddressDescription(uptr addr, uptr access_size,
461471
return;
462472
}
463473

464-
if (GetGlobalAddressInformation(addr, access_size, &data.global)) {
465-
data.kind = kAddressKindGlobal;
466-
return;
467-
}
468474
data.kind = kAddressKindWild;
469475
data.wild.addr = addr;
470476
data.wild.access_size = access_size;

0 commit comments

Comments
 (0)