[PATCH] D81390: [KernelAddressSanitizer] Make globals constructors compatible with kernel [v2]

Alexander Potapenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 9 07:39:38 PDT 2020


glider added inline comments.


================
Comment at: clang/test/CodeGen/asan-globals.cpp:16
+int aliased_global;
+extern int __attribute__((alias("aliased_global"))) __global_alias;
+int __special_global;
----------------
Need a comment explaining this case a bit.


================
Comment at: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp:759
         // do globals-gc.
-        UseCtorComdat(UseGlobalsGC && ClWithComdat) {
-    this->Recover = ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover;
-    this->CompileKernel =
-        ClEnableKasan.getNumOccurrences() > 0 ? ClEnableKasan : CompileKernel;
-
+        UseCtorComdat(UseGlobalsGC && ClWithComdat && !this->CompileKernel) {
     C = &(M.getContext());
----------------
`UseGlobalsGC` assumes `!this->CompileKernel` already, doesn't it?


================
Comment at: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp:1796
+    const GlobalAlias &GA) const {
+  if (CompileKernel) {
+    // When compiling the kernel, globals that are aliased by symbols prefixed
----------------
Maybe it's better to call this function only if CompileKernel is true?
I don't think we need it except for the kernel.


================
Comment at: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp:1938
 // supported on recent versions of ld64.
-bool ModuleAddressSanitizer::ShouldUseMachOGlobalsSection() const {
+bool ModuleAddressSanitizer::shouldUseMachOGlobalsSection() const {
   if (!TargetTriple.isOSBinFormatMachO())
----------------
This change looks unrelated to the rest.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81390





More information about the cfe-commits mailing list