[PATCH] D103936: [compiler-rt][hwasan] Define fuchsia implementations of required hwasan functions

Leonard Chan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 8 10:24:50 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
leonardchan marked 2 inline comments as done.
Closed by commit rGa11aea68a4b3: [compiler-rt][hwasan] Define fuchsia implementations of required hwasan… (authored by leonardchan).

Changed prior to commit:
  https://reviews.llvm.org/D103936?vs=352194&id=357269#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103936/new/

https://reviews.llvm.org/D103936

Files:
  compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp


Index: compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp
+++ compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp
@@ -156,8 +156,10 @@
 
 sanitizer_shadow_bounds_t ShadowBounds;
 
+void InitShadowBounds() { ShadowBounds = __sanitizer_shadow_bounds(); }
+
 uptr GetMaxUserVirtualAddress() {
-  ShadowBounds = __sanitizer_shadow_bounds();
+  InitShadowBounds();
   return ShadowBounds.memory_limit - 1;
 }
 
Index: compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
===================================================================
--- compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
+++ compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
@@ -30,6 +30,19 @@
 
 namespace __hwasan {
 
+bool InitShadow() {
+  __sanitizer::InitShadowBounds();
+  CHECK_NE(__sanitizer::ShadowBounds.shadow_limit, 0);
+
+  return true;
+}
+
+bool MemIsApp(uptr p) {
+  CHECK(GetTagFromPointer(p) == 0);
+  return __sanitizer::ShadowBounds.shadow_limit <= p &&
+         p <= (__sanitizer::ShadowBounds.memory_limit - 1);
+}
+
 // These are known parameters passed to the hwasan runtime on thread creation.
 struct Thread::InitState {
   uptr stack_bottom, stack_top;
@@ -130,6 +143,26 @@
   hwasanThreadList().ReleaseThread(thread);
 }
 
+// Not implemented because Fuchsia does not use signal handlers.
+void HwasanOnDeadlySignal(int signo, void *info, void *context) {}
+
+// Not implemented because Fuchsia does not use interceptors.
+void InitializeInterceptors() {}
+
+// Not implemented because this is only relevant for Android.
+void AndroidTestTlsSlot() {}
+
+// TSD was normally used on linux as a means of calling the hwasan thread exit
+// handler passed to pthread_key_create. This is not needed on Fuchsia because
+// we will be using __sanitizer_thread_exit_hook.
+void HwasanTSDInit() {}
+void HwasanTSDThreadInit() {}
+
+// On linux, this just would call `atexit(HwasanAtExit)`. The functions in
+// HwasanAtExit are unimplemented for Fuchsia and effectively no-ops, so this
+// function is unneeded.
+void InstallAtExitHandler() {}
+
 }  // namespace __hwasan
 
 extern "C" {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103936.357269.patch
Type: text/x-patch
Size: 2183 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210708/cf341f3d/attachment.bin>


More information about the cfe-commits mailing list