Skip to content

Revert "Add support for Windows Secure Hot-Patching" #145553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions clang/include/clang/Basic/CodeGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,6 @@ class CodeGenOptions : public CodeGenOptionsBase {

/// A list of functions that are replacable by the loader.
std::vector<std::string> LoaderReplaceableFunctionNames;
/// The name of a file that contains functions which will be compiled for
/// hotpatching. See -fms-secure-hotpatch-functions-file.
std::string MSSecureHotPatchFunctionsFile;

/// A list of functions which will be compiled for hotpatching.
/// See -fms-secure-hotpatch-functions-list.
std::vector<std::string> MSSecureHotPatchFunctionsList;

public:
// Define accessors/mutators for code generation options of enumeration type.
Expand Down
18 changes: 0 additions & 18 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -3838,24 +3838,6 @@ def fms_hotpatch : Flag<["-"], "fms-hotpatch">, Group<f_Group>,
Visibility<[ClangOption, CC1Option, CLOption]>,
HelpText<"Ensure that all functions can be hotpatched at runtime">,
MarshallingInfoFlag<CodeGenOpts<"HotPatch">>;

// See llvm/lib/CodeGen/WindowsSecureHotPatching.cpp
def fms_secure_hotpatch_functions_file
: Joined<["-"], "fms-secure-hotpatch-functions-file=">,
Group<f_Group>,
Visibility<[ClangOption, CC1Option, CLOption]>,
MarshallingInfoString<CodeGenOpts<"MSSecureHotPatchFunctionsFile">>,
HelpText<"Path to a file that contains a list of mangled names of "
"functions that should be hot-patched for Windows Secure "
"Hot-Patching">;
def fms_secure_hotpatch_functions_list
: CommaJoined<["-"], "fms-secure-hotpatch-functions-list=">,
Group<f_Group>,
Visibility<[ClangOption, CC1Option, CLOption]>,
MarshallingInfoStringVector<CodeGenOpts<"MSSecureHotPatchFunctionsList">>,
HelpText<"List of mangled symbol names of functions that should be "
"hot-patched for Windows Secure Hot-Patching">;

def fpcc_struct_return : Flag<["-"], "fpcc-struct-return">, Group<f_Group>,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Override the default ABI to return all structs on the stack">;
Expand Down
7 changes: 0 additions & 7 deletions clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2660,13 +2660,6 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
// CPU/feature overrides. addDefaultFunctionDefinitionAttributes
// handles these separately to set them based on the global defaults.
GetCPUAndFeaturesAttributes(CalleeInfo.getCalleeDecl(), FuncAttrs);

// Windows hotpatching support
if (!MSHotPatchFunctions.empty()) {
bool IsHotPatched = llvm::binary_search(MSHotPatchFunctions, Name);
if (IsHotPatched)
FuncAttrs.addAttribute("marked_for_windows_hot_patching");
}
}

// Mark functions that are replaceable by the loader.
Expand Down
29 changes: 0 additions & 29 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,35 +458,6 @@ CodeGenModule::CodeGenModule(ASTContext &C,
if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86)
getModule().addModuleFlag(llvm::Module::Error, "NumRegisterParameters",
CodeGenOpts.NumRegisterParameters);

// If there are any functions that are marked for Windows secure hot-patching,
// then build the list of functions now.
if (!CGO.MSSecureHotPatchFunctionsFile.empty() ||
!CGO.MSSecureHotPatchFunctionsList.empty()) {
if (!CGO.MSSecureHotPatchFunctionsFile.empty()) {
auto BufOrErr =
llvm::MemoryBuffer::getFile(CGO.MSSecureHotPatchFunctionsFile);
if (BufOrErr) {
const llvm::MemoryBuffer &FileBuffer = **BufOrErr;
for (llvm::line_iterator I(FileBuffer.getMemBufferRef(), true), E;
I != E; ++I)
this->MSHotPatchFunctions.push_back(std::string{*I});
} else {
auto &DE = Context.getDiagnostics();
unsigned DiagID =
DE.getCustomDiagID(DiagnosticsEngine::Error,
"failed to open hotpatch functions file "
"(-fms-hotpatch-functions-file): %0 : %1");
DE.Report(DiagID) << CGO.MSSecureHotPatchFunctionsFile
<< BufOrErr.getError().message();
}
}

for (const auto &FuncName : CGO.MSSecureHotPatchFunctionsList)
this->MSHotPatchFunctions.push_back(FuncName);

llvm::sort(this->MSHotPatchFunctions);
}
}

