Skip to content

Commit 4b4782b

Browse files
authored
Revert "Add support for Windows Secure Hot-Patching" (#145553)
Reverts #138972
1 parent 0c50971 commit 4b4782b

31 files changed

+0
-1201
lines changed

clang/include/clang/Basic/CodeGenOptions.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -495,13 +495,6 @@ class CodeGenOptions : public CodeGenOptionsBase {
495495

496496
/// A list of functions that are replacable by the loader.
497497
std::vector<std::string> LoaderReplaceableFunctionNames;
498-
/// The name of a file that contains functions which will be compiled for
499-
/// hotpatching. See -fms-secure-hotpatch-functions-file.
500-
std::string MSSecureHotPatchFunctionsFile;
501-
502-
/// A list of functions which will be compiled for hotpatching.
503-
/// See -fms-secure-hotpatch-functions-list.
504-
std::vector<std::string> MSSecureHotPatchFunctionsList;
505498

506499
public:
507500
// Define accessors/mutators for code generation options of enumeration type.

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3838,24 +3838,6 @@ def fms_hotpatch : Flag<["-"], "fms-hotpatch">, Group<f_Group>,
38383838
Visibility<[ClangOption, CC1Option, CLOption]>,
38393839
HelpText<"Ensure that all functions can be hotpatched at runtime">,
38403840
MarshallingInfoFlag<CodeGenOpts<"HotPatch">>;
3841-
3842-
// See llvm/lib/CodeGen/WindowsSecureHotPatching.cpp
3843-
def fms_secure_hotpatch_functions_file
3844-
: Joined<["-"], "fms-secure-hotpatch-functions-file=">,
3845-
Group<f_Group>,
3846-
Visibility<[ClangOption, CC1Option, CLOption]>,
3847-
MarshallingInfoString<CodeGenOpts<"MSSecureHotPatchFunctionsFile">>,
3848-
HelpText<"Path to a file that contains a list of mangled names of "
3849-
"functions that should be hot-patched for Windows Secure "
3850-
"Hot-Patching">;
3851-
def fms_secure_hotpatch_functions_list
3852-
: CommaJoined<["-"], "fms-secure-hotpatch-functions-list=">,
3853-
Group<f_Group>,
3854-
Visibility<[ClangOption, CC1Option, CLOption]>,
3855-
MarshallingInfoStringVector<CodeGenOpts<"MSSecureHotPatchFunctionsList">>,
3856-
HelpText<"List of mangled symbol names of functions that should be "
3857-
"hot-patched for Windows Secure Hot-Patching">;
3858-
38593841
def fpcc_struct_return : Flag<["-"], "fpcc-struct-return">, Group<f_Group>,
38603842
Visibility<[ClangOption, CC1Option]>,
38613843
HelpText<"Override the default ABI to return all structs on the stack">;

clang/lib/CodeGen/CGCall.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2660,13 +2660,6 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
26602660
// CPU/feature overrides. addDefaultFunctionDefinitionAttributes
26612661
// handles these separately to set them based on the global defaults.
26622662
GetCPUAndFeaturesAttributes(CalleeInfo.getCalleeDecl(), FuncAttrs);
2663-
2664-
// Windows hotpatching support
2665-
if (!MSHotPatchFunctions.empty()) {
2666-
bool IsHotPatched = llvm::binary_search(MSHotPatchFunctions, Name);
2667-
if (IsHotPatched)
2668-
FuncAttrs.addAttribute("marked_for_windows_hot_patching");
2669-
}
26702663
}
26712664

26722665
// Mark functions that are replaceable by the loader.

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -458,35 +458,6 @@ CodeGenModule::CodeGenModule(ASTContext &C,
458458
if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86)
459459
getModule().addModuleFlag(llvm::Module::Error, "NumRegisterParameters",
460460
CodeGenOpts.NumRegisterParameters);
461-
462-
// If there are any functions that are marked for Windows secure hot-patching,
463-
// then build the list of functions now.
464-
if (!CGO.MSSecureHotPatchFunctionsFile.empty() ||
465-
!CGO.MSSecureHotPatchFunctionsList.empty()) {
466-
if (!CGO.MSSecureHotPatchFunctionsFile.empty()) {
467-
auto BufOrErr =
468-
llvm::MemoryBuffer::getFile(CGO.MSSecureHotPatchFunctionsFile);
469-
if (BufOrErr) {
470-
const llvm::MemoryBuffer &FileBuffer = **BufOrErr;
471-
for (llvm::line_iterator I(FileBuffer.getMemBufferRef(), true), E;
472-
I != E; ++I)
473-
this->MSHotPatchFunctions.push_back(std::string{*I});
474-
} else {
475-
auto &DE = Context.getDiagnostics();
476-
unsigned DiagID =
477-
DE.getCustomDiagID(DiagnosticsEngine::Error,
478-
"failed to open hotpatch functions file "
479-
"(-fms-hotpatch-functions-file): %0 : %1");
480-
DE.Report(DiagID) << CGO.MSSecureHotPatchFunctionsFile
481-
<< BufOrErr.getError().message();
482-
}
483-
}
484-
485-
for (const auto &FuncName : CGO.MSSecureHotPatchFunctionsList)
486-
this->MSHotPatchFunctions.push_back(FuncName);
487-
488-
llvm::sort(this->MSHotPatchFunctions);
489-
}
490461
}
491462

