[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
+ // and use the .alt_entry attribute to mark the function's real entry point
+ // as an alternative entry point to the prefix-data symbol.
+ MCSymbol *PrefixSym = OutContext.createLinkerPrivateTempSymbol();
+ OutStreamer->emitLabel(PrefixSym);
+
+ for (auto &C : Prefix) {
+ emitGlobalConstant(F.getParent()->getDataLayout(), C);
----------------
MaskRay wrote:
omit braces https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
https://github.com/llvm/llvm-project/pull/87527
More information about the llvm-commits
mailing list