Skip to content

Commit

Permalink
[asan] Implemented getAddressSanitizerParams used by the ASan callbac…
Browse files Browse the repository at this point in the history
…k optimization code.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D108397
  • Loading branch information
kstoimenov committed Aug 20, 2021
1 parent a232a48 commit 05a8c0b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Expand Up @@ -87,6 +87,11 @@ bool forAllReachableExits(const DominatorTree &DT, const PostDominatorTree &PDT,
return true;
}

// Get AddressSanitizer parameters.
void getAddressSanitizerParams(const Triple &TargetTriple, int LongSize,
bool IsKasan, uint64_t *ShadowBase,
int *MappingScale, bool *OrShadowOffset);

} // namespace llvm

#endif
13 changes: 12 additions & 1 deletion llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Expand Up @@ -442,7 +442,7 @@ struct ShadowMapping {

} // end anonymous namespace

static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize,
static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize,
bool IsKasan) {
bool IsAndroid = TargetTriple.isAndroid();
bool IsIOS = TargetTriple.isiOS() || TargetTriple.isWatchOS();
Expand Down Expand Up @@ -559,6 +559,17 @@ static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize,
return Mapping;
}

namespace llvm {
void getAddressSanitizerParams(const Triple &TargetTriple, int LongSize,
bool IsKasan, uint64_t *ShadowBase,
int *MappingScale, bool *OrShadowOffset) {
auto Mapping = getShadowMapping(TargetTriple, LongSize, IsKasan);
*ShadowBase = Mapping.Offset;
*MappingScale = Mapping.Scale;
*OrShadowOffset = Mapping.OrShadowOffset;
}
} // namespace llvm

static uint64_t getRedzoneSizeForScale(int MappingScale) {
// Redzone used for stack and globals is at least 32 bytes.
// For scales 6 and 7, the redzone has to be 64 and 128 bytes respectively.
Expand Down

0 comments on commit 05a8c0b

Please sign in to comment.