[PATCH] D118171: [HWASan] Add __hwasan_init to .preinit_array.

Peter Collingbourne via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 2 13:45:15 PST 2022


pcc added a comment.

What guarantee do we have that the `__hwasan_init` .preinit_array entry will be placed before the user's .preinit_array entries?



================
Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:842
+      if (!Args.hasArg(options::OPT_shared))
+        SharedRuntimes.push_back("hwasan-preinit");
     }
----------------
Shouldn't it be added to `HelperStaticRuntimes`? Otherwise I'm not sure how this would work because the library would need to be enclosed in `--whole-archive` in order to be included in the link.


================
Comment at: compiler-rt/lib/hwasan/hwasan_preinit.cpp:22
+__attribute__((section(".preinit_array"), used))
+void (*__local_hwasan_preinit)(void) = __hwasan_init;
+#endif
----------------
Can it be static?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118171



More information about the cfe-commits mailing list