[llvm] -fsanitize=function: fix .subsections_via_symbols (PR #87527)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 5 19:07:31 PDT 2024


================
@@ -927,6 +927,30 @@ void AsmPrinter::emitDebugValue(const MCExpr *Value, unsigned Size) const {
 
 void AsmPrinter::emitFunctionHeaderComment() {}
 
+void AsmPrinter::emitFunctionPrefix(
+    const SmallVector<const Constant *, 1> &Prefix) {
+  const Function &F = MF->getFunction();
+  if (!MAI->hasSubsectionsViaSymbols()) {
+    for (auto &C : Prefix) {
+      emitGlobalConstant(F.getParent()->getDataLayout(), C);
+    }
+    return;
+  }
+  // Preserving prefix data on platforms which use subsections-via-symbols
+  // is a bit tricky. Here we introduce a symbol for the prefix data
----------------
MaskRay wrote:

The comment about "prefix data" should be adjusted

https://github.com/llvm/llvm-project/pull/87527


More information about the llvm-commits mailing list