CodeGenModule::~CodeGenModule() {}
Expand Down
5 changes: 0 additions & 5 deletions clang/lib/CodeGen/CodeGenModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -678,11 +678,6 @@ class CodeGenModule : public CodeGenTypeCache {

AtomicOptions AtomicOpts;

// A set of functions which should be hot-patched; see
// -fms-hotpatch-functions-file (and -list). This will nearly always be empty.
// The list is sorted for binary-searching.
std::vector<std::string> MSHotPatchFunctions;

public:
CodeGenModule(ASTContext &C, IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
const HeaderSearchOptions &headersearchopts,
Expand Down
8 changes: 0 additions & 8 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6803,14 +6803,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,

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

if (Arg *A = Args.getLastArg(options::OPT_fms_secure_hotpatch_functions_file))
Args.AddLastArg(CmdArgs, options::OPT_fms_secure_hotpatch_functions_file);

for (const auto &A :
Args.getAllArgValues(options::OPT_fms_secure_hotpatch_functions_list))
CmdArgs.push_back(
Args.MakeArgString("-fms-secure-hotpatch-functions-list=" + Twine(A)));

if (TC.SupportsProfiling()) {
Args.AddLastArg(CmdArgs, options::OPT_pg);

Expand Down
18 changes: 0 additions & 18 deletions clang/test/CodeGen/X86/ms-secure-hotpatch-bad-file.c

This file was deleted.

24 changes: 0 additions & 24 deletions clang/test/CodeGen/X86/ms-secure-hotpatch-cpp.cpp

This file was deleted.

26 changes: 0 additions & 26 deletions clang/test/CodeGen/X86/ms-secure-hotpatch-eh.cpp

This file was deleted.

135 changes: 0 additions & 135 deletions clang/test/CodeGen/X86/ms-secure-hotpatch-globals.c

This file was deleted.

26 changes: 0 additions & 26 deletions clang/test/CodeGen/X86/ms-secure-hotpatch-lto.c

This file was deleted.

23 changes: 0 additions & 23 deletions clang/test/CodeGen/X86/ms-secure-hotpatch.c

This file was deleted.

3 changes: 0 additions & 3 deletions llvm/include/llvm/CodeGen/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,6 @@ LLVM_ABI FunctionPass *createSelectOptimizePass();

LLVM_ABI FunctionPass *createCallBrPass();

/// Creates Windows Secure Hot Patch pass. \see WindowsSecureHotPatching.cpp
ModulePass *createWindowsSecureHotPatchingPass();

/// Lowers KCFI operand bundles for indirect calls.
LLVM_ABI FunctionPass *createKCFIPass();
} // namespace llvm
Expand Down
2 changes: 0 additions & 2 deletions llvm/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ SYMBOL_RECORD_ALIAS(S_GTHREAD32 , 0x1113, GlobalTLS, ThreadLocalDataSym)
SYMBOL_RECORD(S_UNAMESPACE , 0x1124, UsingNamespaceSym)
SYMBOL_RECORD(S_ANNOTATION , 0x1019, AnnotationSym)

SYMBOL_RECORD(S_HOTPATCHFUNC , 0x1169, HotPatchFuncSym)

#undef CV_SYMBOL
#undef SYMBOL_RECORD
#undef SYMBOL_RECORD_ALIAS
Loading
Loading