[PATCH] D119296: KCFI sanitizer

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 18 16:45:18 PDT 2022


MaskRay added a comment.

> OK, so we could just not make the symbols weak and end up failing at link time if there's a mismatch. That sounds reasonable to me.

For `STB_WEAK SHN_ABS` `__kcfi_typeid_*`, there is no duplicate definition error. Is this behavior intentional?
Note: I don't think we should change lld to recognize some symbol prefix and enforce more rigid diagnostics.
An error must be implemented with existing ELF features.



================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2273-2275
+    std::string Name = "__kcfi_typeid_" + F.getName().str();
+    if (!allowKCFIIdentifier(Name))
+      continue;
----------------
nickdesaulniers wrote:
> You could probably avoid re-checking `"__kcfi_typeid_"` repeatedly?
```
if (const llvm::MDNode *MD = F.getMetadata(llvm::LLVMContext::MD_kcfi_type))
  Type = ...
else
  continue;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119296



More information about the llvm-commits mailing list