492463
CodeGenModule::~CodeGenModule() {}

clang/lib/CodeGen/CodeGenModule.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -678,11 +678,6 @@ class CodeGenModule : public CodeGenTypeCache {
678678

679679
AtomicOptions AtomicOpts;
680680

681-
// A set of functions which should be hot-patched; see
682-
// -fms-hotpatch-functions-file (and -list). This will nearly always be empty.
683-
// The list is sorted for binary-searching.
684-
std::vector<std::string> MSHotPatchFunctions;
685-
686681
public:
687682
CodeGenModule(ASTContext &C, IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
688683
const HeaderSearchOptions &headersearchopts,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6803,14 +6803,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
68036803

68046804
Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch);
68056805

6806-
if (Arg *A = Args.getLastArg(options::OPT_fms_secure_hotpatch_functions_file))
6807-
Args.AddLastArg(CmdArgs, options::OPT_fms_secure_hotpatch_functions_file);
6808-
6809-
for (const auto &A :
6810-
Args.getAllArgValues(options::OPT_fms_secure_hotpatch_functions_list))
6811-
CmdArgs.push_back(
6812-
Args.MakeArgString("-fms-secure-hotpatch-functions-list=" + Twine(A)));
6813-
68146806
if (TC.SupportsProfiling()) {
68156807
Args.AddLastArg(CmdArgs, options::OPT_pg);
68166808

clang/test/CodeGen/X86/ms-secure-hotpatch-bad-file.c

Lines changed: 0 additions & 18 deletions
This file was deleted.

clang/test/CodeGen/X86/ms-secure-hotpatch-cpp.cpp

Lines changed: 0 additions & 24 deletions
This file was deleted.

clang/test/CodeGen/X86/ms-secure-hotpatch-eh.cpp

Lines changed: 0 additions & 26 deletions
This file was deleted.

clang/test/CodeGen/X86/ms-secure-hotpatch-globals.c

Lines changed: 0 additions & 135 deletions
This file was deleted.

clang/test/CodeGen/X86/ms-secure-hotpatch-lto.c

Lines changed: 0 additions & 26 deletions
This file was deleted.

clang/test/CodeGen/X86/ms-secure-hotpatch.c

Lines changed: 0 additions & 23 deletions
This file was deleted.

llvm/include/llvm/CodeGen/Passes.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,6 @@ LLVM_ABI FunctionPass *createSelectOptimizePass();
618618

619619
LLVM_ABI FunctionPass *createCallBrPass();
620620

621-
/// Creates Windows Secure Hot Patch pass. \see WindowsSecureHotPatching.cpp
622-
ModulePass *createWindowsSecureHotPatchingPass();
623-
624621
/// Lowers KCFI operand bundles for indirect calls.
625622
LLVM_ABI FunctionPass *createKCFIPass();
626623
} // namespace llvm

llvm/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ SYMBOL_RECORD_ALIAS(S_GTHREAD32 , 0x1113, GlobalTLS, ThreadLocalDataSym)
256256
SYMBOL_RECORD(S_UNAMESPACE , 0x1124, UsingNamespaceSym)
257257
SYMBOL_RECORD(S_ANNOTATION , 0x1019, AnnotationSym)
258258

259-
SYMBOL_RECORD(S_HOTPATCHFUNC , 0x1169, HotPatchFuncSym)
260-
261259
#undef CV_SYMBOL
262260
#undef SYMBOL_RECORD
263261
#undef SYMBOL_RECORD_ALIAS

0 commit comments

Comments
 (0)