Update clang-tools-extra to 13.0.0
As usual patches from devel/llvm (thanks jca@ for the hard work)
This commit is contained in:
parent
0536ce405c
commit
3d817fffc8
|
@ -1,4 +1,4 @@
|
|||
# $OpenBSD: Makefile,v 1.21 2021/12/05 06:53:59 rsadowski Exp $
|
||||
# $OpenBSD: Makefile,v 1.22 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
# XXX
|
||||
# This port is more or less a copy from devel/llvm and it tries to
|
||||
|
@ -12,10 +12,9 @@ ONLY_FOR_ARCHS = ${LLVM_ARCHS}
|
|||
|
||||
COMMENT= Clang extra tools
|
||||
|
||||
LLVM_V = 11.1.0
|
||||
LLVM_V = 13.0.0
|
||||
DISTNAME = llvm-${LLVM_V}.src
|
||||
PKGNAME= clang-tools-extra-${LLVM_V}
|
||||
REVISION= 2
|
||||
|
||||
CATEGORIES = devel
|
||||
|
||||
|
@ -48,7 +47,6 @@ CONFIGURE_STYLE = cmake
|
|||
CONFIGURE_ARGS = -DCMAKE_DISABLE_FIND_PACKAGE_Backtrace=ON \
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=ON \
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Z3=ON \
|
||||
-DEPYDOC_EXECUTABLE=EPYDOC_EXECUTABLE-NOTFOUND \
|
||||
-DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND \
|
||||
-DLLVM_BUILD_LLVM_DYLIB=OFF \
|
||||
-DLLVM_ENABLE_FFI=OFF \
|
||||
|
@ -75,6 +73,11 @@ GCC_CONFIG = ${MACHINE_ARCH}-unknown-openbsd${OSREV}
|
|||
CLANG_INCLUDE_PATH = lib/clang/${LLVM_V}/include
|
||||
SUBST_VARS += CLANG_INCLUDE_PATH LLVM_V GCC_VER GCC_CONFIG
|
||||
|
||||
# hack to disable the use of -Bsymbolic-functions
|
||||
# Keep in sync with devel/llvm
|
||||
OPENBSD_LD_IS_LLD = FALSE
|
||||
SUBST_VARS += OPENBSD_LD_IS_LLD
|
||||
|
||||
ALL_TARGET = tools/clang/tools/extra/all
|
||||
FAKE_TARGET = tools/clang/tools/extra/install
|
||||
|
||||
|
@ -84,6 +87,9 @@ post-extract:
|
|||
|
||||
pre-configure:
|
||||
@${SUBST_CMD} ${WRKSRC}/tools/clang/lib/Driver/ToolChains/OpenBSD.cpp
|
||||
@${SUBST_CMD} ${WRKSRC}/cmake/modules/LLVMProcessSources.cmake
|
||||
@${SUBST_CMD} ${WRKSRC}/tools/clang/tools/clang-shlib/CMakeLists.txt
|
||||
@${SUBST_CMD} ${WRKSRC}/tools/llvm-shlib/CMakeLists.txt
|
||||
-@ln -s ${MODPY_BIN} ${WRKDIR}/bin/python
|
||||
|
||||
post-install:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
SHA256 (clang-11.1.0.src.tar.xz) = CoKI8GXR9Xy22W2k0pZcvqMu3FcqqXLkZulU0XFIVYs=
|
||||
SHA256 (clang-tools-extra-11.1.0.src.tar.xz) = dnB8JJ3nqc3jRWuWDJo27Zu96ONkLAHw72GkPWHgwaI=
|
||||
SHA256 (llvm-11.1.0.src.tar.xz) = zoUI4xigGmPU6LMJCrLe08WYpQJYzEniYluRINTAPqU=
|
||||
SIZE (clang-11.1.0.src.tar.xz) = 14850272
|
||||
SIZE (clang-tools-extra-11.1.0.src.tar.xz) = 1498848
|
||||
SIZE (llvm-11.1.0.src.tar.xz) = 38915280
|
||||
SHA256 (clang-13.0.0.src.tar.xz) = XWEcuwbPtmJr5G6y8j0AOyuA9AGCiY2qVLHE6LW54X4=
|
||||
SHA256 (clang-tools-extra-13.0.0.src.tar.xz) = QotgYKKLIq3wzfXYJ6u8K6gYCfRmHt49ArHT/tqj6tU=
|
||||
SHA256 (llvm-13.0.0.src.tar.xz) = QI0RcIZD6oJvUZ/3l2H838EtZBolECKe7EWecvgWMCA=
|
||||
SIZE (clang-13.0.0.src.tar.xz) = 17846828
|
||||
SIZE (clang-tools-extra-13.0.0.src.tar.xz) = 2739604
|
||||
SIZE (llvm-13.0.0.src.tar.xz) = 45471992
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-cmake_modules_LLVMProcessSources_cmake,v 1.3 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-cmake_modules_LLVMProcessSources_cmake,v 1.4 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
Avoid adding a dep on all headers in ${LOCALBASE}/include, not
|
||||
compatible with dpb(1) junking.
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
$OpenBSD: patch-include_llvm_BinaryFormat_Dwarf_def,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
|
||||
implement -msave-args in clang/llvm, like the sun did for gcc
|
||||
|
||||
Index: include/llvm/BinaryFormat/Dwarf.def
|
||||
--- include/llvm/BinaryFormat/Dwarf.def.orig
|
||||
+++ include/llvm/BinaryFormat/Dwarf.def
|
||||
@@ -393,6 +393,8 @@ HANDLE_DW_AT(0x2133, GNU_addr_base, 0, GNU)
|
||||
HANDLE_DW_AT(0x2134, GNU_pubnames, 0, GNU)
|
||||
HANDLE_DW_AT(0x2135, GNU_pubtypes, 0, GNU)
|
||||
HANDLE_DW_AT(0x2136, GNU_discriminator, 0, GNU)
|
||||
+// Sun Extension
|
||||
+HANDLE_DW_AT(0x2224, SUN_amd64_parmdump, 0, GNU)
|
||||
// Borland extensions.
|
||||
HANDLE_DW_AT(0x3b11, BORLAND_property_read, 0, BORLAND)
|
||||
HANDLE_DW_AT(0x3b12, BORLAND_property_write, 0, BORLAND)
|
|
@ -1,11 +1,11 @@
|
|||
$OpenBSD: patch-include_llvm_CodeGen_AsmPrinter_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-include_llvm_CodeGen_AsmPrinter_h,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
Use int3 trap padding between functions instead of trapsleds with a leading jump.
|
||||
|
||||
Index: include/llvm/CodeGen/AsmPrinter.h
|
||||
--- include/llvm/CodeGen/AsmPrinter.h.orig
|
||||
+++ include/llvm/CodeGen/AsmPrinter.h
|
||||
@@ -375,6 +375,11 @@ class AsmPrinter : public MachineFunctionPass { (publi
|
||||
@@ -434,6 +434,11 @@ class AsmPrinter : public MachineFunctionPass { (publi
|
||||
/// correctness.
|
||||
void emitAlignment(Align Alignment, const GlobalObject *GV = nullptr) const;
|
||||
|
||||
|
@ -17,7 +17,7 @@ Index: include/llvm/CodeGen/AsmPrinter.h
|
|||
/// Lower the specified LLVM Constant to an MCExpr.
|
||||
virtual const MCExpr *lowerConstant(const Constant *CV);
|
||||
|
||||
@@ -435,6 +440,11 @@ class AsmPrinter : public MachineFunctionPass { (publi
|
||||
@@ -499,6 +504,11 @@ class AsmPrinter : public MachineFunctionPass { (publi
|
||||
virtual void emitInstruction(const MachineInstr *) {
|
||||
llvm_unreachable("EmitInstruction not implemented");
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-include_llvm_CodeGen_MachineFrameInfo_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-include_llvm_CodeGen_MachineFrameInfo_h,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
- Add RETGUARD to clang for amd64. This security mechanism uses per-function
|
||||
random cookies to protect access to function return instructions, with the
|
||||
|
@ -22,7 +22,7 @@ $OpenBSD: patch-include_llvm_CodeGen_MachineFrameInfo_h,v 1.4 2021/05/18 03:35:0
|
|||
Index: include/llvm/CodeGen/MachineFrameInfo.h
|
||||
--- include/llvm/CodeGen/MachineFrameInfo.h.orig
|
||||
+++ include/llvm/CodeGen/MachineFrameInfo.h
|
||||
@@ -273,6 +273,15 @@ class MachineFrameInfo { (private)
|
||||
@@ -274,6 +274,15 @@ class MachineFrameInfo { (private)
|
||||
/// The frame index for the stack protector.
|
||||
int StackProtectorIdx = -1;
|
||||
|
||||
|
@ -38,7 +38,7 @@ Index: include/llvm/CodeGen/MachineFrameInfo.h
|
|||
/// The frame index for the function context. Used for SjLj exceptions.
|
||||
int FunctionContextIdx = -1;
|
||||
|
||||
@@ -353,6 +362,17 @@ class MachineFrameInfo { (private)
|
||||
@@ -354,6 +363,17 @@ class MachineFrameInfo { (private)
|
||||
int getStackProtectorIndex() const { return StackProtectorIdx; }
|
||||
void setStackProtectorIndex(int I) { StackProtectorIdx = I; }
|
||||
bool hasStackProtectorIndex() const { return StackProtectorIdx != -1; }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-include_llvm_CodeGen_Passes_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-include_llvm_CodeGen_Passes_h,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
Add RETGUARD to clang for amd64. This security mechanism uses per-function
|
||||
random cookies to protect access to function return instructions, with the
|
||||
|
@ -21,7 +21,7 @@ remove these gadgets will continue through other mechanisms.
|
|||
Index: include/llvm/CodeGen/Passes.h
|
||||
--- include/llvm/CodeGen/Passes.h.orig
|
||||
+++ include/llvm/CodeGen/Passes.h
|
||||
@@ -334,6 +334,9 @@ namespace llvm {
|
||||
@@ -353,6 +353,9 @@ namespace llvm {
|
||||
///
|
||||
FunctionPass *createStackProtectorPass();
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-include_llvm_CodeGen_ReturnProtectorLowering_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-include_llvm_CodeGen_ReturnProtectorLowering_h,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
- Refactor retguard to make adding additional arches easier.
|
||||
- Do not store the retguard cookie in frame in leaf functions if possible.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-include_llvm_CodeGen_TargetFrameLowering_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-include_llvm_CodeGen_TargetFrameLowering_h,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
- Add RETGUARD to clang for amd64. This security mechanism uses per-function
|
||||
random cookies to protect access to function return instructions, with the
|
||||
|
@ -27,10 +27,10 @@ Index: include/llvm/CodeGen/TargetFrameLowering.h
|
|||
|
||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||
+#include "llvm/CodeGen/ReturnProtectorLowering.h"
|
||||
#include "llvm/Support/TypeSize.h"
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
@@ -207,6 +208,10 @@ class TargetFrameLowering { (public)
|
||||
@@ -209,6 +210,10 @@ class TargetFrameLowering { (public)
|
||||
MachineBasicBlock &MBB) const = 0;
|
||||
virtual void emitEpilogue(MachineFunction &MF,
|
||||
MachineBasicBlock &MBB) const = 0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-include_llvm_InitializePasses_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-include_llvm_InitializePasses_h,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
Add RETGUARD to clang for amd64. This security mechanism uses per-function
|
||||
random cookies to protect access to function return instructions, with the
|
||||
|
@ -21,9 +21,9 @@ remove these gadgets will continue through other mechanisms.
|
|||
Index: include/llvm/InitializePasses.h
|
||||
--- include/llvm/InitializePasses.h.orig
|
||||
+++ include/llvm/InitializePasses.h
|
||||
@@ -372,6 +372,7 @@ void initializeRegionViewerPass(PassRegistry&);
|
||||
void initializeRegisterCoalescerPass(PassRegistry&);
|
||||
@@ -387,6 +387,7 @@ void initializeRemoveRedundantDebugValuesPass(PassRegi
|
||||
void initializeRenameIndependentSubregsPass(PassRegistry&);
|
||||
void initializeReplaceWithVeclibLegacyPass(PassRegistry &);
|
||||
void initializeResetMachineFunctionPass(PassRegistry&);
|
||||
+void initializeReturnProtectorPass(PassRegistry&);
|
||||
void initializeReversePostOrderFunctionAttrsLegacyPassPass(PassRegistry&);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_CodeGen_AsmPrinter_AsmPrinter_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_CodeGen_AsmPrinter_AsmPrinter_cpp,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
- Use int3 trap padding between functions instead of trapsleds with a leading jump.
|
||||
- Emit trap alignment between basic blocks that are unreachable via
|
||||
|
@ -8,7 +8,7 @@ $OpenBSD: patch-lib_CodeGen_AsmPrinter_AsmPrinter_cpp,v 1.4 2021/05/18 03:35:07
|
|||
Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp
|
||||
--- lib/CodeGen/AsmPrinter/AsmPrinter.cpp.orig
|
||||
+++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp
|
||||
@@ -687,7 +687,7 @@ void AsmPrinter::emitFunctionHeader() {
|
||||
@@ -745,7 +745,7 @@ void AsmPrinter::emitFunctionHeader() {
|
||||
|
||||
emitLinkage(&F, CurrentFnSym);
|
||||
if (MAI->hasFunctionAlignment())
|
||||
|
@ -17,7 +17,7 @@ Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp
|
|||
|
||||
if (MAI->hasDotTypeDotSizeDirective())
|
||||
OutStreamer->emitSymbolAttribute(CurrentFnSym, MCSA_ELF_TypeFunction);
|
||||
@@ -2256,6 +2256,30 @@ void AsmPrinter::emitAlignment(Align Alignment, const
|
||||
@@ -2462,6 +2462,30 @@ void AsmPrinter::emitAlignment(Align Alignment, const
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -48,7 +48,7 @@ Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp
|
|||
// Constant emission.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -3020,10 +3044,17 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasi
|
||||
@@ -3246,10 +3270,17 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasi
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,5 +66,5 @@ Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp
|
|||
+ emitTrapAlignment(Alignment);
|
||||
+ }
|
||||
|
||||
// If the block has its address taken, emit any labels that were used to
|
||||
// reference the block. It is possible that there is more than one label
|
||||
// Switch to a new section if this basic block must begin a section. The
|
||||
// entry block is always placed in the function section and is handled
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_CodeGen_CMakeLists_txt,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_CodeGen_CMakeLists_txt,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
- Add RETGUARD to clang for amd64. This security mechanism uses per-function
|
||||
random cookies to protect access to function return instructions, with the
|
||||
|
@ -22,12 +22,12 @@ $OpenBSD: patch-lib_CodeGen_CMakeLists_txt,v 1.4 2021/05/18 03:35:07 rsadowski E
|
|||
Index: lib/CodeGen/CMakeLists.txt
|
||||
--- lib/CodeGen/CMakeLists.txt.orig
|
||||
+++ lib/CodeGen/CMakeLists.txt
|
||||
@@ -142,6 +142,8 @@ add_llvm_component_library(LLVMCodeGen
|
||||
RegUsageInfoCollector.cpp
|
||||
@@ -153,6 +153,8 @@ add_llvm_component_library(LLVMCodeGen
|
||||
RegUsageInfoPropagate.cpp
|
||||
ReplaceWithVeclib.cpp
|
||||
ResetMachineFunctionPass.cpp
|
||||
+ ReturnProtectorLowering.cpp
|
||||
+ ReturnProtectorPass.cpp
|
||||
SafeStack.cpp
|
||||
SafeStackLayout.cpp
|
||||
ScalarizeMaskedMemIntrin.cpp
|
||||
ScheduleDAG.cpp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_CodeGen_PrologEpilogInserter_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_CodeGen_PrologEpilogInserter_cpp,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
- Add RETGUARD to clang for amd64. This security mechanism uses per-function
|
||||
random cookies to protect access to function return instructions, with the
|
||||
|
@ -22,7 +22,7 @@ $OpenBSD: patch-lib_CodeGen_PrologEpilogInserter_cpp,v 1.4 2021/05/18 03:35:07 r
|
|||
Index: lib/CodeGen/PrologEpilogInserter.cpp
|
||||
--- lib/CodeGen/PrologEpilogInserter.cpp.orig
|
||||
+++ lib/CodeGen/PrologEpilogInserter.cpp
|
||||
@@ -217,7 +217,11 @@ bool PEI::runOnMachineFunction(MachineFunction &MF) {
|
||||
@@ -213,7 +213,11 @@ bool PEI::runOnMachineFunction(MachineFunction &MF) {
|
||||
const Function &F = MF.getFunction();
|
||||
const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
|
||||
const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering();
|
||||
|
@ -34,7 +34,7 @@ Index: lib/CodeGen/PrologEpilogInserter.cpp
|
|||
RS = TRI->requiresRegisterScavenging(MF) ? new RegScavenger() : nullptr;
|
||||
FrameIndexVirtualScavenging = TRI->requiresFrameIndexScavenging(MF);
|
||||
ORE = &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE();
|
||||
@@ -255,6 +259,10 @@ bool PEI::runOnMachineFunction(MachineFunction &MF) {
|
||||
@@ -251,6 +255,10 @@ bool PEI::runOnMachineFunction(MachineFunction &MF) {
|
||||
if (!F.hasFnAttribute(Attribute::Naked))
|
||||
insertPrologEpilogCode(MF);
|
||||
|
||||
|
@ -45,7 +45,7 @@ Index: lib/CodeGen/PrologEpilogInserter.cpp
|
|||
// Reinsert stashed debug values at the start of the entry blocks.
|
||||
for (auto &I : EntryDbgValues)
|
||||
I.first->insert(I.first->begin(), I.second.begin(), I.second.end());
|
||||
@@ -353,7 +361,9 @@ void PEI::calculateCallFrameInfo(MachineFunction &MF)
|
||||
@@ -357,7 +365,9 @@ void PEI::calculateCallFrameInfo(MachineFunction &MF)
|
||||
/// Compute the sets of entry and return blocks for saving and restoring
|
||||
/// callee-saved registers, and placing prolog and epilog code.
|
||||
void PEI::calculateSaveRestoreBlocks(MachineFunction &MF) {
|
||||
|
@ -56,7 +56,7 @@ Index: lib/CodeGen/PrologEpilogInserter.cpp
|
|||
|
||||
// Even when we do not change any CSR, we still want to insert the
|
||||
// prologue and epilogue of the function.
|
||||
@@ -369,7 +379,18 @@ void PEI::calculateSaveRestoreBlocks(MachineFunction &
|
||||
@@ -373,7 +383,18 @@ void PEI::calculateSaveRestoreBlocks(MachineFunction &
|
||||
// epilogue.
|
||||
if (!RestoreBlock->succ_empty() || RestoreBlock->isReturnBlock())
|
||||
RestoreBlocks.push_back(RestoreBlock);
|
||||
|
@ -76,7 +76,7 @@ Index: lib/CodeGen/PrologEpilogInserter.cpp
|
|||
}
|
||||
|
||||
// Save refs to entry and return blocks.
|
||||
@@ -380,6 +401,9 @@ void PEI::calculateSaveRestoreBlocks(MachineFunction &
|
||||
@@ -384,6 +405,9 @@ void PEI::calculateSaveRestoreBlocks(MachineFunction &
|
||||
if (MBB.isReturnBlock())
|
||||
RestoreBlocks.push_back(&MBB);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ Index: lib/CodeGen/PrologEpilogInserter.cpp
|
|||
}
|
||||
|
||||
static void assignCalleeSavedSpillSlots(MachineFunction &F,
|
||||
@@ -401,6 +425,10 @@ static void assignCalleeSavedSpillSlots(MachineFunctio
|
||||
@@ -405,6 +429,10 @@ static void assignCalleeSavedSpillSlots(MachineFunctio
|
||||
|
||||
const TargetFrameLowering *TFI = F.getSubtarget().getFrameLowering();
|
||||
MachineFrameInfo &MFI = F.getFrameInfo();
|
||||
|
@ -94,6 +94,6 @@ Index: lib/CodeGen/PrologEpilogInserter.cpp
|
|||
+ if (TFI->getReturnProtector())
|
||||
+ TFI->getReturnProtector()->saveReturnProtectorRegister(F, CSI);
|
||||
+
|
||||
if (!TFI->assignCalleeSavedSpillSlots(F, RegInfo, CSI)) {
|
||||
if (!TFI->assignCalleeSavedSpillSlots(F, RegInfo, CSI, MinCSFrameIndex,
|
||||
MaxCSFrameIndex)) {
|
||||
// If target doesn't implement this, use generic code.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_CodeGen_ReturnProtectorLowering_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_CodeGen_ReturnProtectorLowering_cpp,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
- Refactor retguard to make adding additional arches easier.
|
||||
- Do not store the retguard cookie in frame in leaf functions if possible.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_CodeGen_ReturnProtectorPass_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_CodeGen_ReturnProtectorPass_cpp,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
- Add RETGUARD to clang for amd64. This security mechanism uses per-function
|
||||
random cookies to protect access to function return instructions, with the
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_CodeGen_TargetPassConfig_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_CodeGen_TargetPassConfig_cpp,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
Add RETGUARD to clang for amd64. This security mechanism uses per-function
|
||||
random cookies to protect access to function return instructions, with the
|
||||
|
@ -21,7 +21,7 @@ remove these gadgets will continue through other mechanisms.
|
|||
Index: lib/CodeGen/TargetPassConfig.cpp
|
||||
--- lib/CodeGen/TargetPassConfig.cpp.orig
|
||||
+++ lib/CodeGen/TargetPassConfig.cpp
|
||||
@@ -773,6 +773,8 @@ void TargetPassConfig::addISelPrepare() {
|
||||
@@ -950,6 +950,8 @@ void TargetPassConfig::addISelPrepare() {
|
||||
if (requiresCodeGenSCCOrder())
|
||||
addPass(new DummyCGSCCPass);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_MC_MCAsmInfoELF_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_MC_MCAsmInfoELF_cpp,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
Do not use ident.
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
$OpenBSD: patch-lib_MC_MCELFStreamer_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_MC_MCELFStreamer_cpp,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
getNonexecutableStackSection() may return nullptr.
|
||||
|
||||
Index: lib/MC/MCELFStreamer.cpp
|
||||
--- lib/MC/MCELFStreamer.cpp.orig
|
||||
+++ lib/MC/MCELFStreamer.cpp
|
||||
@@ -92,8 +92,11 @@ void MCELFStreamer::InitSections(bool NoExecStack) {
|
||||
@@ -93,8 +93,11 @@ void MCELFStreamer::InitSections(bool NoExecStack) {
|
||||
SwitchSection(Ctx.getObjectFileInfo()->getTextSection());
|
||||
emitCodeAlignment(4);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_MC_MCParser_AsmParser_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_MC_MCParser_AsmParser_cpp,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
make clang include a FILE symbol for .(s|S) files
|
||||
|
||||
|
@ -11,7 +11,7 @@ a file directive.
|
|||
Index: lib/MC/MCParser/AsmParser.cpp
|
||||
--- lib/MC/MCParser/AsmParser.cpp.orig
|
||||
+++ lib/MC/MCParser/AsmParser.cpp
|
||||
@@ -909,6 +909,10 @@ bool AsmParser::Run(bool NoInitialTextSection, bool No
|
||||
@@ -975,6 +975,10 @@ bool AsmParser::Run(bool NoInitialTextSection, bool No
|
||||
(void)InsertResult;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,6 @@ Index: lib/MC/MCParser/AsmParser.cpp
|
|||
+ if (!Filename.empty() && (Filename.compare(StringRef("-")) != 0))
|
||||
+ Out.emitFileDirective(Filename);
|
||||
+
|
||||
getTargetParser().onBeginOfFile();
|
||||
|
||||
// While we have input, parse each statement.
|
||||
while (Lexer.isNot(AsmToken::Eof)) {
|
||||
ParseStatementInfo Info(&AsmStrRewrites);
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
$OpenBSD: patch-lib_Support_CMakeLists_txt,v 1.3 2021/05/18 03:35:07 rsadowski Exp $
|
||||
|
||||
For upstream:
|
||||
bogus dep on all headers in ${Backtrace_INCLUDE_DIRS} ie /usr/local/include.
|
||||
|
||||
Index: lib/Support/CMakeLists.txt
|
||||
--- lib/Support/CMakeLists.txt.orig
|
||||
+++ lib/Support/CMakeLists.txt
|
||||
@@ -193,7 +193,6 @@ add_llvm_component_library(LLVMSupport
|
||||
Windows
|
||||
${LLVM_MAIN_INCLUDE_DIR}/llvm/ADT
|
||||
${LLVM_MAIN_INCLUDE_DIR}/llvm/Support
|
||||
- ${Backtrace_INCLUDE_DIRS}
|
||||
LINK_LIBS ${system_libs} ${delayload_flags} ${Z3_LINK_FILES}
|
||||
)
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
$OpenBSD: patch-lib_Target_AArch64_AArch64AsmPrinter_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_AArch64_AArch64AsmPrinter_cpp,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
Add retguard for arm64.
|
||||
|
||||
Index: lib/Target/AArch64/AArch64AsmPrinter.cpp
|
||||
--- lib/Target/AArch64/AArch64AsmPrinter.cpp.orig
|
||||
+++ lib/Target/AArch64/AArch64AsmPrinter.cpp
|
||||
@@ -1350,6 +1350,19 @@ void AArch64AsmPrinter::emitInstruction(const MachineI
|
||||
@@ -1488,6 +1488,19 @@ void AArch64AsmPrinter::emitInstruction(const MachineI
|
||||
case AArch64::SEH_EpilogEnd:
|
||||
TS->EmitARM64WinCFIEpilogEnd();
|
||||
TS->emitARM64WinCFIEpilogEnd();
|
||||
return;
|
||||
+
|
||||
+ case AArch64::RETGUARD_JMP_TRAP:
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
$OpenBSD: patch-lib_Target_AArch64_AArch64FrameLowering_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_AArch64_AArch64FrameLowering_cpp,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
Add retguard for arm64.
|
||||
|
||||
Index: lib/Target/AArch64/AArch64FrameLowering.cpp
|
||||
--- lib/Target/AArch64/AArch64FrameLowering.cpp.orig
|
||||
+++ lib/Target/AArch64/AArch64FrameLowering.cpp
|
||||
@@ -116,6 +116,7 @@
|
||||
@@ -123,6 +123,7 @@
|
||||
#include "AArch64InstrInfo.h"
|
||||
#include "AArch64MachineFunctionInfo.h"
|
||||
#include "AArch64RegisterInfo.h"
|
||||
+#include "AArch64ReturnProtectorLowering.h"
|
||||
#include "AArch64StackOffset.h"
|
||||
#include "AArch64Subtarget.h"
|
||||
#include "AArch64TargetMachine.h"
|
||||
@@ -2521,6 +2522,10 @@ void AArch64FrameLowering::determineCalleeSaves(Machin
|
||||
#include "MCTargetDesc/AArch64AddressingModes.h"
|
||||
@@ -2753,6 +2754,10 @@ void AArch64FrameLowering::determineCalleeSaves(Machin
|
||||
? RegInfo->getBaseRegister()
|
||||
: (unsigned)AArch64::NoRegister;
|
||||
|
||||
|
@ -24,7 +24,7 @@ Index: lib/Target/AArch64/AArch64FrameLowering.cpp
|
|||
unsigned ExtraCSSpill = 0;
|
||||
// Figure out which callee-saved registers to save/restore.
|
||||
for (unsigned i = 0; CSRegs[i]; ++i) {
|
||||
@@ -3251,4 +3256,8 @@ unsigned AArch64FrameLowering::getWinEHFuncletFrameSiz
|
||||
@@ -3532,6 +3537,10 @@ unsigned AArch64FrameLowering::getWinEHFuncletFrameSiz
|
||||
// This is the amount of stack a funclet needs to allocate.
|
||||
return alignTo(CSSize + MF.getFrameInfo().getMaxCallFrameSize(),
|
||||
getStackAlign());
|
||||
|
@ -33,3 +33,5 @@ Index: lib/Target/AArch64/AArch64FrameLowering.cpp
|
|||
+const ReturnProtectorLowering *AArch64FrameLowering::getReturnProtector() const {
|
||||
+ return &RPL;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_AArch64_AArch64FrameLowering_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_AArch64_AArch64FrameLowering_h,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
Add retguard for arm64.
|
||||
|
||||
|
@ -10,7 +10,7 @@ Index: lib/Target/AArch64/AArch64FrameLowering.h
|
|||
#define LLVM_LIB_TARGET_AARCH64_AARCH64FRAMELOWERING_H
|
||||
|
||||
+#include "AArch64ReturnProtectorLowering.h"
|
||||
#include "AArch64StackOffset.h"
|
||||
#include "llvm/Support/TypeSize.h"
|
||||
#include "llvm/CodeGen/TargetFrameLowering.h"
|
||||
|
||||
@@ -22,9 +23,12 @@ class MCCFIInstruction;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_AArch64_AArch64ISelLowering_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_AArch64_AArch64ISelLowering_cpp,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
Disable the Load Stack Guard for OpenBSD on AArch64. We don't use it
|
||||
on any other platform and it causes a segfault in combination with our
|
||||
|
@ -7,7 +7,7 @@ IR Stack Guard.
|
|||
Index: lib/Target/AArch64/AArch64ISelLowering.cpp
|
||||
--- lib/Target/AArch64/AArch64ISelLowering.cpp.orig
|
||||
+++ lib/Target/AArch64/AArch64ISelLowering.cpp
|
||||
@@ -14558,7 +14558,8 @@ void AArch64TargetLowering::ReplaceNodeResults(
|
||||
@@ -17364,7 +17364,8 @@ void AArch64TargetLowering::ReplaceNodeResults(
|
||||
}
|
||||
|
||||
bool AArch64TargetLowering::useLoadStackGuardNode() const {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
$OpenBSD: patch-lib_Target_AArch64_AArch64InstrInfo_cpp,v 1.2 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_AArch64_AArch64InstrInfo_cpp,v 1.3 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
XXX no comment
|
||||
|
||||
Index: lib/Target/AArch64/AArch64InstrInfo.cpp
|
||||
--- lib/Target/AArch64/AArch64InstrInfo.cpp.orig
|
||||
+++ lib/Target/AArch64/AArch64InstrInfo.cpp
|
||||
@@ -96,6 +96,9 @@ unsigned AArch64InstrInfo::getInstSizeInBytes(const Ma
|
||||
@@ -97,6 +97,9 @@ unsigned AArch64InstrInfo::getInstSizeInBytes(const Ma
|
||||
default:
|
||||
// Anything not explicitly designated otherwise is a normal 4-byte insn.
|
||||
NumBytes = 4;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
$OpenBSD: patch-lib_Target_AArch64_AArch64InstrInfo_td,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_AArch64_AArch64InstrInfo_td,v 1.5 2022/01/03 21:36:41 rsadowski Exp $
|
||||
|
||||
Add retguard for arm64.
|
||||
|
||||
Index: lib/Target/AArch64/AArch64InstrInfo.td
|
||||
--- lib/Target/AArch64/AArch64InstrInfo.td.orig
|
||||
+++ lib/Target/AArch64/AArch64InstrInfo.td
|
||||
@@ -678,6 +678,14 @@ def ADDlowTLS
|
||||
@@ -721,6 +721,14 @@ def ADDlowTLS
|
||||
|
||||
} // isReMaterializable, isCodeGenOnly
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_AArch64_AArch64ReturnProtectorLowering_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_AArch64_AArch64ReturnProtectorLowering_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add retguard for arm64.
|
||||
- Do not store the retguard cookie in frame in leaf functions if possible.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_AArch64_AArch64ReturnProtectorLowering_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_AArch64_AArch64ReturnProtectorLowering_h,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add retguard for arm64.
|
||||
- Do not store the retguard cookie in frame in leaf functions if possible.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_AArch64_AArch64Subtarget_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_AArch64_AArch64Subtarget_h,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Disable the Load Stack Guard for OpenBSD on AArch64. We don't use it
|
||||
on any other platform and it causes a segfault in combination with our
|
||||
|
@ -7,7 +7,7 @@ IR Stack Guard.
|
|||
Index: lib/Target/AArch64/AArch64Subtarget.h
|
||||
--- lib/Target/AArch64/AArch64Subtarget.h.orig
|
||||
+++ lib/Target/AArch64/AArch64Subtarget.h
|
||||
@@ -453,6 +453,7 @@ class AArch64Subtarget final : public AArch64GenSubtar
|
||||
@@ -500,6 +500,7 @@ class AArch64Subtarget final : public AArch64GenSubtar
|
||||
bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
|
||||
bool isTargetIOS() const { return TargetTriple.isiOS(); }
|
||||
bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_AArch64_AArch64TargetMachine_cpp,v 1.2 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_AArch64_AArch64TargetMachine_cpp,v 1.3 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Always disable GlobalISel on aarch64, fixes a crash when building on
|
||||
aarch64 without retguard, with a stack protector and without
|
||||
|
@ -7,11 +7,11 @@ optimizations.
|
|||
Index: lib/Target/AArch64/AArch64TargetMachine.cpp
|
||||
--- lib/Target/AArch64/AArch64TargetMachine.cpp.orig
|
||||
+++ lib/Target/AArch64/AArch64TargetMachine.cpp
|
||||
@@ -308,6 +308,7 @@ AArch64TargetMachine::AArch64TargetMachine(const Targe
|
||||
@@ -332,6 +332,7 @@ AArch64TargetMachine::AArch64TargetMachine(const Targe
|
||||
// Enable GlobalISel at or below EnableGlobalISelAt0, unless this is
|
||||
// MachO/CodeModel::Large, which GlobalISel does not support.
|
||||
if (getOptLevel() <= EnableGlobalISelAtO &&
|
||||
+ !getTargetTriple().isOSOpenBSD() &&
|
||||
TT.getArch() != Triple::aarch64_32 &&
|
||||
TT.getEnvironment() != Triple::GNUILP32 &&
|
||||
!(getCodeModel() == CodeModel::Large && TT.isOSBinFormatMachO())) {
|
||||
setGlobalISel(true);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
$OpenBSD: patch-lib_Target_AArch64_CMakeLists_txt,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_AArch64_CMakeLists_txt,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Add retguard for arm64.
|
||||
|
||||
Index: lib/Target/AArch64/CMakeLists.txt
|
||||
--- lib/Target/AArch64/CMakeLists.txt.orig
|
||||
+++ lib/Target/AArch64/CMakeLists.txt
|
||||
@@ -59,6 +59,7 @@ add_llvm_target(AArch64CodeGen
|
||||
@@ -70,6 +70,7 @@ add_llvm_target(AArch64CodeGen
|
||||
AArch64PromoteConstant.cpp
|
||||
AArch64PBQPRegAlloc.cpp
|
||||
AArch64RegisterInfo.cpp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_Mips_AsmParser_MipsAsmParser_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Mips_AsmParser_MipsAsmParser_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Adapt the -mfix-loongson2f-btb workaround from as(1) to LLVM/clang.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_Mips_CMakeLists_txt,v 1.3 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Mips_CMakeLists_txt,v 1.4 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Adapt the -mfix-loongson2f-btb workaround from as(1) to LLVM/clang.
|
||||
- Add retguard for octeon/mips64.
|
||||
|
@ -6,7 +6,7 @@ $OpenBSD: patch-lib_Target_Mips_CMakeLists_txt,v 1.3 2021/05/18 03:35:07 rsadows
|
|||
Index: lib/Target/Mips/CMakeLists.txt
|
||||
--- lib/Target/Mips/CMakeLists.txt.orig
|
||||
+++ lib/Target/Mips/CMakeLists.txt
|
||||
@@ -39,6 +39,7 @@ add_llvm_target(MipsCodeGen
|
||||
@@ -41,6 +41,7 @@ add_llvm_target(MipsCodeGen
|
||||
MipsISelLowering.cpp
|
||||
MipsFrameLowering.cpp
|
||||
MipsLegalizerInfo.cpp
|
||||
|
@ -14,7 +14,7 @@ Index: lib/Target/Mips/CMakeLists.txt
|
|||
MipsBranchExpansion.cpp
|
||||
MipsMCInstLower.cpp
|
||||
MipsMachineFunction.cpp
|
||||
@@ -48,6 +49,7 @@ add_llvm_target(MipsCodeGen
|
||||
@@ -50,6 +51,7 @@ add_llvm_target(MipsCodeGen
|
||||
MipsPreLegalizerCombiner.cpp
|
||||
MipsRegisterBankInfo.cpp
|
||||
MipsRegisterInfo.cpp
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
$OpenBSD: patch-lib_Target_Mips_MCTargetDesc_MipsABIInfo_cpp,v 1.1 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Mips_MCTargetDesc_MipsABIInfo_cpp,v 1.2 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Adapt the -mfix-loongson2f-btb workaround from as(1) to LLVM/clang.
|
||||
|
||||
Index: lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp
|
||||
--- lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp.orig
|
||||
+++ lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp
|
||||
@@ -22,6 +22,11 @@ EmitJalrReloc("mips-jalr-reloc", cl::Hidden,
|
||||
@@ -21,6 +21,11 @@ EmitJalrReloc("mips-jalr-reloc", cl::Hidden,
|
||||
cl::desc("MIPS: Emit R_{MICRO}MIPS_JALR relocation with jalr"),
|
||||
cl::init(true));
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_Mips_MipsAsmPrinter_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Mips_MipsAsmPrinter_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add retguard for octeon/mips64.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_Mips_MipsFrameLowering_cpp,v 1.3 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Mips_MipsFrameLowering_cpp,v 1.4 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Add retguard for octeon/mips64.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_Mips_MipsFrameLowering_h,v 1.3 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Mips_MipsFrameLowering_h,v 1.4 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Add retguard for octeon/mips64.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_Mips_MipsISelLowering_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Mips_MipsISelLowering_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Implement the 'h' register constraint on mips64. This lets clang build
|
||||
pieces of software that use the constraint if the compiler claims
|
||||
|
@ -12,7 +12,7 @@ $OpenBSD: patch-lib_Target_Mips_MipsISelLowering_cpp,v 1.4 2021/05/18 03:35:07 r
|
|||
Index: lib/Target/Mips/MipsISelLowering.cpp
|
||||
--- lib/Target/Mips/MipsISelLowering.cpp.orig
|
||||
+++ lib/Target/Mips/MipsISelLowering.cpp
|
||||
@@ -3919,6 +3919,7 @@ MipsTargetLowering::getConstraintType(StringRef Constr
|
||||
@@ -3925,6 +3925,7 @@ MipsTargetLowering::getConstraintType(StringRef Constr
|
||||
// backwards compatibility.
|
||||
// 'c' : A register suitable for use in an indirect
|
||||
// jump. This will always be $25 for -mabicalls.
|
||||
|
@ -20,7 +20,7 @@ Index: lib/Target/Mips/MipsISelLowering.cpp
|
|||
// 'l' : The lo register. 1 word storage.
|
||||
// 'x' : The hilo register pair. Double word storage.
|
||||
if (Constraint.size() == 1) {
|
||||
@@ -3928,6 +3929,7 @@ MipsTargetLowering::getConstraintType(StringRef Constr
|
||||
@@ -3934,6 +3935,7 @@ MipsTargetLowering::getConstraintType(StringRef Constr
|
||||
case 'y':
|
||||
case 'f':
|
||||
case 'c':
|
||||
|
@ -28,7 +28,7 @@ Index: lib/Target/Mips/MipsISelLowering.cpp
|
|||
case 'l':
|
||||
case 'x':
|
||||
return C_RegisterClass;
|
||||
@@ -3973,6 +3975,7 @@ MipsTargetLowering::getSingleConstraintMatchWeight(
|
||||
@@ -3979,6 +3981,7 @@ MipsTargetLowering::getSingleConstraintMatchWeight(
|
||||
weight = CW_Register;
|
||||
break;
|
||||
case 'c': // $25 for indirect jumps
|
||||
|
@ -36,7 +36,7 @@ Index: lib/Target/Mips/MipsISelLowering.cpp
|
|||
case 'l': // lo register
|
||||
case 'x': // hilo register pair
|
||||
if (type->isIntegerTy())
|
||||
@@ -4147,6 +4150,11 @@ MipsTargetLowering::getRegForInlineAsmConstraint(const
|
||||
@@ -4153,6 +4156,11 @@ MipsTargetLowering::getRegForInlineAsmConstraint(const
|
||||
return std::make_pair((unsigned)Mips::T9_64, &Mips::GPR64RegClass);
|
||||
// This will generate an error message
|
||||
return std::make_pair(0U, nullptr);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_Mips_MipsInstrInfo_td,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Mips_MipsInstrInfo_td,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add retguard for octeon/mips64.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_Mips_MipsLoongson2FBTBFix_cpp,v 1.1 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Mips_MipsLoongson2FBTBFix_cpp,v 1.2 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Adapt the -mfix-loongson2f-btb workaround from as(1) to LLVM/clang.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_Mips_MipsReturnProtectorLowering_cpp,v 1.3 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Mips_MipsReturnProtectorLowering_cpp,v 1.4 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Add retguard for octeon/mips64.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_Mips_MipsReturnProtectorLowering_h,v 1.3 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Mips_MipsReturnProtectorLowering_h,v 1.4 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Add retguard for octeon/mips64.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_Mips_MipsTargetMachine_cpp,v 1.1 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Mips_MipsTargetMachine_cpp,v 1.2 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Adapt the -mfix-loongson2f-btb workaround from as(1) to LLVM/clang.
|
||||
|
||||
|
@ -14,7 +14,7 @@ Index: lib/Target/Mips/MipsTargetMachine.cpp
|
|||
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsTarget() {
|
||||
// Register the target.
|
||||
RegisterTargetMachine<MipsebTargetMachine> X(getTheMipsTarget());
|
||||
@@ -280,6 +282,9 @@ bool MipsPassConfig::addInstSelector() {
|
||||
@@ -268,6 +270,9 @@ bool MipsPassConfig::addInstSelector() {
|
||||
|
||||
void MipsPassConfig::addPreRegAlloc() {
|
||||
addPass(createMipsOptimizePICCallPass());
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_Mips_Mips_h,v 1.1 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Mips_Mips_h,v 1.2 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Adapt the -mfix-loongson2f-btb workaround from as(1) to LLVM/clang.
|
||||
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
$OpenBSD: patch-lib_Target_PowerPC_CMakeLists_txt,v 1.1 2021/05/18 03:35:07 rsadowski Exp $
|
||||
|
||||
Add RETGUARD implementation for powerpc and powerpc64.
|
||||
$OpenBSD: patch-lib_Target_PowerPC_CMakeLists_txt,v 1.2 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Index: lib/Target/PowerPC/CMakeLists.txt
|
||||
--- lib/Target/PowerPC/CMakeLists.txt.orig
|
||||
+++ lib/Target/PowerPC/CMakeLists.txt
|
||||
@@ -36,6 +36,7 @@ add_llvm_target(PowerPCCodeGen
|
||||
@@ -42,6 +42,7 @@ add_llvm_target(PowerPCCodeGen
|
||||
PPCMacroFusion.cpp
|
||||
PPCMIPeephole.cpp
|
||||
PPCRegisterInfo.cpp
|
||||
+ PPCReturnProtectorLowering.cpp
|
||||
PPCQPXLoadSplat.cpp
|
||||
PPCSubtarget.cpp
|
||||
PPCTargetMachine.cpp
|
||||
PPCTargetObjectFile.cpp
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
$OpenBSD: patch-lib_Target_PowerPC_PPCAsmPrinter_cpp,v 1.1 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_PowerPC_PPCAsmPrinter_cpp,v 1.2 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Add RETGUARD implementation for powerpc and powerpc64.
|
||||
|
||||
Index: lib/Target/PowerPC/PPCAsmPrinter.cpp
|
||||
--- lib/Target/PowerPC/PPCAsmPrinter.cpp.orig
|
||||
+++ lib/Target/PowerPC/PPCAsmPrinter.cpp
|
||||
@@ -657,6 +657,85 @@ void PPCAsmPrinter::emitInstruction(const MachineInstr
|
||||
@@ -815,6 +815,85 @@ void PPCAsmPrinter::emitInstruction(const MachineInstr
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_PowerPC_PPCFrameLowering_cpp,v 1.1 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_PowerPC_PPCFrameLowering_cpp,v 1.2 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Add RETGUARD implementation for powerpc and powerpc64.
|
||||
|
||||
|
@ -13,10 +13,10 @@ Index: lib/Target/PowerPC/PPCFrameLowering.cpp
|
|||
#include "PPCSubtarget.h"
|
||||
#include "PPCTargetMachine.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
@@ -2626,4 +2627,8 @@ bool PPCFrameLowering::enableShrinkWrapping(const Mach
|
||||
@@ -2696,4 +2697,8 @@ bool PPCFrameLowering::enableShrinkWrapping(const Mach
|
||||
if (MF.getInfo<PPCFunctionInfo>()->shrinkWrapDisabled())
|
||||
return false;
|
||||
return (MF.getSubtarget<PPCSubtarget>().isSVR4ABI() &&
|
||||
MF.getSubtarget<PPCSubtarget>().isPPC64());
|
||||
return !MF.getSubtarget<PPCSubtarget>().is32BitELFABI();
|
||||
+}
|
||||
+
|
||||
+const ReturnProtectorLowering *PPCFrameLowering::getReturnProtector() const {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_PowerPC_PPCFrameLowering_h,v 1.1 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_PowerPC_PPCFrameLowering_h,v 1.2 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Add RETGUARD implementation for powerpc and powerpc64.
|
||||
|
||||
|
@ -13,7 +13,7 @@ Index: lib/Target/PowerPC/PPCFrameLowering.h
|
|||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/CodeGen/TargetFrameLowering.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
@@ -169,6 +170,9 @@ class PPCFrameLowering: public TargetFrameLowering { (
|
||||
@@ -173,6 +174,9 @@ class PPCFrameLowering: public TargetFrameLowering { (
|
||||
/// function prologue/epilogue.
|
||||
bool canUseAsPrologue(const MachineBasicBlock &MBB) const override;
|
||||
bool canUseAsEpilogue(const MachineBasicBlock &MBB) const override;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
$OpenBSD: patch-lib_Target_PowerPC_PPCInstrInfo_td,v 1.1 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_PowerPC_PPCInstrInfo_td,v 1.2 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Add RETGUARD implementation for powerpc and powerpc64.
|
||||
|
||||
Index: lib/Target/PowerPC/PPCInstrInfo.td
|
||||
--- lib/Target/PowerPC/PPCInstrInfo.td.orig
|
||||
+++ lib/Target/PowerPC/PPCInstrInfo.td
|
||||
@@ -1527,6 +1527,31 @@ let Defs = [LR] in
|
||||
@@ -1690,6 +1690,31 @@ let Defs = [LR] in
|
||||
def MoveGOTtoLR : PPCEmitTimePseudo<(outs), (ins), "#MoveGOTtoLR", []>,
|
||||
PPC970_Unit_BRU;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_PowerPC_PPCReturnProtectorLowering_cpp,v 1.1 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_PowerPC_PPCReturnProtectorLowering_cpp,v 1.2 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add RETGUARD implementation for powerpc and powerpc64.
|
||||
- Use all 64 bits of the RETGUARD cookie on powerpc64.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_PowerPC_PPCReturnProtectorLowering_h,v 1.1 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_PowerPC_PPCReturnProtectorLowering_h,v 1.2 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Add RETGUARD implementation for powerpc and powerpc64.
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
$OpenBSD: patch-lib_Target_PowerPC_PPCTargetMachine_cpp,v 1.2 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_PowerPC_PPCTargetMachine_cpp,v 1.3 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Switch Powerpc64 Big Endian to ELFv2 on OpenBSD.
|
||||
|
||||
Index: lib/Target/PowerPC/PPCTargetMachine.cpp
|
||||
--- lib/Target/PowerPC/PPCTargetMachine.cpp.orig
|
||||
+++ lib/Target/PowerPC/PPCTargetMachine.cpp
|
||||
@@ -216,6 +216,8 @@ static PPCTargetMachine::PPCABI computeTargetABI(const
|
||||
@@ -228,6 +228,8 @@ static PPCTargetMachine::PPCABI computeTargetABI(const
|
||||
case Triple::ppc64le:
|
||||
return PPCTargetMachine::PPC_ABI_ELFv2;
|
||||
case Triple::ppc64:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_Sparc_SparcISelLowering_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Sparc_SparcISelLowering_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Make sure that we really don't emit quad-precision unless the
|
||||
"hard-quad-float" feature is available
|
||||
|
@ -6,7 +6,7 @@ $OpenBSD: patch-lib_Target_Sparc_SparcISelLowering_cpp,v 1.4 2021/05/18 03:35:07
|
|||
Index: lib/Target/Sparc/SparcISelLowering.cpp
|
||||
--- lib/Target/Sparc/SparcISelLowering.cpp.orig
|
||||
+++ lib/Target/Sparc/SparcISelLowering.cpp
|
||||
@@ -3111,6 +3111,11 @@ SparcTargetLowering::EmitInstrWithCustomInserter(Machi
|
||||
@@ -3116,6 +3116,11 @@ SparcTargetLowering::EmitInstrWithCustomInserter(Machi
|
||||
case SP::SELECT_CC_DFP_ICC:
|
||||
case SP::SELECT_CC_QFP_ICC:
|
||||
return expandSelectCC(MI, BB, SP::BCOND);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_Sparc_SparcInstr64Bit_td,v 1.2 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Sparc_SparcInstr64Bit_td,v 1.3 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Make sure that we really don't emit quad-precision unless the
|
||||
"hard-quad-float" feature is available.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_Sparc_SparcInstrInfo_td,v 1.2 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_Sparc_SparcInstrInfo_td,v 1.3 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Make sure that we really don't emit quad-precision unless the
|
||||
"hard-quad-float" feature is available
|
||||
|
@ -6,7 +6,7 @@ Make sure that we really don't emit quad-precision unless the
|
|||
Index: lib/Target/Sparc/SparcInstrInfo.td
|
||||
--- lib/Target/Sparc/SparcInstrInfo.td.orig
|
||||
+++ lib/Target/Sparc/SparcInstrInfo.td
|
||||
@@ -468,6 +468,27 @@ let Uses = [ICC], usesCustomInserter = 1 in {
|
||||
@@ -487,6 +487,27 @@ let Uses = [ICC], usesCustomInserter = 1 in {
|
||||
[(set f128:$dst, (SPselecticc f128:$T, f128:$F, imm:$Cond))]>;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ Index: lib/Target/Sparc/SparcInstrInfo.td
|
|||
let usesCustomInserter = 1, Uses = [FCC0] in {
|
||||
|
||||
def SELECT_CC_Int_FCC
|
||||
@@ -1391,12 +1412,12 @@ let Predicates = [HasV9], Constraints = "$f = $rd" in
|
||||
@@ -1418,12 +1439,12 @@ let Predicates = [HasV9], Constraints = "$f = $rd" in
|
||||
(ins DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond),
|
||||
"fmovd$cond %icc, $rs2, $rd",
|
||||
[(set f64:$rd, (SPselecticc f64:$rs2, f64:$f, imm:$cond))]>;
|
||||
|
@ -49,7 +49,7 @@ Index: lib/Target/Sparc/SparcInstrInfo.td
|
|||
}
|
||||
|
||||
let Uses = [FCC0], intcc = 0, opf_cc = 0b00 in {
|
||||
@@ -1410,12 +1431,12 @@ let Predicates = [HasV9], Constraints = "$f = $rd" in
|
||||
@@ -1437,12 +1458,12 @@ let Predicates = [HasV9], Constraints = "$f = $rd" in
|
||||
(ins DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond),
|
||||
"fmovd$cond %fcc0, $rs2, $rd",
|
||||
[(set f64:$rd, (SPselectfcc f64:$rs2, f64:$f, imm:$cond))]>;
|
||||
|
@ -64,7 +64,7 @@ Index: lib/Target/Sparc/SparcInstrInfo.td
|
|||
}
|
||||
|
||||
}
|
||||
@@ -1425,28 +1446,28 @@ let Predicates = [HasV9] in {
|
||||
@@ -1452,28 +1473,28 @@ let Predicates = [HasV9] in {
|
||||
def FMOVD : F3_3u<2, 0b110100, 0b000000010,
|
||||
(outs DFPRegs:$rd), (ins DFPRegs:$rs2),
|
||||
"fmovd $rs2, $rd", []>;
|
||||
|
@ -99,7 +99,7 @@ Index: lib/Target/Sparc/SparcInstrInfo.td
|
|||
}
|
||||
|
||||
// Floating-point compare instruction with %fcc0-%fcc3.
|
||||
@@ -1493,11 +1514,11 @@ let Predicates = [HasV9] in {
|
||||
@@ -1520,11 +1541,11 @@ let Predicates = [HasV9] in {
|
||||
: F4_3<0b110101, 0b000010, (outs DFPRegs:$rd),
|
||||
(ins FCCRegs:$opf_cc, DFPRegs:$rs2, DFPRegs:$f, CCOp:$cond),
|
||||
"fmovd$cond $opf_cc, $rs2, $rd", []>;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_X86_CMakeLists_txt,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_CMakeLists_txt,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add a clang pass that identifies potential ROP gadgets and replaces ROP
|
||||
friendly instructions with safe alternatives. This initial commit fixes
|
||||
|
@ -10,7 +10,7 @@ $OpenBSD: patch-lib_Target_X86_CMakeLists_txt,v 1.4 2021/05/18 03:35:07 rsadowsk
|
|||
Index: lib/Target/X86/CMakeLists.txt
|
||||
--- lib/Target/X86/CMakeLists.txt.orig
|
||||
+++ lib/Target/X86/CMakeLists.txt
|
||||
@@ -34,6 +34,7 @@ set(sources
|
||||
@@ -42,6 +42,7 @@ set(sources
|
||||
X86ExpandPseudo.cpp
|
||||
X86FastISel.cpp
|
||||
X86FixupBWInsts.cpp
|
||||
|
@ -18,7 +18,7 @@ Index: lib/Target/X86/CMakeLists.txt
|
|||
X86FixupLEAs.cpp
|
||||
X86AvoidStoreForwardingBlocks.cpp
|
||||
X86FixupSetCC.cpp
|
||||
@@ -62,6 +63,7 @@ set(sources
|
||||
@@ -71,6 +72,7 @@ set(sources
|
||||
X86PartialReduction.cpp
|
||||
X86RegisterBankInfo.cpp
|
||||
X86RegisterInfo.cpp
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
$OpenBSD: patch-lib_Target_X86_MCTargetDesc_X86AsmBackend_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
|
||||
trapsleds
|
||||
|
||||
Index: lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
|
||||
--- lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp.orig
|
||||
+++ lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
|
||||
@@ -1071,57 +1071,23 @@ void X86AsmBackend::finishLayout(MCAssembler const &As
|
||||
/// bytes.
|
||||
/// \return - true on success, false on failure
|
||||
bool X86AsmBackend::writeNopData(raw_ostream &OS, uint64_t Count) const {
|
||||
- static const char Nops[10][11] = {
|
||||
- // nop
|
||||
- "\x90",
|
||||
- // xchg %ax,%ax
|
||||
- "\x66\x90",
|
||||
- // nopl (%[re]ax)
|
||||
- "\x0f\x1f\x00",
|
||||
- // nopl 0(%[re]ax)
|
||||
- "\x0f\x1f\x40\x00",
|
||||
- // nopl 0(%[re]ax,%[re]ax,1)
|
||||
- "\x0f\x1f\x44\x00\x00",
|
||||
- // nopw 0(%[re]ax,%[re]ax,1)
|
||||
- "\x66\x0f\x1f\x44\x00\x00",
|
||||
- // nopl 0L(%[re]ax)
|
||||
- "\x0f\x1f\x80\x00\x00\x00\x00",
|
||||
- // nopl 0L(%[re]ax,%[re]ax,1)
|
||||
- "\x0f\x1f\x84\x00\x00\x00\x00\x00",
|
||||
- // nopw 0L(%[re]ax,%[re]ax,1)
|
||||
- "\x66\x0f\x1f\x84\x00\x00\x00\x00\x00",
|
||||
- // nopw %cs:0L(%[re]ax,%[re]ax,1)
|
||||
- "\x66\x2e\x0f\x1f\x84\x00\x00\x00\x00\x00",
|
||||
- };
|
||||
|
||||
- // This CPU doesn't support long nops. If needed add more.
|
||||
- // FIXME: We could generated something better than plain 0x90.
|
||||
- if (!STI.hasFeature(X86::FeatureNOPL) && !STI.hasFeature(X86::Mode64Bit)) {
|
||||
- for (uint64_t i = 0; i < Count; ++i)
|
||||
- OS << '\x90';
|
||||
- return true;
|
||||
- }
|
||||
-
|
||||
- // 15-bytes is the longest single NOP instruction, but 10-bytes is
|
||||
- // commonly the longest that can be efficiently decoded.
|
||||
- uint64_t MaxNopLength = 10;
|
||||
- if (STI.getFeatureBits()[X86::FeatureFast7ByteNOP])
|
||||
- MaxNopLength = 7;
|
||||
- else if (STI.getFeatureBits()[X86::FeatureFast15ByteNOP])
|
||||
- MaxNopLength = 15;
|
||||
- else if (STI.getFeatureBits()[X86::FeatureFast11ByteNOP])
|
||||
- MaxNopLength = 11;
|
||||
-
|
||||
- // Emit as many MaxNopLength NOPs as needed, then emit a NOP of the remaining
|
||||
- // length.
|
||||
+ // Write 1 or 2 byte NOP sequences, or a longer trapsled, until
|
||||
+ // we have written Count bytes
|
||||
do {
|
||||
- const uint8_t ThisNopLength = (uint8_t) std::min(Count, MaxNopLength);
|
||||
- const uint8_t Prefixes = ThisNopLength <= 10 ? 0 : ThisNopLength - 10;
|
||||
- for (uint8_t i = 0; i < Prefixes; i++)
|
||||
- OS << '\x66';
|
||||
- const uint8_t Rest = ThisNopLength - Prefixes;
|
||||
- if (Rest != 0)
|
||||
- OS.write(Nops[Rest - 1], Rest);
|
||||
+ const uint8_t ThisNopLength = (uint8_t) std::min(Count, (uint64_t)127);
|
||||
+ switch (ThisNopLength) {
|
||||
+ case 0: break;
|
||||
+ case 1: OS << '\x90';
|
||||
+ break;
|
||||
+ case 2: OS << '\x66';
|
||||
+ OS << '\x90';
|
||||
+ break;
|
||||
+ default: OS << '\xEB';
|
||||
+ OS << (uint8_t)(ThisNopLength - 2);
|
||||
+ for(uint8_t i = 2; i < ThisNopLength; ++i)
|
||||
+ OS << '\xCC';
|
||||
+ }
|
||||
Count -= ThisNopLength;
|
||||
} while (Count != 0);
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_X86_X86AsmPrinter_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_X86AsmPrinter_h,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Use int3 trap padding between functions instead of trapsleds with a leading jump.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_X86_X86FixupGadgets_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_X86FixupGadgets_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add a clang pass that identifies potential ROP gadgets and replaces ROP
|
||||
friendly instructions with safe alternatives. This initial commit fixes
|
||||
|
@ -6,11 +6,12 @@ $OpenBSD: patch-lib_Target_X86_X86FixupGadgets_cpp,v 1.4 2021/05/18 03:35:07 rsa
|
|||
Additional problematic instructions can be fixed incrementally using
|
||||
this framework.
|
||||
- Improve the X86FixupGadgets pass
|
||||
- Optimize gadget fixups for MOV instructions
|
||||
|
||||
Index: lib/Target/X86/X86FixupGadgets.cpp
|
||||
--- lib/Target/X86/X86FixupGadgets.cpp.orig
|
||||
+++ lib/Target/X86/X86FixupGadgets.cpp
|
||||
@@ -0,0 +1,670 @@
|
||||
@@ -0,0 +1,708 @@
|
||||
+//===-- X86FixupGadgets.cpp - Fixup Instructions that make ROP Gadgets ----===//
|
||||
+//
|
||||
+// The LLVM Compiler Infrastructure
|
||||
|
@ -103,6 +104,7 @@ Index: lib/Target/X86/X86FixupGadgets.cpp
|
|||
+ unsigned getEquivalentRegForReg(unsigned oreg, unsigned nreg) const;
|
||||
+ bool hasImplicitUseOrDef(const MachineInstr &MI, unsigned Reg1,
|
||||
+ unsigned Reg2) const;
|
||||
+ bool fixupWithoutExchange(MachineInstr &MI);
|
||||
+
|
||||
+ bool fixupInstruction(MachineFunction &MF, MachineBasicBlock &MBB,
|
||||
+ MachineInstr &MI, struct FixupInfo Info);
|
||||
|
@ -576,6 +578,38 @@ Index: lib/Target/X86/X86FixupGadgets.cpp
|
|||
+ return false;
|
||||
+}
|
||||
+
|
||||
+bool FixupGadgetsPass::fixupWithoutExchange(MachineInstr &MI) {
|
||||
+ switch (MI.getOpcode()) {
|
||||
+ case X86::MOV8rr_REV:
|
||||
+ MI.setDesc(TII->get(X86::MOV8rr));
|
||||
+ break;
|
||||
+ case X86::MOV16rr_REV:
|
||||
+ MI.setDesc(TII->get(X86::MOV16rr));
|
||||
+ break;
|
||||
+ case X86::MOV32rr_REV:
|
||||
+ MI.setDesc(TII->get(X86::MOV32rr));
|
||||
+ break;
|
||||
+ case X86::MOV64rr_REV:
|
||||
+ MI.setDesc(TII->get(X86::MOV64rr));
|
||||
+ break;
|
||||
+ case X86::MOV8rr:
|
||||
+ MI.setDesc(TII->get(X86::MOV8rr_REV));
|
||||
+ break;
|
||||
+ case X86::MOV16rr:
|
||||
+ MI.setDesc(TII->get(X86::MOV16rr_REV));
|
||||
+ break;
|
||||
+ case X86::MOV32rr:
|
||||
+ MI.setDesc(TII->get(X86::MOV32rr_REV));
|
||||
+ break;
|
||||
+ case X86::MOV64rr:
|
||||
+ MI.setDesc(TII->get(X86::MOV64rr_REV));
|
||||
+ break;
|
||||
+ default:
|
||||
+ return false;
|
||||
+ }
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+bool FixupGadgetsPass::fixupInstruction(MachineFunction &MF,
|
||||
+ MachineBasicBlock &MBB,
|
||||
+ MachineInstr &MI, FixupInfo Info) {
|
||||
|
@ -623,6 +657,11 @@ Index: lib/Target/X86/X86FixupGadgets.cpp
|
|||
+ SwapReg2 = treg;
|
||||
+ }
|
||||
+
|
||||
+ // Check for specific instructions we can fix without the xchg dance
|
||||
+ if (fixupWithoutExchange(MI)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ // Swap the two registers to start
|
||||
+ BuildMI(MBB, MI, DL, TII->get(XCHG))
|
||||
+ .addReg(SwapReg1, RegState::Define)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_X86_X86FrameLowering_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_X86FrameLowering_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add RETGUARD to clang for amd64. This security mechanism uses per-function
|
||||
random cookies to protect access to function return instructions, with the
|
||||
|
@ -31,7 +31,7 @@ Index: lib/Target/X86/X86FrameLowering.cpp
|
|||
#include "X86Subtarget.h"
|
||||
#include "X86TargetMachine.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
@@ -45,7 +46,7 @@ X86FrameLowering::X86FrameLowering(const X86Subtarget
|
||||
@@ -46,7 +47,7 @@ X86FrameLowering::X86FrameLowering(const X86Subtarget
|
||||
MaybeAlign StackAlignOverride)
|
||||
: TargetFrameLowering(StackGrowsDown, StackAlignOverride.valueOrOne(),
|
||||
STI.is64Bit() ? -8 : -4),
|
||||
|
@ -40,7 +40,7 @@ Index: lib/Target/X86/X86FrameLowering.cpp
|
|||
// Cache a bunch of frame-related predicates for this subtarget.
|
||||
SlotSize = TRI->getSlotSize();
|
||||
Is64Bit = STI.is64Bit();
|
||||
@@ -53,6 +54,7 @@ X86FrameLowering::X86FrameLowering(const X86Subtarget
|
||||
@@ -54,6 +55,7 @@ X86FrameLowering::X86FrameLowering(const X86Subtarget
|
||||
// standard x86_64 and NaCl use 64-bit frame/stack pointers, x32 - 32-bit.
|
||||
Uses64BitFramePtr = STI.isTarget64BitLP64() || STI.isTargetNaCl64();
|
||||
StackPtr = TRI->getStackRegister();
|
||||
|
@ -48,7 +48,7 @@ Index: lib/Target/X86/X86FrameLowering.cpp
|
|||
}
|
||||
|
||||
bool X86FrameLowering::hasReservedCallFrame(const MachineFunction &MF) const {
|
||||
@@ -98,7 +100,8 @@ bool X86FrameLowering::hasFP(const MachineFunction &MF
|
||||
@@ -99,7 +101,8 @@ bool X86FrameLowering::hasFP(const MachineFunction &MF
|
||||
MF.getInfo<X86MachineFunctionInfo>()->hasPreallocatedCall() ||
|
||||
MF.callsUnwindInit() || MF.hasEHFunclets() || MF.callsEHReturn() ||
|
||||
MFI.hasStackMap() || MFI.hasPatchPoint() ||
|
||||
|
@ -58,7 +58,7 @@ Index: lib/Target/X86/X86FrameLowering.cpp
|
|||
}
|
||||
|
||||
static unsigned getSUBriOpcode(bool IsLP64, int64_t Imm) {
|
||||
@@ -1243,6 +1246,24 @@ void X86FrameLowering::BuildStackAlignAND(MachineBasic
|
||||
@@ -1213,6 +1216,24 @@ void X86FrameLowering::BuildStackAlignAND(MachineBasic
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,9 +83,9 @@ Index: lib/Target/X86/X86FrameLowering.cpp
|
|||
bool X86FrameLowering::has128ByteRedZone(const MachineFunction& MF) const {
|
||||
// x86-64 (non Win64) has a 128 byte red zone which is guaranteed not to be
|
||||
// clobbered by any interrupt handler.
|
||||
@@ -1517,6 +1538,43 @@ void X86FrameLowering::emitPrologue(MachineFunction &M
|
||||
nullptr, DwarfFramePtr));
|
||||
}
|
||||
@@ -1537,6 +1558,43 @@ void X86FrameLowering::emitPrologue(MachineFunction &M
|
||||
.addReg(StackPtr)
|
||||
.setMIFlag(MachineInstr::FrameSetup);
|
||||
|
||||
+ if (SaveArgs && !Fn.arg_empty()) {
|
||||
+ ArrayRef<MCPhysReg> GPRs =
|
||||
|
@ -119,20 +119,21 @@ Index: lib/Target/X86/X86FrameLowering.cpp
|
|||
+ SaveSize += SlotSize;
|
||||
+ }
|
||||
+
|
||||
+ //dlg StackSize -= SaveSize;
|
||||
+ //dlg StackSize -= SaveSize;
|
||||
+ //dlg MFI.setStackSize(StackSize);
|
||||
+ X86FI->setSaveArgSize(SaveSize);
|
||||
+ }
|
||||
+
|
||||
if (NeedsWinFPO) {
|
||||
// .cv_fpo_setframe $FramePtr
|
||||
HasWinCFI = true;
|
||||
@@ -2009,10 +2067,16 @@ void X86FrameLowering::emitEpilogue(MachineFunction &M
|
||||
// AfterPop is the position to insert .cfi_restore.
|
||||
MachineBasicBlock::iterator AfterPop = MBBI;
|
||||
if (HasFP) {
|
||||
if (NeedsDwarfCFI) {
|
||||
// Mark effective beginning of when frame pointer becomes valid.
|
||||
// Define the current CFA to use the EBP/RBP register.
|
||||
@@ -2047,10 +2105,17 @@ void X86FrameLowering::emitEpilogue(MachineFunction &M
|
||||
int Offset = 16 + mergeSPUpdates(MBB, MBBI, true);
|
||||
emitSPUpdate(MBB, MBBI, DL, Offset, /*InEpilogue*/true);
|
||||
}
|
||||
- // Pop EBP.
|
||||
- BuildMI(MBB, MBBI, DL, TII.get(Is64Bit ? X86::POP64r : X86::POP32r),
|
||||
+
|
||||
+ if (X86FI->getSaveArgSize()) {
|
||||
+ // LEAVE is effectively mov rbp,rsp; pop rbp
|
||||
+ BuildMI(MBB, MBBI, DL, TII.get(X86::LEAVE64))
|
||||
|
@ -143,20 +144,18 @@ Index: lib/Target/X86/X86FrameLowering.cpp
|
|||
MachineFramePtr)
|
||||
.setMIFlag(MachineInstr::FrameDestroy);
|
||||
+ }
|
||||
if (NeedsDwarfCFI) {
|
||||
unsigned DwarfStackPtr =
|
||||
TRI->getDwarfRegNum(Is64Bit ? X86::RSP : X86::ESP, true);
|
||||
@@ -2037,7 +2101,8 @@ void X86FrameLowering::emitEpilogue(MachineFunction &M
|
||||
|
||||
// We need to reset FP to its untagged state on return. Bit 60 is currently
|
||||
// used to show the presence of an extended frame.
|
||||
@@ -2087,6 +2152,7 @@ void X86FrameLowering::emitEpilogue(MachineFunction &M
|
||||
if (Opc != X86::DBG_VALUE && !PI->isTerminator()) {
|
||||
if ((Opc != X86::POP32r || !PI->getFlag(MachineInstr::FrameDestroy)) &&
|
||||
- (Opc != X86::POP64r || !PI->getFlag(MachineInstr::FrameDestroy)))
|
||||
+ (Opc != X86::POP64r || !PI->getFlag(MachineInstr::FrameDestroy)) &&
|
||||
+ (Opc != X86::LEAVE64 || !PI->getFlag(MachineInstr::FrameDestroy)))
|
||||
(Opc != X86::POP64r || !PI->getFlag(MachineInstr::FrameDestroy)) &&
|
||||
+ (Opc != X86::LEAVE64 || !PI->getFlag(MachineInstr::FrameDestroy)) &&
|
||||
(Opc != X86::BTR64ri8 || !PI->getFlag(MachineInstr::FrameDestroy)) &&
|
||||
(Opc != X86::ADD64ri8 || !PI->getFlag(MachineInstr::FrameDestroy)))
|
||||
break;
|
||||
FirstCSPop = PI;
|
||||
}
|
||||
@@ -2202,6 +2267,8 @@ int X86FrameLowering::getFrameIndexReference(const Mac
|
||||
@@ -2266,6 +2332,8 @@ StackOffset X86FrameLowering::getFrameIndexReference(c
|
||||
"FPDelta isn't aligned per the Win64 ABI!");
|
||||
}
|
||||
|
||||
|
@ -165,7 +164,7 @@ Index: lib/Target/X86/X86FrameLowering.cpp
|
|||
|
||||
if (TRI->hasBasePointer(MF)) {
|
||||
assert(HasFP && "VLAs and dynamic stack realign, but no FP?!");
|
||||
@@ -3603,6 +3670,10 @@ void X86FrameLowering::processFunctionBeforeFrameFinal
|
||||
@@ -3699,6 +3767,10 @@ void X86FrameLowering::adjustFrameForMsvcCxxEh(Machine
|
||||
addFrameReference(BuildMI(MBB, MBBI, DL, TII.get(X86::MOV64mi32)),
|
||||
UnwindHelpFI)
|
||||
.addImm(-2);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_X86_X86FrameLowering_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_X86FrameLowering_h,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add RETGUARD to clang for amd64. This security mechanism uses per-function
|
||||
random cookies to protect access to function return instructions, with the
|
||||
|
@ -29,9 +29,9 @@ Index: lib/Target/X86/X86FrameLowering.h
|
|||
|
||||
+#include "X86ReturnProtectorLowering.h"
|
||||
#include "llvm/CodeGen/TargetFrameLowering.h"
|
||||
#include "llvm/Support/TypeSize.h"
|
||||
|
||||
namespace llvm {
|
||||
@@ -22,6 +23,7 @@ class MCCFIInstruction;
|
||||
@@ -23,6 +24,7 @@ class MCCFIInstruction;
|
||||
class X86InstrInfo;
|
||||
class X86Subtarget;
|
||||
class X86RegisterInfo;
|
||||
|
@ -39,7 +39,7 @@ Index: lib/Target/X86/X86FrameLowering.h
|
|||
|
||||
class X86FrameLowering : public TargetFrameLowering {
|
||||
public:
|
||||
@@ -32,7 +34,10 @@ class X86FrameLowering : public TargetFrameLowering {
|
||||
@@ -33,7 +35,10 @@ class X86FrameLowering : public TargetFrameLowering {
|
||||
const X86Subtarget &STI;
|
||||
const X86InstrInfo &TII;
|
||||
const X86RegisterInfo *TRI;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_X86_X86InstrCompiler_td,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_X86InstrCompiler_td,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add RETGUARD to clang for amd64. This security mechanism uses per-function
|
||||
random cookies to protect access to function return instructions, with the
|
||||
|
@ -22,7 +22,7 @@ $OpenBSD: patch-lib_Target_X86_X86InstrCompiler_td,v 1.4 2021/05/18 03:35:07 rsa
|
|||
Index: lib/Target/X86/X86InstrCompiler.td
|
||||
--- lib/Target/X86/X86InstrCompiler.td.orig
|
||||
+++ lib/Target/X86/X86InstrCompiler.td
|
||||
@@ -268,6 +268,25 @@ def MORESTACK_RET_RESTORE_R10 : I<0, Pseudo, (outs), (
|
||||
@@ -277,6 +277,25 @@ def MORESTACK_RET_RESTORE_R10 : I<0, Pseudo, (outs), (
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -36,11 +36,11 @@ Index: lib/Target/X86/X86InstrCompiler.td
|
|||
+// used as a return value. When emitted as a split BB, the single byte
|
||||
+// register would sometimes be widened to 4 bytes, which would corrupt
|
||||
+// the return value (ie mov %ecx, %eax instead of mov %cl, %al).
|
||||
+let isCodeGenOnly = 1, Uses = [EFLAGS] in {
|
||||
+let isCodeGenOnly = 1, hasNoSchedulingInfo = 1, Uses = [EFLAGS] in {
|
||||
+def RETGUARD_JMP_TRAP: I<0, Pseudo, (outs), (ins), "", []>;
|
||||
+}
|
||||
+
|
||||
+let isCodeGenOnly = 1 in {
|
||||
+let isCodeGenOnly = 1, hasNoSchedulingInfo = 1 in {
|
||||
+def JMP_TRAP: I<0, Pseudo, (outs), (ins), "", []>;
|
||||
+}
|
||||
+
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_X86_X86MCInstLower_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_X86MCInstLower_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add RETGUARD to clang for amd64. This security mechanism uses per-function
|
||||
random cookies to protect access to function return instructions, with the
|
||||
|
@ -25,7 +25,7 @@ $OpenBSD: patch-lib_Target_X86_X86MCInstLower_cpp,v 1.4 2021/05/18 03:35:07 rsad
|
|||
Index: lib/Target/X86/X86MCInstLower.cpp
|
||||
--- lib/Target/X86/X86MCInstLower.cpp.orig
|
||||
+++ lib/Target/X86/X86MCInstLower.cpp
|
||||
@@ -2566,6 +2566,50 @@ void X86AsmPrinter::emitInstruction(const MachineInstr
|
||||
@@ -2570,6 +2570,50 @@ void X86AsmPrinter::emitInstruction(const MachineInstr
|
||||
MCInstBuilder(X86::MOV64rr).addReg(X86::R10).addReg(X86::RAX));
|
||||
return;
|
||||
|
||||
|
@ -76,7 +76,7 @@ Index: lib/Target/X86/X86MCInstLower.cpp
|
|||
case X86::SEH_PushReg:
|
||||
case X86::SEH_SaveReg:
|
||||
case X86::SEH_SaveXMM:
|
||||
@@ -2615,4 +2659,10 @@ void X86AsmPrinter::emitInstruction(const MachineInstr
|
||||
@@ -2628,4 +2672,10 @@ void X86AsmPrinter::emitInstruction(const MachineInstr
|
||||
}
|
||||
|
||||
EmitAndCountInstruction(TmpInst);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_X86_X86MachineFunctionInfo_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_X86MachineFunctionInfo_h,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
implement -msave-args in clang/llvm, like the sun did for gcc
|
||||
|
||||
|
@ -15,7 +15,7 @@ Index: lib/Target/X86/X86MachineFunctionInfo.h
|
|||
/// BytesToPopOnReturn - Number of bytes function pops on return (in addition
|
||||
/// to the space used by the return address).
|
||||
/// Used on windows platform for stdcall & fastcall name decoration
|
||||
@@ -138,6 +141,9 @@ class X86MachineFunctionInfo : public MachineFunctionI
|
||||
@@ -145,6 +148,9 @@ class X86MachineFunctionInfo : public MachineFunctionI
|
||||
|
||||
unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
|
||||
void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_X86_X86RegisterInfo_td,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_X86RegisterInfo_td,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- The compiler is generally free to allocate general purpose registers in
|
||||
whatever order it chooses. Reasons for choosing one register before another
|
||||
|
@ -23,7 +23,7 @@ $OpenBSD: patch-lib_Target_X86_X86RegisterInfo_td,v 1.4 2021/05/18 03:35:07 rsad
|
|||
Index: lib/Target/X86/X86RegisterInfo.td
|
||||
--- lib/Target/X86/X86RegisterInfo.td.orig
|
||||
+++ lib/Target/X86/X86RegisterInfo.td
|
||||
@@ -421,8 +421,8 @@ def GRH16 : RegisterClass<"X86", [i16], 16,
|
||||
@@ -424,8 +424,8 @@ def GRH16 : RegisterClass<"X86", [i16], 16,
|
||||
R15WH)>;
|
||||
|
||||
def GR32 : RegisterClass<"X86", [i32], 32,
|
||||
|
@ -34,7 +34,7 @@ Index: lib/Target/X86/X86RegisterInfo.td
|
|||
|
||||
// GR64 - 64-bit GPRs. This oddly includes RIP, which isn't accurate, since
|
||||
// RIP isn't really a register and it can't be used anywhere except in an
|
||||
@@ -431,7 +431,7 @@ def GR32 : RegisterClass<"X86", [i32], 32,
|
||||
@@ -434,7 +434,7 @@ def GR32 : RegisterClass<"X86", [i32], 32,
|
||||
// tests because of the inclusion of RIP in this register class.
|
||||
def GR64 : RegisterClass<"X86", [i64], 64,
|
||||
(add RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_X86_X86ReturnProtectorLowering_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_X86ReturnProtectorLowering_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Refactor retguard to make adding additional arches easier.
|
||||
- Do not store the retguard cookie in frame in leaf functions if possible.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_X86_X86ReturnProtectorLowering_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_X86ReturnProtectorLowering_h,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Refactor retguard to make adding additional arches easier.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_X86_X86Subtarget_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_X86Subtarget_h,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- implement -msave-args in clang/llvm, like the sun did for gcc
|
||||
- Turn on -mretpoline by default in clang on amd64.
|
||||
|
@ -6,9 +6,9 @@ $OpenBSD: patch-lib_Target_X86_X86Subtarget_h,v 1.4 2021/05/18 03:35:07 rsadowsk
|
|||
Index: lib/Target/X86/X86Subtarget.h
|
||||
--- lib/Target/X86/X86Subtarget.h.orig
|
||||
+++ lib/Target/X86/X86Subtarget.h
|
||||
@@ -459,6 +459,9 @@ class X86Subtarget final : public X86GenSubtargetInfo
|
||||
/// entry to the function and which must be maintained by every function.
|
||||
Align stackAlignment = Align(4);
|
||||
@@ -481,6 +481,9 @@ class X86Subtarget final : public X86GenSubtargetInfo
|
||||
|
||||
Align TileConfigAlignment = Align(4);
|
||||
|
||||
+ /// Whether function prologues should save register arguments on the stack.
|
||||
+ bool SaveArgs = false;
|
||||
|
@ -16,16 +16,16 @@ Index: lib/Target/X86/X86Subtarget.h
|
|||
/// Max. memset / memcpy size that is turned into rep/movs, rep/stos ops.
|
||||
///
|
||||
// FIXME: this is a known good value for Yonah. How about others?
|
||||
@@ -549,6 +552,8 @@ class X86Subtarget final : public X86GenSubtargetInfo
|
||||
return &getInstrInfo()->getRegisterInfo();
|
||||
}
|
||||
@@ -567,6 +570,8 @@ class X86Subtarget final : public X86GenSubtargetInfo
|
||||
unsigned getTileConfigSize() const { return 64; }
|
||||
Align getTileConfigAlignment() const { return TileConfigAlignment; }
|
||||
|
||||
+ bool getSaveArgs() const { return SaveArgs; }
|
||||
+
|
||||
/// Returns the minimum alignment known to hold of the
|
||||
/// stack frame on entry to the function and which must be maintained by every
|
||||
/// function for this subtarget.
|
||||
@@ -809,6 +814,7 @@ class X86Subtarget final : public X86GenSubtargetInfo
|
||||
@@ -832,6 +837,7 @@ class X86Subtarget final : public X86GenSubtargetInfo
|
||||
|
||||
bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
|
||||
bool isTargetFreeBSD() const { return TargetTriple.isOSFreeBSD(); }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_X86_X86TargetMachine_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_X86TargetMachine_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Add a clang pass that identifies potential ROP gadgets and replaces ROP
|
||||
friendly instructions with safe alternatives. This initial commit fixes
|
||||
|
@ -9,7 +9,7 @@ this framework.
|
|||
Index: lib/Target/X86/X86TargetMachine.cpp
|
||||
--- lib/Target/X86/X86TargetMachine.cpp.orig
|
||||
+++ lib/Target/X86/X86TargetMachine.cpp
|
||||
@@ -517,6 +517,7 @@ void X86PassConfig::addPreEmitPass() {
|
||||
@@ -546,6 +546,7 @@ void X86PassConfig::addPreEmitPass() {
|
||||
addPass(createX86EvexToVexInsts());
|
||||
addPass(createX86DiscriminateMemOpsPass());
|
||||
addPass(createX86InsertPrefetchPass());
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Target_X86_X86_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_X86_h,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Add a clang pass that identifies potential ROP gadgets and replaces ROP
|
||||
friendly instructions with safe alternatives. This initial commit fixes
|
||||
|
@ -9,7 +9,7 @@ this framework.
|
|||
Index: lib/Target/X86/X86.h
|
||||
--- lib/Target/X86/X86.h.orig
|
||||
+++ lib/Target/X86/X86.h
|
||||
@@ -113,6 +113,10 @@ FunctionPass *createX86FixupBWInsts();
|
||||
@@ -122,6 +122,10 @@ FunctionPass *createX86FixupBWInsts();
|
||||
/// to another, when profitable.
|
||||
FunctionPass *createX86DomainReassignmentPass();
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
$OpenBSD: patch-lib_Target_X86_X86_td,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Target_X86_X86_td,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
implement -msave-args in clang/llvm, like the sun did for gcc
|
||||
|
||||
Index: lib/Target/X86/X86.td
|
||||
--- lib/Target/X86/X86.td.orig
|
||||
+++ lib/Target/X86/X86.td
|
||||
@@ -313,6 +313,9 @@ def FeatureLZCNTFalseDeps : SubtargetFeature<"false-de
|
||||
@@ -321,6 +321,9 @@ def FeatureLZCNTFalseDeps : SubtargetFeature<"false-de
|
||||
"LZCNT/TZCNT have a false dependency on dest register">;
|
||||
def FeaturePCONFIG : SubtargetFeature<"pconfig", "HasPCONFIG", "true",
|
||||
"platform configuration instruction">;
|
||||
|
@ -14,4 +14,4 @@ Index: lib/Target/X86/X86.td
|
|||
+ "Save register arguments on the stack.">;
|
||||
// On recent X86 (port bound) processors, its preferable to combine to a single shuffle
|
||||
// using a variable mask over multiple fixed shuffles.
|
||||
def FeatureFastVariableShuffle
|
||||
def FeatureFastVariableCrossLaneShuffle
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-lib_Transforms_Scalar_LoopIdiomRecognize_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-lib_Transforms_Scalar_LoopIdiomRecognize_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Disable loop idiom recognition for _libc_memset and _libc_memcpy. These are
|
||||
the internal names we use in libc for memset and memcpy and having the
|
||||
|
@ -8,7 +8,7 @@ recursion.
|
|||
Index: lib/Transforms/Scalar/LoopIdiomRecognize.cpp
|
||||
--- lib/Transforms/Scalar/LoopIdiomRecognize.cpp.orig
|
||||
+++ lib/Transforms/Scalar/LoopIdiomRecognize.cpp
|
||||
@@ -312,6 +312,8 @@ bool LoopIdiomRecognize::runOnLoop(Loop *L) {
|
||||
@@ -367,6 +367,8 @@ bool LoopIdiomRecognize::runOnLoop(Loop *L) {
|
||||
StringRef Name = L->getHeader()->getParent()->getName();
|
||||
if (Name == "memset" || Name == "memcpy")
|
||||
return false;
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
$OpenBSD: patch-lib_Transforms_Scalar_SCCP_cpp,v 1.1 2021/05/18 03:35:07 rsadowski Exp $
|
||||
|
||||
[SCCP] Avoid modifying AdditionalUsers while iterating over it
|
||||
https://reviews.llvm.org/rG6abb92f2103a58d097620b4410054c5bb18c48ec
|
||||
|
||||
Index: lib/Transforms/Scalar/SCCP.cpp
|
||||
--- lib/Transforms/Scalar/SCCP.cpp.orig
|
||||
+++ lib/Transforms/Scalar/SCCP.cpp
|
||||
@@ -541,9 +541,14 @@ class SCCPSolver : public InstVisitor<SCCPSolver> { (p
|
||||
|
||||
auto Iter = AdditionalUsers.find(I);
|
||||
if (Iter != AdditionalUsers.end()) {
|
||||
+ // Copy additional users before notifying them of changes, because new
|
||||
+ // users may be added, potentially invalidating the iterator.
|
||||
+ SmallVector<Instruction *, 2> ToNotify;
|
||||
for (User *U : Iter->second)
|
||||
if (auto *UI = dyn_cast<Instruction>(U))
|
||||
- OperandChangedState(UI);
|
||||
+ ToNotify.push_back(UI);
|
||||
+ for (Instruction *UI : ToNotify)
|
||||
+ OperandChangedState(UI);
|
||||
}
|
||||
}
|
||||
void handleCallOverdefined(CallBase &CB);
|
|
@ -1,18 +0,0 @@
|
|||
$OpenBSD: patch-lib_WindowsManifest_CMakeLists_txt,v 1.3 2021/05/18 03:35:07 rsadowski Exp $
|
||||
|
||||
For upstream:
|
||||
bogus dep on all headers in ${Backtrace_INCLUDE_DIRS} ie /usr/local/include.
|
||||
|
||||
Index: lib/WindowsManifest/CMakeLists.txt
|
||||
--- lib/WindowsManifest/CMakeLists.txt.orig
|
||||
+++ lib/WindowsManifest/CMakeLists.txt
|
||||
@@ -2,8 +2,7 @@ add_llvm_component_library(LLVMWindowsManifest
|
||||
WindowsManifestMerger.cpp
|
||||
|
||||
ADDITIONAL_HEADER_DIRS
|
||||
- ${LLVM_MAIN_INCLUDE_DIR}/llvm/WindowsManifest
|
||||
- ${Backtrace_INCLUDE_DIRS})
|
||||
+ ${LLVM_MAIN_INCLUDE_DIR}/llvm/WindowsManifest)
|
||||
|
||||
if(LIBXML2_LIBRARIES)
|
||||
target_link_libraries(LLVMWindowsManifest PUBLIC ${LIBXML2_LIBRARIES})
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-tools_clang_include_clang_AST_FormatString_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_include_clang_AST_FormatString_h,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- The %b printf extension in the kernel is not fixed to a int type. On sparc64
|
||||
there are various %llb formats. Adjust the code to handle the length specifiers
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-tools_clang_include_clang_Basic_CodeGenOptions_def,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_include_clang_Basic_CodeGenOptions_def,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add RETGUARD to clang for amd64. This security mechanism uses per-function
|
||||
random cookies to protect access to function return instructions, with the
|
||||
|
@ -22,7 +22,7 @@ $OpenBSD: patch-tools_clang_include_clang_Basic_CodeGenOptions_def,v 1.4 2021/05
|
|||
Index: tools/clang/include/clang/Basic/CodeGenOptions.def
|
||||
--- tools/clang/include/clang/Basic/CodeGenOptions.def.orig
|
||||
+++ tools/clang/include/clang/Basic/CodeGenOptions.def
|
||||
@@ -312,6 +312,9 @@ VALUE_CODEGENOPT(SmallDataLimit, 32, 0)
|
||||
@@ -340,6 +340,9 @@ VALUE_CODEGENOPT(SmallDataLimit, 32, 0)
|
||||
/// The lower bound for a buffer to be considered for stack protection.
|
||||
VALUE_CODEGENOPT(SSPBufferSize, 32, 0)
|
||||
|
||||
|
@ -30,5 +30,5 @@ Index: tools/clang/include/clang/Basic/CodeGenOptions.def
|
|||
+CODEGENOPT(ReturnProtector, 1, 0)
|
||||
+
|
||||
/// The kind of generated debug info.
|
||||
ENUM_CODEGENOPT(DebugInfo, codegenoptions::DebugInfoKind, 3, codegenoptions::NoDebugInfo)
|
||||
ENUM_CODEGENOPT(DebugInfo, codegenoptions::DebugInfoKind, 4, codegenoptions::NoDebugInfo)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-tools_clang_include_clang_Basic_DiagnosticSemaKinds_td,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_include_clang_Basic_DiagnosticSemaKinds_td,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Disable -Waddress-of-packed-member by default.
|
||||
|
||||
|
@ -9,24 +9,36 @@ false positives right now.
|
|||
|
||||
base gcc does the same.
|
||||
|
||||
- Add a new warning for %n format specifier usage in printf(3) family functions
|
||||
|
||||
Index: tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
|
||||
--- tools/clang/include/clang/Basic/DiagnosticSemaKinds.td.orig
|
||||
+++ tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
|
||||
@@ -6440,7 +6440,7 @@ def warn_pointer_indirection_from_incompatible_type :
|
||||
@@ -6768,7 +6768,7 @@ def warn_pointer_indirection_from_incompatible_type :
|
||||
InGroup<UndefinedReinterpretCast>, DefaultIgnore;
|
||||
def warn_taking_address_of_packed_member : Warning<
|
||||
"taking address of packed member %0 of class or structure %q1 may result in an unaligned pointer value">,
|
||||
- InGroup<DiagGroup<"address-of-packed-member">>;
|
||||
+ InGroup<DiagGroup<"address-of-packed-member">>, DefaultIgnore;
|
||||
|
||||
def err_objc_object_assignment : Error<
|
||||
"cannot assign to class object (%0 invalid)">;
|
||||
@@ -7607,7 +7607,7 @@ def ext_typecheck_convert_incompatible_pointer_sign :
|
||||
"sending to parameter of different type}0,1"
|
||||
def warn_param_mismatched_alignment : Warning<
|
||||
"passing %0-byte aligned argument to %1-byte aligned parameter %2 of %3 may result in an unaligned pointer access">,
|
||||
InGroup<DiagGroup<"align-mismatch">>;
|
||||
@@ -7980,7 +7980,7 @@ def ext_typecheck_convert_incompatible_pointer_sign :
|
||||
"|%diff{casting $ to type $|casting between types}0,1}2"
|
||||
" converts between pointers to integer types with different sign">,
|
||||
" converts between pointers to integer types %select{with different sign|"
|
||||
"where one is of the unique plain 'char' type and the other is not}3">,
|
||||
- InGroup<DiagGroup<"pointer-sign">>;
|
||||
+ InGroup<DiagGroup<"pointer-sign">>, DefaultIgnore;
|
||||
def err_typecheck_convert_incompatible_pointer_sign : Error<
|
||||
"%select{%diff{assigning to $ from $|assigning to different types}0,1"
|
||||
"|%diff{passing $ to parameter of type $|"
|
||||
def err_typecheck_convert_incompatible_pointer_sign :
|
||||
Error<ext_typecheck_convert_incompatible_pointer_sign.Text>;
|
||||
def ext_typecheck_convert_incompatible_pointer : ExtWarn<
|
||||
@@ -9512,6 +9512,9 @@ def err_os_log_argument_too_big : Error<
|
||||
"os_log() argument %0 is too big (%1 bytes, max %2)">;
|
||||
def warn_os_log_format_narg : Error<
|
||||
"os_log() '%%n' format specifier is not allowed">, DefaultError;
|
||||
+
|
||||
+def warn_format_narg : Warning<
|
||||
+ "'%%n' format specifier support is deactivated and will call abort(3)">;
|
||||
|
||||
// Statements.
|
||||
def err_continue_not_in_loop : Error<
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-tools_clang_include_clang_Driver_Options_td,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_include_clang_Driver_Options_td,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add ret protector options as no-ops.
|
||||
- Improve the X86FixupGadgets pass
|
||||
|
@ -9,7 +9,7 @@ $OpenBSD: patch-tools_clang_include_clang_Driver_Options_td,v 1.4 2021/05/18 03:
|
|||
Index: tools/clang/include/clang/Driver/Options.td
|
||||
--- tools/clang/include/clang/Driver/Options.td.orig
|
||||
+++ tools/clang/include/clang/Driver/Options.td
|
||||
@@ -1799,6 +1799,16 @@ def ftrivial_auto_var_init : Joined<["-"], "ftrivial-a
|
||||
@@ -2528,6 +2528,16 @@ def ftrivial_auto_var_init : Joined<["-"], "ftrivial-a
|
||||
def enable_trivial_var_init_zero : Flag<["-"], "enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">,
|
||||
Flags<[CC1Option, CoreOption]>,
|
||||
HelpText<"Trivial automatic variable initialization to zero is only here for benchmarks, it'll eventually be removed, and I'm OK with that because I'm only using it to benchmark">;
|
||||
|
@ -24,9 +24,9 @@ Index: tools/clang/include/clang/Driver/Options.td
|
|||
+def ffixup_gadgets : Flag<["-"], "ffixup-gadgets">, Group<f_Group>, Flags<[CoreOption]>,
|
||||
+ HelpText<"Replace ROP friendly instructions with safe alternatives (x86 only)">;
|
||||
def ftrivial_auto_var_init_stop_after : Joined<["-"], "ftrivial-auto-var-init-stop-after=">, Group<f_Group>,
|
||||
Flags<[CC1Option, CoreOption]>, HelpText<"Stop initializing trivial automatic stack variables after the specified number of instances">;
|
||||
def fstandalone_debug : Flag<["-"], "fstandalone-debug">, Group<f_Group>, Flags<[CoreOption]>,
|
||||
@@ -2548,6 +2558,8 @@ def mno_check_zero_division : Flag<["-"], "mno-check-z
|
||||
Flags<[CC1Option, CoreOption]>, HelpText<"Stop initializing trivial automatic stack variables after the specified number of instances">,
|
||||
MarshallingInfoInt<LangOpts<"TrivialAutoVarInitStopAfter">>;
|
||||
@@ -3493,6 +3503,8 @@ def mno_check_zero_division : Flag<["-"], "mno-check-z
|
||||
Group<m_mips_Features_Group>;
|
||||
def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">,
|
||||
Group<m_mips_Features_Group>;
|
||||
|
@ -35,16 +35,16 @@ Index: tools/clang/include/clang/Driver/Options.td
|
|||
def mbranch_likely : Flag<["-"], "mbranch-likely">, Group<m_Group>,
|
||||
IgnoredGCCCompat;
|
||||
def mno_branch_likely : Flag<["-"], "mno-branch-likely">, Group<m_Group>,
|
||||
@@ -2760,7 +2772,7 @@ def pthreads : Flag<["-"], "pthreads">;
|
||||
def pthread : Flag<["-"], "pthread">, Flags<[CC1Option]>,
|
||||
HelpText<"Support POSIX threads in generated code">;
|
||||
def no_pthread : Flag<["-"], "no-pthread">, Flags<[CC1Option]>;
|
||||
@@ -3721,7 +3733,7 @@ defm pthread : BoolOption<"", "pthread",
|
||||
LangOpts<"POSIXThreads">, DefaultFalse,
|
||||
PosFlag<SetTrue, [], "Support POSIX threads in generated code">,
|
||||
NegFlag<SetFalse>, BothFlags<[CC1Option]>>;
|
||||
-def p : Flag<["-"], "p">;
|
||||
+def p : Flag<["-"], "p">, Alias<pg>;
|
||||
def pie : Flag<["-"], "pie">;
|
||||
def static_pie : Flag<["-"], "static-pie">;
|
||||
def pie : Flag<["-"], "pie">, Group<Link_Group>;
|
||||
def static_pie : Flag<["-"], "static-pie">, Group<Link_Group>;
|
||||
def read__only__relocs : Separate<["-"], "read_only_relocs">;
|
||||
@@ -3243,6 +3255,8 @@ def mshstk : Flag<["-"], "mshstk">, Group<m_x86_Featur
|
||||
@@ -4252,6 +4264,8 @@ def mshstk : Flag<["-"], "mshstk">, Group<m_x86_Featur
|
||||
def mno_shstk : Flag<["-"], "mno-shstk">, Group<m_x86_Features_Group>;
|
||||
def mretpoline_external_thunk : Flag<["-"], "mretpoline-external-thunk">, Group<m_x86_Features_Group>;
|
||||
def mno_retpoline_external_thunk : Flag<["-"], "mno-retpoline-external-thunk">, Group<m_x86_Features_Group>;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
$OpenBSD: patch-tools_clang_include_clang_Sema_Sema_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_include_clang_Sema_Sema_h,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Teach Clang about syslog format attribute
|
||||
|
||||
Index: tools/clang/include/clang/Sema/Sema.h
|
||||
--- tools/clang/include/clang/Sema/Sema.h.orig
|
||||
+++ tools/clang/include/clang/Sema/Sema.h
|
||||
@@ -12226,6 +12226,7 @@ class Sema final { (public)
|
||||
@@ -12648,6 +12648,7 @@ class Sema final { (public)
|
||||
FST_FreeBSDKPrintf,
|
||||
FST_OSTrace,
|
||||
FST_OSLog,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-tools_clang_lib_AST_FormatString_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_lib_AST_FormatString_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- The %b printf extension in the kernel is not fixed to a int type. On sparc64
|
||||
there are various %llb formats. Adjust the code to handle the length specifiers
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-tools_clang_lib_Basic_Targets_Mips_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_lib_Basic_Targets_Mips_h,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Implement the 'h' register constraint on mips64. This lets clang build
|
||||
pieces of software that use the constraint if the compiler claims
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
$OpenBSD: patch-tools_clang_lib_Basic_Targets_X86_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_lib_Basic_Targets_X86_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
implement -msave-args in clang/llvm, like the sun did for gcc
|
||||
|
||||
Index: tools/clang/lib/Basic/Targets/X86.cpp
|
||||
--- tools/clang/lib/Basic/Targets/X86.cpp.orig
|
||||
+++ tools/clang/lib/Basic/Targets/X86.cpp
|
||||
@@ -296,6 +296,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<s
|
||||
@@ -309,6 +309,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<s
|
||||
HasPTWRITE = true;
|
||||
} else if (Feature == "+invpcid") {
|
||||
HasINVPCID = true;
|
||||
|
@ -13,8 +13,8 @@ Index: tools/clang/lib/Basic/Targets/X86.cpp
|
|||
+ HasSaveArgs = true;
|
||||
} else if (Feature == "+enqcmd") {
|
||||
HasENQCMD = true;
|
||||
} else if (Feature == "+amx-bf16") {
|
||||
@@ -930,6 +932,7 @@ bool X86TargetInfo::hasFeature(StringRef Feature) cons
|
||||
} else if (Feature == "+hreset") {
|
||||
@@ -984,6 +986,7 @@ bool X86TargetInfo::hasFeature(StringRef Feature) cons
|
||||
.Case("movbe", HasMOVBE)
|
||||
.Case("movdiri", HasMOVDIRI)
|
||||
.Case("movdir64b", HasMOVDIR64B)
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
$OpenBSD: patch-tools_clang_lib_Basic_Targets_X86_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_lib_Basic_Targets_X86_h,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- implement -msave-args in clang/llvm, like the sun did for gcc.
|
||||
|
||||
Index: tools/clang/lib/Basic/Targets/X86.h
|
||||
--- tools/clang/lib/Basic/Targets/X86.h.orig
|
||||
+++ tools/clang/lib/Basic/Targets/X86.h
|
||||
@@ -124,6 +124,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public T
|
||||
@@ -131,6 +131,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public T
|
||||
bool HasMOVDIR64B = false;
|
||||
bool HasPTWRITE = false;
|
||||
bool HasINVPCID = false;
|
||||
+ bool HasSaveArgs = false;
|
||||
bool HasENQCMD = false;
|
||||
bool HasAMXTILE = false;
|
||||
bool HasAMXINT8 = false;
|
||||
bool HasKL = false; // For key locker
|
||||
bool HasWIDEKL = false; // For wide key locker
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-tools_clang_lib_CodeGen_CGCall_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_lib_CodeGen_CGCall_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Add RETGUARD to clang for amd64. This security mechanism uses per-function
|
||||
random cookies to protect access to function return instructions, with the
|
||||
|
@ -21,7 +21,7 @@ remove these gadgets will continue through other mechanisms.
|
|||
Index: tools/clang/lib/CodeGen/CGCall.cpp
|
||||
--- tools/clang/lib/CodeGen/CGCall.cpp.orig
|
||||
+++ tools/clang/lib/CodeGen/CGCall.cpp
|
||||
@@ -2068,6 +2068,9 @@ void CodeGenModule::ConstructAttributeList(
|
||||
@@ -2215,6 +2215,9 @@ void CodeGenModule::ConstructAttributeList(StringRef N
|
||||
// CPU/feature overrides. addDefaultFunctionDefinitionAttributes
|
||||
// handles these separately to set them based on the global defaults.
|
||||
GetCPUAndFeaturesAttributes(CalleeInfo.getCalleeDecl(), FuncAttrs);
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
$OpenBSD: patch-tools_clang_lib_CodeGen_TargetInfo_cpp,v 1.3 2021/05/18 03:35:07 rsadowski Exp $
|
||||
|
||||
- Fix va_arg in C++, Objective-C on 32-bit powerpc.
|
||||
|
||||
Index: tools/clang/lib/CodeGen/TargetInfo.cpp
|
||||
--- tools/clang/lib/CodeGen/TargetInfo.cpp.orig
|
||||
+++ tools/clang/lib/CodeGen/TargetInfo.cpp
|
||||
@@ -4711,13 +4711,12 @@ Address PPC32_SVR4_ABIInfo::EmitVAArg(CodeGenFunction
|
||||
// };
|
||||
|
||||
bool isI64 = Ty->isIntegerType() && getContext().getTypeSize(Ty) == 64;
|
||||
- bool isInt =
|
||||
- Ty->isIntegerType() || Ty->isPointerType() || Ty->isAggregateType();
|
||||
+ bool isInt = !Ty->isFloatingType();
|
||||
bool isF64 = Ty->isFloatingType() && getContext().getTypeSize(Ty) == 64;
|
||||
|
||||
// All aggregates are passed indirectly? That doesn't seem consistent
|
||||
// with the argument-lowering code.
|
||||
- bool isIndirect = Ty->isAggregateType();
|
||||
+ bool isIndirect = isAggregateTypeForABI(Ty);
|
||||
|
||||
CGBuilderTy &Builder = CGF.Builder;
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
$OpenBSD: patch-tools_clang_lib_Driver_ToolChains_Arch_X86_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_lib_Driver_ToolChains_Arch_X86_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Turn on -mretpoline by default in clang on amd64.
|
||||
|
||||
Index: tools/clang/lib/Driver/ToolChains/Arch/X86.cpp
|
||||
--- tools/clang/lib/Driver/ToolChains/Arch/X86.cpp.orig
|
||||
+++ tools/clang/lib/Driver/ToolChains/Arch/X86.cpp
|
||||
@@ -148,6 +148,12 @@ void x86::getX86TargetFeatures(const Driver &D, const
|
||||
@@ -149,6 +149,12 @@ void x86::getX86TargetFeatures(const Driver &D, const
|
||||
// consider deprecating this and instead warn if the user requests external
|
||||
// retpoline thunks and *doesn't* request some form of retpolines.
|
||||
auto SpectreOpt = clang::driver::options::ID::OPT_INVALID;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-tools_clang_lib_Driver_ToolChains_Clang_cpp,v 1.5 2021/05/18 06:19:48 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_lib_Driver_ToolChains_Clang_cpp,v 1.6 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Switch Powerpc64 Big Endian to ELFv2 on OpenBSD.
|
||||
- Adapt the -mfix-loongson2f-btb workaround from as(1) to LLVM/clang.
|
||||
|
@ -35,7 +35,7 @@ $OpenBSD: patch-tools_clang_lib_Driver_ToolChains_Clang_cpp,v 1.5 2021/05/18 06:
|
|||
Index: tools/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
--- tools/clang/lib/Driver/ToolChains/Clang.cpp.orig
|
||||
+++ tools/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
@@ -2328,6 +2328,11 @@ static void CollectArgsForIntegratedAssembler(Compilat
|
||||
@@ -2489,6 +2489,11 @@ static void CollectArgsForIntegratedAssembler(Compilat
|
||||
CmdArgs.push_back("-soft-float");
|
||||
continue;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ Index: tools/clang/lib/Driver/ToolChains/Clang.cpp
|
|||
|
||||
MipsTargetFeature = llvm::StringSwitch<const char *>(Value)
|
||||
.Case("-mips1", "+mips1")
|
||||
@@ -4570,9 +4575,12 @@ void Clang::ConstructJob(Compilation &C, const JobActi
|
||||
@@ -4943,9 +4948,12 @@ void Clang::ConstructJob(Compilation &C, const JobActi
|
||||
OFastEnabled ? options::OPT_Ofast : options::OPT_fstrict_aliasing;
|
||||
// We turn strict aliasing off by default if we're in CL mode, since MSVC
|
||||
// doesn't do any TBAA.
|
||||
|
@ -62,7 +62,7 @@ Index: tools/clang/lib/Driver/ToolChains/Clang.cpp
|
|||
CmdArgs.push_back("-relaxed-aliasing");
|
||||
if (!Args.hasFlag(options::OPT_fstruct_path_tbaa,
|
||||
options::OPT_fno_struct_path_tbaa))
|
||||
@@ -5342,7 +5350,8 @@ void Clang::ConstructJob(Compilation &C, const JobActi
|
||||
@@ -5868,7 +5876,8 @@ void Clang::ConstructJob(Compilation &C, const JobActi
|
||||
options::OPT_fno_strict_overflow)) {
|
||||
if (A->getOption().matches(options::OPT_fno_strict_overflow))
|
||||
CmdArgs.push_back("-fwrapv");
|
||||
|
@ -72,14 +72,11 @@ Index: tools/clang/lib/Driver/ToolChains/Clang.cpp
|
|||
|
||||
if (Arg *A = Args.getLastArg(options::OPT_freroll_loops,
|
||||
options::OPT_fno_reroll_loops))
|
||||
@@ -5359,10 +5368,51 @@ void Clang::ConstructJob(Compilation &C, const JobActi
|
||||
@@ -5888,7 +5897,48 @@ void Clang::ConstructJob(Compilation &C, const JobActi
|
||||
options::OPT_mno_speculative_load_hardening, false))
|
||||
CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
|
||||
|
||||
- RenderSSPOptions(TC, Args, CmdArgs, KernelOrKext);
|
||||
RenderSCPOptions(TC, Args, CmdArgs);
|
||||
RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);
|
||||
|
||||
- RenderSSPOptions(D, TC, Args, CmdArgs, KernelOrKext);
|
||||
+ // -ret-protector
|
||||
+ unsigned RetProtector = 1;
|
||||
+ if (Arg *A = Args.getLastArg(options::OPT_fno_ret_protector,
|
||||
|
@ -109,7 +106,7 @@ Index: tools/clang/lib/Driver/ToolChains/Clang.cpp
|
|||
+ options::OPT__param); // ssp-buffer-size
|
||||
+ } else {
|
||||
+ // If we're not using retguard, then do the usual stack protector
|
||||
+ RenderSSPOptions(TC, Args, CmdArgs, KernelOrKext);
|
||||
+ RenderSSPOptions(D, TC, Args, CmdArgs, KernelOrKext);
|
||||
+ }
|
||||
+
|
||||
+ // -fixup-gadgets
|
||||
|
@ -122,10 +119,10 @@ Index: tools/clang/lib/Driver/ToolChains/Clang.cpp
|
|||
+ CmdArgs.push_back(Args.MakeArgString(Twine("-x86-fixup-gadgets=true")));
|
||||
+ }
|
||||
+
|
||||
// Translate -mstackrealign
|
||||
if (Args.hasFlag(options::OPT_mstackrealign, options::OPT_mno_stackrealign,
|
||||
false))
|
||||
@@ -5857,6 +5907,18 @@ void Clang::ConstructJob(Compilation &C, const JobActi
|
||||
RenderSCPOptions(TC, Args, CmdArgs);
|
||||
RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);
|
||||
|
||||
@@ -6445,6 +6495,18 @@ void Clang::ConstructJob(Compilation &C, const JobActi
|
||||
options::OPT_fno_rewrite_imports, false);
|
||||
if (RewriteImports)
|
||||
CmdArgs.push_back("-frewrite-imports");
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
$OpenBSD: patch-tools_clang_lib_Driver_ToolChains_Gnu_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_lib_Driver_ToolChains_Gnu_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Disable IAS for OpenBSD SPARC.
|
||||
|
||||
Index: tools/clang/lib/Driver/ToolChains/Gnu.cpp
|
||||
--- tools/clang/lib/Driver/ToolChains/Gnu.cpp.orig
|
||||
+++ tools/clang/lib/Driver/ToolChains/Gnu.cpp
|
||||
@@ -2711,7 +2711,7 @@ bool Generic_GCC::IsIntegratedAssemblerDefault() const
|
||||
@@ -2763,7 +2763,7 @@ bool Generic_GCC::IsIntegratedAssemblerDefault() const
|
||||
case llvm::Triple::sparc:
|
||||
case llvm::Triple::sparcel:
|
||||
case llvm::Triple::sparcv9:
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
$OpenBSD: patch-tools_clang_lib_Driver_ToolChains_OpenBSD_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_lib_Driver_ToolChains_OpenBSD_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add support for building against libestdc++ from ports-gcc.
|
||||
- Use more *_p.a libraries from base when profiling is requested.
|
||||
- Make clang emit the proper path to our libcompiler_rt.a when asked to.
|
||||
- Allow the compiler driver to link the libclang_rt.profile library.
|
||||
- Use Component in OpenBSD::getCompilerRT to find libraries.
|
||||
|
||||
Index: tools/clang/lib/Driver/ToolChains/OpenBSD.cpp
|
||||
--- tools/clang/lib/Driver/ToolChains/OpenBSD.cpp.orig
|
||||
+++ tools/clang/lib/Driver/ToolChains/OpenBSD.cpp
|
||||
@@ -12,6 +12,8 @@
|
||||
@@ -12,10 +12,13 @@
|
||||
#include "CommonArgs.h"
|
||||
#include "clang/Config/config.h"
|
||||
#include "clang/Driver/Compilation.h"
|
||||
|
@ -16,7 +16,12 @@ Index: tools/clang/lib/Driver/ToolChains/OpenBSD.cpp
|
|||
#include "clang/Driver/Options.h"
|
||||
#include "clang/Driver/SanitizerArgs.h"
|
||||
#include "llvm/Option/ArgList.h"
|
||||
@@ -191,7 +193,13 @@ void openbsd::Linker::ConstructJob(Compilation &C, con
|
||||
#include "llvm/Support/Path.h"
|
||||
+#include "llvm/Support/VirtualFileSystem.h"
|
||||
|
||||
using namespace clang::driver;
|
||||
using namespace clang::driver::tools;
|
||||
@@ -197,7 +200,13 @@ void openbsd::Linker::ConstructJob(Compilation &C, con
|
||||
}
|
||||
// FIXME: For some reason GCC passes -lgcc before adding
|
||||
// the default system libraries. Just mimic this for now.
|
||||
|
@ -31,7 +36,7 @@ Index: tools/clang/lib/Driver/ToolChains/OpenBSD.cpp
|
|||
|
||||
if (Args.hasArg(options::OPT_pthread)) {
|
||||
if (!Args.hasArg(options::OPT_shared) && Args.hasArg(options::OPT_pg))
|
||||
@@ -207,7 +215,10 @@ void openbsd::Linker::ConstructJob(Compilation &C, con
|
||||
@@ -213,7 +222,10 @@ void openbsd::Linker::ConstructJob(Compilation &C, con
|
||||
CmdArgs.push_back("-lc");
|
||||
}
|
||||
|
||||
|
@ -43,22 +48,48 @@ Index: tools/clang/lib/Driver/ToolChains/OpenBSD.cpp
|
|||
}
|
||||
|
||||
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
|
||||
@@ -288,14 +299,7 @@ void OpenBSD::addLibCxxIncludePaths(const llvm::opt::A
|
||||
getDriver().SysRoot + "/usr/include/c++/v1");
|
||||
}
|
||||
|
||||
-void OpenBSD::AddCXXStdlibLibArgs(const ArgList &Args,
|
||||
- ArgStringList &CmdArgs) const {
|
||||
- bool Profiling = Args.hasArg(options::OPT_pg);
|
||||
@@ -301,17 +313,34 @@ void OpenBSD::AddCXXStdlibLibArgs(const ArgList &Args,
|
||||
ArgStringList &CmdArgs) const {
|
||||
bool Profiling = Args.hasArg(options::OPT_pg);
|
||||
|
||||
- CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
|
||||
- CmdArgs.push_back(Profiling ? "-lc++abi_p" : "-lc++abi");
|
||||
-}
|
||||
-
|
||||
- CmdArgs.push_back(Profiling ? "-lpthread_p" : "-lpthread");
|
||||
+ switch (GetCXXStdlibType(Args)) {
|
||||
+ case ToolChain::CST_Libcxx:
|
||||
+ CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
|
||||
+ CmdArgs.push_back(Profiling ? "-lc++abi_p" : "-lc++abi");
|
||||
+ CmdArgs.push_back(Profiling ? "-lpthread_p" : "-lpthread");
|
||||
+ break;
|
||||
+ case ToolChain::CST_Libstdcxx:
|
||||
+ CmdArgs.push_back("-lestdc++");
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
|
||||
std::string OpenBSD::getCompilerRT(const ArgList &Args,
|
||||
StringRef Component,
|
||||
FileType Type) const {
|
||||
@@ -311,3 +315,69 @@ Tool *OpenBSD::buildAssembler() const {
|
||||
- SmallString<128> Path(getDriver().SysRoot);
|
||||
- llvm::sys::path::append(Path, "/usr/lib/libcompiler_rt.a");
|
||||
- return std::string(Path.str());
|
||||
+ if (Component == "builtins") {
|
||||
+ SmallString<128> Path(getDriver().SysRoot);
|
||||
+ llvm::sys::path::append(Path, "/usr/lib/libcompiler_rt.a");
|
||||
+ return std::string(Path.str());
|
||||
+ } else {
|
||||
+ SmallString<128> P(getDriver().ResourceDir);
|
||||
+ std::string CRTBasename =
|
||||
+ buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/false);
|
||||
+ llvm::sys::path::append(P, "lib", CRTBasename);
|
||||
+ if (getVFS().exists(P))
|
||||
+ return std::string(P.str());
|
||||
+ return ToolChain::getCompilerRT(Args, Component, Type);
|
||||
+ }
|
||||
}
|
||||
|
||||
Tool *OpenBSD::buildAssembler() const {
|
||||
@@ -321,3 +350,54 @@ Tool *OpenBSD::buildAssembler() const {
|
||||
Tool *OpenBSD::buildLinker() const { return new tools::openbsd::Linker(*this); }
|
||||
|
||||
bool OpenBSD::HasNativeLLVMSupport() const { return true; }
|
||||
|
@ -81,6 +112,7 @@ Index: tools/clang/lib/Driver/ToolChains/OpenBSD.cpp
|
|||
+ case llvm::Triple::mips64el:
|
||||
+ case llvm::Triple::ppc:
|
||||
+ case llvm::Triple::ppc64:
|
||||
+ case llvm::Triple::riscv64:
|
||||
+ case llvm::Triple::x86:
|
||||
+ case llvm::Triple::x86_64:
|
||||
+ return ToolChain::CST_Libcxx;
|
||||
|
@ -112,19 +144,3 @@ Index: tools/clang/lib/Driver/ToolChains/OpenBSD.cpp
|
|||
+ break;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void OpenBSD::AddCXXStdlibLibArgs(const ArgList &Args,
|
||||
+ ArgStringList &CmdArgs) const {
|
||||
+ bool Profiling = Args.hasArg(options::OPT_pg);
|
||||
+
|
||||
+ switch (GetCXXStdlibType(Args)) {
|
||||
+ case ToolChain::CST_Libcxx:
|
||||
+ CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
|
||||
+ CmdArgs.push_back(Profiling ? "-lc++abi_p" : "-lc++abi");
|
||||
+ CmdArgs.push_back(Profiling ? "-lpthread_p" : "-lpthread");
|
||||
+ break;
|
||||
+ case ToolChain::CST_Libstdcxx:
|
||||
+ CmdArgs.push_back("-lestdc++");
|
||||
+ break;
|
||||
+ }
|
||||
+}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-tools_clang_lib_Driver_ToolChains_OpenBSD_h,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_lib_Driver_ToolChains_OpenBSD_h,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add support for building against libestdc++ from ports-gcc.
|
||||
- Make clang emit the proper path to our libcompiler_rt.a when asked to.
|
||||
|
@ -6,7 +6,7 @@ $OpenBSD: patch-tools_clang_lib_Driver_ToolChains_OpenBSD_h,v 1.4 2021/05/18 03:
|
|||
Index: tools/clang/lib/Driver/ToolChains/OpenBSD.h
|
||||
--- tools/clang/lib/Driver/ToolChains/OpenBSD.h.orig
|
||||
+++ tools/clang/lib/Driver/ToolChains/OpenBSD.h
|
||||
@@ -76,6 +76,11 @@ class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic
|
||||
@@ -77,6 +77,11 @@ class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic
|
||||
void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
|
||||
llvm::opt::ArgStringList &CmdArgs) const override;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$OpenBSD: patch-tools_clang_lib_Frontend_CompilerInvocation_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_lib_Frontend_CompilerInvocation_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Add RETGUARD to clang for amd64. This security mechanism uses per-function
|
||||
random cookies to protect access to function return instructions, with the
|
||||
|
@ -21,12 +21,23 @@ $OpenBSD: patch-tools_clang_lib_Frontend_CompilerInvocation_cpp,v 1.4 2021/05/18
|
|||
Index: tools/clang/lib/Frontend/CompilerInvocation.cpp
|
||||
--- tools/clang/lib/Frontend/CompilerInvocation.cpp.orig
|
||||
+++ tools/clang/lib/Frontend/CompilerInvocation.cpp
|
||||
@@ -1250,6 +1250,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, Arg
|
||||
Opts.StackAlignment = StackAlignment;
|
||||
@@ -1470,6 +1470,10 @@ void CompilerInvocation::GenerateCodeGenArgs(
|
||||
F.Filename, SA);
|
||||
}
|
||||
|
||||
+ Opts.ReturnProtector = Args.hasArg(OPT_ret_protector);
|
||||
+ if (Opts.ReturnProtector) {
|
||||
+ GenerateArg(Args, OPT_ret_protector, SA);
|
||||
+ }
|
||||
+
|
||||
if (Arg *A = Args.getLastArg(OPT_mstack_probe_size)) {
|
||||
StringRef Val = A->getValue();
|
||||
unsigned StackProbeSize = Opts.StackProbeSize;
|
||||
// TODO: Consider removing marshalling annotations from f[no_]emulated_tls.
|
||||
// That would make it easy to generate the option only **once** if it was
|
||||
// explicitly set to non-default value.
|
||||
@@ -1805,6 +1809,8 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptio
|
||||
}
|
||||
Opts.LinkBitcodeFiles.push_back(F);
|
||||
}
|
||||
+
|
||||
+ Opts.ReturnProtector = Args.hasArg(OPT_ret_protector);
|
||||
|
||||
if (Args.getLastArg(OPT_femulated_tls) ||
|
||||
Args.getLastArg(OPT_fno_emulated_tls)) {
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
$OpenBSD: patch-tools_clang_lib_Sema_SemaChecking_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_lib_Sema_SemaChecking_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
- Teach Clang about syslog format attribute
|
||||
- Enable the kprintf format attribute
|
||||
- The %b printf extension in the kernel is not fixed to a int type. On sparc64
|
||||
there are various %llb formats. Adjust the code to handle the length
|
||||
specifiers and type check like it is used by the regular case.
|
||||
- Add a new warning for %n format specifier usage in printf(3) family functions
|
||||
|
||||
Index: tools/clang/lib/Sema/SemaChecking.cpp
|
||||
--- tools/clang/lib/Sema/SemaChecking.cpp.orig
|
||||
+++ tools/clang/lib/Sema/SemaChecking.cpp
|
||||
@@ -7095,7 +7095,7 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef
|
||||
@@ -7847,7 +7847,7 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef
|
||||
Sema::FormatStringType Sema::GetFormatStringType(const FormatAttr *Format) {
|
||||
return llvm::StringSwitch<FormatStringType>(Format->getType()->getName())
|
||||
.Case("scanf", FST_Scanf)
|
||||
|
@ -18,7 +19,7 @@ Index: tools/clang/lib/Sema/SemaChecking.cpp
|
|||
.Cases("NSString", "CFString", FST_NSString)
|
||||
.Case("strftime", FST_Strftime)
|
||||
.Case("strfmon", FST_Strfmon)
|
||||
@@ -7192,6 +7192,7 @@ bool Sema::CheckFormatArguments(ArrayRef<const Expr *>
|
||||
@@ -7944,6 +7944,7 @@ bool Sema::CheckFormatArguments(ArrayRef<const Expr *>
|
||||
case FST_Kprintf:
|
||||
case FST_FreeBSDKPrintf:
|
||||
case FST_Printf:
|
||||
|
@ -26,7 +27,7 @@ Index: tools/clang/lib/Sema/SemaChecking.cpp
|
|||
Diag(FormatLoc, diag::note_format_security_fixit)
|
||||
<< FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
|
||||
break;
|
||||
@@ -8017,19 +8018,34 @@ CheckPrintfHandler::HandlePrintfSpecifier(const analyz
|
||||
@@ -8769,19 +8770,34 @@ CheckPrintfHandler::HandlePrintfSpecifier(const analyz
|
||||
// Claim the second argument.
|
||||
CoveredArgs.set(argIndex + 1);
|
||||
|
||||
|
@ -70,7 +71,23 @@ Index: tools/clang/lib/Sema/SemaChecking.cpp
|
|||
// Type check the second argument (char * for both %b and %D)
|
||||
Ex = getDataArg(argIndex + 1);
|
||||
const analyze_printf::ArgType &AT2 = ArgType::CStrTy;
|
||||
@@ -8810,8 +8826,9 @@ static void CheckFormatString(Sema &S, const FormatStr
|
||||
@@ -8819,6 +8835,15 @@ CheckPrintfHandler::HandlePrintfSpecifier(const analyz
|
||||
return true;
|
||||
}
|
||||
|
||||
+ // %n is not allowed anywhere
|
||||
+ if (CS.getKind() == ConversionSpecifier::nArg) {
|
||||
+ EmitFormatDiagnostic(S.PDiag(diag::warn_format_narg),
|
||||
+ getLocationOfByte(CS.getStart()),
|
||||
+ /*IsStringLocation*/ false,
|
||||
+ getSpecifierRange(startSpecifier, specifierLen));
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
// Only scalars are allowed for os_trace.
|
||||
if (FSType == Sema::FST_OSTrace &&
|
||||
(CS.getKind() == ConversionSpecifier::PArg ||
|
||||
@@ -9565,8 +9590,9 @@ static void CheckFormatString(Sema &S, const FormatStr
|
||||
}
|
||||
|
||||
if (Type == Sema::FST_Printf || Type == Sema::FST_NSString ||
|
||||
|
@ -82,7 +99,7 @@ Index: tools/clang/lib/Sema/SemaChecking.cpp
|
|||
CheckPrintfHandler H(
|
||||
S, FExpr, OrigFormatExpr, Type, firstDataArg, numDataArgs,
|
||||
(Type == Sema::FST_NSString || Type == Sema::FST_OSTrace), Str,
|
||||
@@ -8821,7 +8838,7 @@ static void CheckFormatString(Sema &S, const FormatStr
|
||||
@@ -9576,7 +9602,7 @@ static void CheckFormatString(Sema &S, const FormatStr
|
||||
if (!analyze_format_string::ParsePrintfString(H, Str, Str + StrLen,
|
||||
S.getLangOpts(),
|
||||
S.Context.getTargetInfo(),
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
$OpenBSD: patch-tools_clang_lib_Sema_SemaDeclAttr_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_lib_Sema_SemaDeclAttr_cpp,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Teach Clang about syslog format attribute
|
||||
|
||||
Index: tools/clang/lib/Sema/SemaDeclAttr.cpp
|
||||
--- tools/clang/lib/Sema/SemaDeclAttr.cpp.orig
|
||||
+++ tools/clang/lib/Sema/SemaDeclAttr.cpp
|
||||
@@ -3267,6 +3267,7 @@ static FormatAttrKind getFormatAttrKind(StringRef Form
|
||||
@@ -3411,6 +3411,7 @@ static FormatAttrKind getFormatAttrKind(StringRef Form
|
||||
.Case("freebsd_kprintf", SupportedFormat) // FreeBSD.
|
||||
.Case("os_trace", SupportedFormat)
|
||||
.Case("os_log", SupportedFormat)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
$OpenBSD: patch-tools_clang_tools_scan-build_libexec_ccc-analyzer,v 1.1 2021/05/18 06:19:48 rsadowski Exp $
|
||||
$OpenBSD: patch-tools_clang_tools_scan-build_libexec_ccc-analyzer,v 1.2 2022/01/03 21:36:42 rsadowski Exp $
|
||||
|
||||
Our default compilers are cc/c++.
|
||||
|
||||
Index: tools/clang/tools/scan-build/libexec/ccc-analyzer
|
||||
--- tools/clang/tools/scan-build/libexec/ccc-analyzer.orig
|
||||
+++ tools/clang/tools/scan-build/libexec/ccc-analyzer
|
||||
@@ -81,8 +81,8 @@ if (`uname -a` =~ m/Darwin/) {
|
||||
$UseXCRUN = 1;
|
||||
}
|
||||
@@ -84,8 +84,8 @@ if (`uname -a` =~ m/Darwin/) {
|
||||
$DefaultCCompiler = 'cc';
|
||||
$DefaultCXXCompiler = 'c++';
|
||||
} else {
|
||||
- $DefaultCCompiler = 'gcc';
|
||||
- $DefaultCXXCompiler = 'g++';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@comment $OpenBSD: PLIST,v 1.4 2021/05/18 03:35:07 rsadowski Exp $
|
||||
@comment $OpenBSD: PLIST,v 1.5 2022/01/03 21:36:42 rsadowski Exp $
|
||||
@bin bin/clang-apply-replacements
|
||||
@bin bin/clang-change-namespace
|
||||
@bin bin/clang-doc
|
||||
|
@ -11,6 +11,7 @@
|
|||
@bin bin/find-all-symbols
|
||||
@bin bin/modularize
|
||||
@bin bin/pp-trace
|
||||
bin/run-clang-tidy
|
||||
include/clang-tidy/
|
||||
include/clang-tidy/ClangTidy.h
|
||||
include/clang-tidy/ClangTidyCheck.h
|
||||
|
@ -43,6 +44,12 @@ include/clang-tidy/abseil/StringFindStrContainsCheck.h
|
|||
include/clang-tidy/abseil/TimeComparisonCheck.h
|
||||
include/clang-tidy/abseil/TimeSubtractionCheck.h
|
||||
include/clang-tidy/abseil/UpgradeDurationConversionsCheck.h
|
||||
include/clang-tidy/altera/
|
||||
include/clang-tidy/altera/IdDependentBackwardBranchCheck.h
|
||||
include/clang-tidy/altera/KernelNameRestrictionCheck.h
|
||||
include/clang-tidy/altera/SingleWorkItemBarrierCheck.h
|
||||
include/clang-tidy/altera/StructPackAlignCheck.h
|
||||
include/clang-tidy/altera/UnrollLoopsCheck.h
|
||||
include/clang-tidy/android/
|
||||
include/clang-tidy/android/CloexecAccept4Check.h
|
||||
include/clang-tidy/android/CloexecAcceptCheck.h
|
||||
|
@ -71,10 +78,12 @@ include/clang-tidy/bugprone/BranchCloneCheck.h
|
|||
include/clang-tidy/bugprone/CopyConstructorInitCheck.h
|
||||
include/clang-tidy/bugprone/DanglingHandleCheck.h
|
||||
include/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
|
||||
include/clang-tidy/bugprone/EasilySwappableParametersCheck.h
|
||||
include/clang-tidy/bugprone/ExceptionEscapeCheck.h
|
||||
include/clang-tidy/bugprone/FoldInitTypeCheck.h
|
||||
include/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.h
|
||||
include/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.h
|
||||
include/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.h
|
||||
include/clang-tidy/bugprone/InaccurateEraseCheck.h
|
||||
include/clang-tidy/bugprone/IncorrectRoundingsCheck.h
|
||||
include/clang-tidy/bugprone/InfiniteLoopCheck.h
|
||||
|
@ -91,7 +100,9 @@ include/clang-tidy/bugprone/NoEscapeCheck.h
|
|||
include/clang-tidy/bugprone/NotNullTerminatedResultCheck.h
|
||||
include/clang-tidy/bugprone/ParentVirtualCallCheck.h
|
||||
include/clang-tidy/bugprone/PosixReturnCheck.h
|
||||
include/clang-tidy/bugprone/RedundantBranchConditionCheck.h
|
||||
include/clang-tidy/bugprone/ReservedIdentifierCheck.h
|
||||
include/clang-tidy/bugprone/SignalHandlerCheck.h
|
||||
include/clang-tidy/bugprone/SignedCharMisuseCheck.h
|
||||
include/clang-tidy/bugprone/SizeofContainerCheck.h
|
||||
include/clang-tidy/bugprone/SizeofExpressionCheck.h
|
||||
|
@ -111,6 +122,7 @@ include/clang-tidy/bugprone/ThrowKeywordMissingCheck.h
|
|||
include/clang-tidy/bugprone/TooSmallLoopVariableCheck.h
|
||||
include/clang-tidy/bugprone/UndefinedMemoryManipulationCheck.h
|
||||
include/clang-tidy/bugprone/UndelegatedConstructorCheck.h
|
||||
include/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.h
|
||||
include/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.h
|
||||
include/clang-tidy/bugprone/UnusedRaiiCheck.h
|
||||
include/clang-tidy/bugprone/UnusedReturnValueCheck.h
|
||||
|
@ -131,6 +143,9 @@ include/clang-tidy/cert/StaticObjectExceptionCheck.h
|
|||
include/clang-tidy/cert/StrToNumCheck.h
|
||||
include/clang-tidy/cert/ThrownExceptionTypeCheck.h
|
||||
include/clang-tidy/cert/VariadicFunctionDefCheck.h
|
||||
include/clang-tidy/concurrency/
|
||||
include/clang-tidy/concurrency/MtUnsafeCheck.h
|
||||
include/clang-tidy/concurrency/ThreadCanceltypeAsynchronousCheck.h
|
||||
include/clang-tidy/cppcoreguidelines/
|
||||
include/clang-tidy/cppcoreguidelines/AvoidGotoCheck.h
|
||||
include/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.h
|
||||
|
@ -140,6 +155,7 @@ include/clang-tidy/cppcoreguidelines/MacroUsageCheck.h
|
|||
include/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
|
||||
include/clang-tidy/cppcoreguidelines/NoMallocCheck.h
|
||||
include/clang-tidy/cppcoreguidelines/OwningMemoryCheck.h
|
||||
include/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.h
|
||||
include/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
|
||||
include/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
|
||||
include/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h
|
||||
|
@ -175,7 +191,6 @@ include/clang-tidy/google/FunctionNamingCheck.h
|
|||
include/clang-tidy/google/GlobalNamesInHeadersCheck.h
|
||||
include/clang-tidy/google/GlobalVariableDeclarationCheck.h
|
||||
include/clang-tidy/google/IntegerTypesCheck.h
|
||||
include/clang-tidy/google/NonConstReferences.h
|
||||
include/clang-tidy/google/OverloadedUnaryAndCheck.h
|
||||
include/clang-tidy/google/TodoCommentCheck.h
|
||||
include/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
|
||||
|
@ -271,6 +286,7 @@ include/clang-tidy/performance/InefficientVectorOperationCheck.h
|
|||
include/clang-tidy/performance/MoveConstArgCheck.h
|
||||
include/clang-tidy/performance/MoveConstructorInitCheck.h
|
||||
include/clang-tidy/performance/NoAutomaticMoveCheck.h
|
||||
include/clang-tidy/performance/NoIntToPtrCheck.h
|
||||
include/clang-tidy/performance/NoexceptMoveConstructorCheck.h
|
||||
include/clang-tidy/performance/TriviallyDestructibleCheck.h
|
||||
include/clang-tidy/performance/TypePromotionInMathFnCheck.h
|
||||
|
@ -287,8 +303,8 @@ include/clang-tidy/readability/ConstReturnTypeCheck.h
|
|||
include/clang-tidy/readability/ContainerSizeEmptyCheck.h
|
||||
include/clang-tidy/readability/ConvertMemberFunctionsToStatic.h
|
||||
include/clang-tidy/readability/DeleteNullPointerCheck.h
|
||||
include/clang-tidy/readability/DeletedDefaultCheck.h
|
||||
include/clang-tidy/readability/ElseAfterReturnCheck.h
|
||||
include/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
|
||||
include/clang-tidy/readability/FunctionSizeCheck.h
|
||||
include/clang-tidy/readability/IdentifierNamingCheck.h
|
||||
include/clang-tidy/readability/ImplicitBoolConversionCheck.h
|
||||
|
@ -316,6 +332,7 @@ include/clang-tidy/readability/SimplifySubscriptExprCheck.h
|
|||
include/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
|
||||
include/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.h
|
||||
include/clang-tidy/readability/StringCompareCheck.h
|
||||
include/clang-tidy/readability/SuspiciousCallArgumentCheck.h
|
||||
include/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h
|
||||
include/clang-tidy/readability/UppercaseLiteralSuffixCheck.h
|
||||
include/clang-tidy/readability/UseAnyOfAllOfCheck.h
|
||||
|
@ -354,10 +371,12 @@ include/clang-tidy/zircon/TemporaryObjectsCheck.h
|
|||
@static-lib lib/libclangReorderFields.a
|
||||
@static-lib lib/libclangTidy.a
|
||||
@static-lib lib/libclangTidyAbseilModule.a
|
||||
@static-lib lib/libclangTidyAlteraModule.a
|
||||
@static-lib lib/libclangTidyAndroidModule.a
|
||||
@static-lib lib/libclangTidyBoostModule.a
|
||||
@static-lib lib/libclangTidyBugproneModule.a
|
||||
@static-lib lib/libclangTidyCERTModule.a
|
||||
@static-lib lib/libclangTidyConcurrencyModule.a
|
||||
@static-lib lib/libclangTidyCppCoreGuidelinesModule.a
|
||||
@static-lib lib/libclangTidyDarwinModule.a
|
||||
@static-lib lib/libclangTidyFuchsiaModule.a
|
||||
|
@ -381,15 +400,12 @@ include/clang-tidy/zircon/TemporaryObjectsCheck.h
|
|||
@static-lib lib/libclangdRemoteIndex.a
|
||||
@static-lib lib/libclangdSupport.a
|
||||
@static-lib lib/libfindAllSymbols.a
|
||||
share/clang/${MODPY_PYCACHE}/
|
||||
share/clang/${MODPY_PYCACHE}clang-include-fixer.${MODPY_PYC_MAGIC_TAG}pyc
|
||||
share/clang/${MODPY_PYCACHE}clang-tidy-diff.${MODPY_PYC_MAGIC_TAG}pyc
|
||||
share/clang/${MODPY_PYCACHE}run-clang-tidy.${MODPY_PYC_MAGIC_TAG}pyc
|
||||
share/clang/${MODPY_PYCACHE}run-find-all-symbols.${MODPY_PYC_MAGIC_TAG}pyc
|
||||
share/clang/clang-doc-default-stylesheet.css
|
||||
share/clang/clang-include-fixer.el
|
||||
share/clang/clang-include-fixer.py
|
||||
share/clang/clang-tidy-diff.py
|
||||
share/clang/index.js
|
||||
share/clang/run-clang-tidy.py
|
||||
share/clang/run-find-all-symbols.py
|
||||
|
|
Loading…
Reference in New Issue
Block a user