[PATCH] D23354: [asan] Support dynamic shadow address instrumentation

Anna Zaks via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 09:31:13 PDT 2016


zaks.anna added a comment.

When testing with this patch on the Mac, I ran into a problem using -asan-force-dynamic-shadow. Specifically, Mapping.OrShadowOffset was not inferred correctly because it relies on checking kDynamicShadowSentinel and not the ClForceDynamicShadow. How about using ClForceDynamicShadow when setting the Mapping.Offset and gating the maybeInsertDynamicShadowAtFunctionEntry solely on the value of the Mapping.Offset?

  @@ -434,13 +434,19 @@ static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize,
  ...
       else
         Mapping.Offset = kDefaultShadowOffset64;
     }
   
  +  if (ClForceDynamicShadow) {
  +    Mapping.Offset = kDynamicShadowSentinel;
  +  }
  +
     Mapping.Scale = kDefaultShadowScale;
     if (ClMappingScale.getNumOccurrences() > 0) {
       Mapping.Scale = ClMappingScale;
  @@ -1802,7 +1808,7 @@ bool AddressSanitizer::maybeInsertAsanInitAtFunctionEntry(Function &F) {
   
   void AddressSanitizer::maybeInsertDynamicShadowAtFunctionEntry(Function &F) {
     // Generate code only when dynamic addressing is needed.
  -  if (!ClForceDynamicShadow && Mapping.Offset != kDynamicShadowSentinel)
  +  if (Mapping.Offset != kDynamicShadowSentinel)
       return;
   
     IRBuilder<> IRB(&F.front().front());

If you'd like, I can commit this as a separate patch.


https://reviews.llvm.org/D23354





More information about the llvm-commits mailing list