This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt][hwasan] Add GetShadowOffset function
ClosedPublic

Authored by leonardchan on Jun 14 2021, 6:29 PM.

Details

Summary

Similar to SHADOW_OFFSET on asan, we can use this for hwasan so platforms that use a constant value for the start of shadow memory can just use the constant rather than access a global.

Diff Detail

Event Timeline

leonardchan created this revision.Jun 14 2021, 6:29 PM
leonardchan requested review of this revision.Jun 14 2021, 6:29 PM
Herald added a subscriber: Restricted Project. · View Herald TranscriptJun 14 2021, 6:29 PM
vitalybuka added inline comments.Jun 14 2021, 9:35 PM
compiler-rt/lib/hwasan/hwasan_mapping.h
51

Maybe the following to minimize code which compiles only on limited set of platforms?

inline uptr GetShadowOffset() {
  return SANITIZER_FUCHSIA ? 0 : __hwasan_shadow_memory_dynamic_address;
}
56–57

clang-tidy: error: expected ';' after return statement [clang-diagnostic-error]

please fix

vitalybuka accepted this revision.Jun 14 2021, 9:37 PM
This revision is now accepted and ready to land.Jun 14 2021, 9:37 PM
leonardchan marked 2 inline comments as done.
leonardchan retitled this revision from [compiler-rt][hwasan] Add SHADOW_OFFSET macro to [compiler-rt][hwasan] Add GetShadowOffset function.
This revision was landed with ongoing or failed builds.Jun 15 2021, 10:48 AM
This revision was automatically updated to reflect the committed changes.
mcgrathr added inline comments.Jun 15 2021, 3:50 PM
compiler-rt/lib/hwasan/hwasan_mapping.h
54

I think you'll eventually need to make this an #if or if constexpr for it to be kosher that the symbol isn't defined at all, which is what we'd ideally like to have on Fuchsia.

vitalybuka added inline comments.Jun 15 2021, 7:24 PM
compiler-rt/lib/hwasan/hwasan_mapping.h
54

static inline?

mcgrathr added inline comments.Jun 16 2021, 1:07 AM
compiler-rt/lib/hwasan/hwasan_mapping.h
54

Plain inline has correct semantics here, and is consistent with the existing functions below.
static inside namespace scope in a header is a strange thing to do.

vitalybuka added inline comments.Jun 16 2021, 1:28 AM
compiler-rt/lib/hwasan/hwasan_mapping.h
54

that's exactly the point: inline and no exported symbol
you can find many of then in llvm headers.