49 lines
2.1 KiB
Plaintext
49 lines
2.1 KiB
Plaintext
$OpenBSD: patch-lib_CodeGen_AsmPrinter_AsmPrinter_cpp,v 1.5 2018/04/07 14:55:42 ajacoutot Exp $
|
|
|
|
Use int3 trap padding between functions instead of trapsleds with a leading jump.
|
|
|
|
Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp
|
|
--- lib/CodeGen/AsmPrinter/AsmPrinter.cpp.orig
|
|
+++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp
|
|
@@ -637,7 +637,7 @@ void AsmPrinter::EmitFunctionHeader() {
|
|
|
|
EmitLinkage(&F, CurrentFnSym);
|
|
if (MAI->hasFunctionAlignment())
|
|
- EmitAlignment(MF->getAlignment(), &F);
|
|
+ EmitTrapAlignment(MF->getAlignment(), &F);
|
|
|
|
if (MAI->hasDotTypeDotSizeDirective())
|
|
OutStreamer->EmitSymbolAttribute(CurrentFnSym, MCSA_ELF_TypeFunction);
|
|
@@ -1908,6 +1908,31 @@ void AsmPrinter::EmitAlignment(unsigned NumBits, const
|
|
OutStreamer->EmitCodeAlignment(1u << NumBits);
|
|
else
|
|
OutStreamer->EmitValueToAlignment(1u << NumBits);
|
|
+}
|
|
+
|
|
+//===----------------------------------------------------------------------===//
|
|
+/// EmitTrapAlignment - Emit an alignment directive to the specified power of
|
|
+/// two boundary, but call EmitTrapToAlignment to fill with Trap instructions
|
|
+/// if the Target implements EmitTrapToAlignment.
|
|
+void AsmPrinter::EmitTrapAlignment(unsigned NumBits, const GlobalObject *GV) const {
|
|
+ if (GV)
|
|
+ NumBits = getGVAlignmentLog2(GV, GV->getParent()->getDataLayout(), NumBits);
|
|
+
|
|
+ if (NumBits == 0) return; // 1-byte aligned: no need to emit alignment.
|
|
+
|
|
+ assert(NumBits <
|
|
+ static_cast<unsigned>(std::numeric_limits<unsigned>::digits) &&
|
|
+ "undefined behavior");
|
|
+ EmitTrapToAlignment(NumBits);
|
|
+}
|
|
+
|
|
+//===----------------------------------------------------------------------===//
|
|
+/// EmitTrapToAlignment - Emit an alignment directive to the specified power
|
|
+/// of two boundary. This default implementation calls EmitCodeAlignment on
|
|
+/// the OutStreamer, but can be overridden by Target implementations.
|
|
+void AsmPrinter::EmitTrapToAlignment(unsigned NumBits) const {
|
|
+ if (NumBits == 0) return;
|
|
+ OutStreamer->EmitCodeAlignment(1u << NumBits);
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|