<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">diff -rupN llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h llvm.patched/include/llvm/LTO/legacy/LTOCodeGenerator.h
--- llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h	2023-12-04 17:18:23.553941271 +0000
+++ llvm.patched/include/llvm/LTO/legacy/LTOCodeGenerator.h	2023-12-04 17:19:00.990403394 +0000
@@ -100,6 +100,10 @@ struct LTOCodeGenerator {
   void setCpu(StringRef MCpu) { Config.CPU = std::string(MCpu); }
   void setAttrs(std::vector&lt;std::string&gt; MAttrs) { Config.MAttrs = MAttrs; }
   void setOptLevel(unsigned OptLevel);
+  void setFunctionSections(bool Value) { Config.Options.FunctionSections = Value; }
+  void setDataSections(bool Value) { Config.Options.DataSections = Value; }
+  void setFloatingABIType(FloatABI::ABIType Value) { Config.Options.FloatABIType = Value; }
+  void setNoExceptions(bool Value) { Config.Options.NoExceptions = Value; }
 
   void setShouldInternalize(bool Value) { ShouldInternalize = Value; }
   void setShouldEmbedUselists(bool Value) { ShouldEmbedUselists = Value; }
diff -rupN llvm/include/llvm/Target/TargetOptions.h llvm.patched/include/llvm/Target/TargetOptions.h
--- llvm/include/llvm/Target/TargetOptions.h	2023-12-04 17:18:23.597941814 +0000
+++ llvm.patched/include/llvm/Target/TargetOptions.h	2023-12-04 17:19:00.990403394 +0000
@@ -132,7 +132,7 @@ namespace llvm {
           EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
           DisableIntegratedAS(false), RelaxELFRelocations(true),
           FunctionSections(false), DataSections(false),
-          IgnoreXCOFFVisibility(false), XCOFFTracebackTable(true),
+          IgnoreXCOFFVisibility(false), XCOFFTracebackTable(true), NoExceptions(false),
           UniqueSectionNames(true), UniqueBasicBlockSectionNames(false),
           TrapUnreachable(false), NoTrapAfterNoreturn(false), TLSSize(0),
           EmulatedTLS(false), EnableIPRA(false), EmitStackSizeSection(false),
@@ -266,6 +266,9 @@ namespace llvm {
     /// Emit XCOFF traceback table.
     unsigned XCOFFTracebackTable : 1;
 
+    /// No Exceptions
+    unsigned NoExceptions : 1;
+
     unsigned UniqueSectionNames : 1;
 
     /// Use unique names for basic block sections.
diff -rupN llvm/lib/CodeGen/LLVMTargetMachine.cpp llvm.patched/lib/CodeGen/LLVMTargetMachine.cpp
--- llvm/lib/CodeGen/LLVMTargetMachine.cpp	2023-12-04 17:18:29.142010237 +0000
+++ llvm.patched/lib/CodeGen/LLVMTargetMachine.cpp	2023-12-04 17:19:00.990403394 +0000
@@ -76,7 +76,7 @@ void LLVMTargetMachine::initAsmInfo() {
 
   TmpAsmInfo-&gt;setRelaxELFRelocations(Options.RelaxELFRelocations);
 
-  if (Options.ExceptionModel != ExceptionHandling::None)
+  if (Options.ExceptionModel != ExceptionHandling::None || Options.NoExceptions)
     TmpAsmInfo-&gt;setExceptionsType(Options.ExceptionModel);
 
   AsmInfo.reset(TmpAsmInfo);
diff -rupN llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp llvm.patched/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
--- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp	2023-12-04 17:18:29.174010632 +0000
+++ llvm.patched/lib/CodeGen/TargetLoweringObjectFileImpl.cpp	2023-12-04 17:19:00.994403444 +0000
@@ -615,18 +615,19 @@ static unsigned getEntrySizeForKind(Sect
 /// Return the section prefix name used by options FunctionsSections and
 /// DataSections.
 static StringRef getSectionPrefixForGlobal(SectionKind Kind, bool IsLarge) {
+  extern const char *bssName, *textName, *dataName, *rodataName;
   if (Kind.isText())
-    return ".text";
+    return textName;
   if (Kind.isReadOnly())
-    return IsLarge ? ".lrodata" : ".rodata";
+    return IsLarge ? ".lrodata" : rodataName;
   if (Kind.isBSS())
-    return IsLarge ? ".lbss" : ".bss";
+    return IsLarge ? ".lbss" : bssName;
   if (Kind.isThreadData())
     return ".tdata";
   if (Kind.isThreadBSS())
     return ".tbss";
   if (Kind.isData())
-    return IsLarge ? ".ldata" : ".data";
+    return IsLarge ? ".ldata" : dataName;
   if (Kind.isReadOnlyWithRel())
     return IsLarge ? ".ldata.rel.ro" : ".data.rel.ro";
   llvm_unreachable("Unknown section kind");
diff -rupN llvm/lib/MC/MCObjectFileInfo.cpp llvm.patched/lib/MC/MCObjectFileInfo.cpp
--- llvm/lib/MC/MCObjectFileInfo.cpp	2023-12-04 17:18:29.234011372 +0000
+++ llvm.patched/lib/MC/MCObjectFileInfo.cpp	2023-12-04 17:19:00.994403444 +0000
@@ -27,6 +27,11 @@
 
 using namespace llvm;
 
+const char *bssName = ".bss";
+const char *textName = ".text";
+const char *dataName = ".data";
+const char *rodataName = ".rodata";
+
 static bool useCompactUnwind(const Triple &amp;T) {
   // Only on darwin.
   if (!T.isOSDarwin())
@@ -381,17 +386,17 @@ void MCObjectFileInfo::initELFMCObjectFi
     EHSectionFlags |= ELF::SHF_WRITE;
 
   // ELF
-  BSSSection = Ctx-&gt;getELFSection(".bss", ELF::SHT_NOBITS,
+  BSSSection = Ctx-&gt;getELFSection(bssName, ELF::SHT_NOBITS,
                                   ELF::SHF_WRITE | ELF::SHF_ALLOC);
 
-  TextSection = Ctx-&gt;getELFSection(".text", ELF::SHT_PROGBITS,
+  TextSection = Ctx-&gt;getELFSection(textName, ELF::SHT_PROGBITS,
                                    ELF::SHF_EXECINSTR | ELF::SHF_ALLOC);
 
-  DataSection = Ctx-&gt;getELFSection(".data", ELF::SHT_PROGBITS,
+  DataSection = Ctx-&gt;getELFSection(dataName, ELF::SHT_PROGBITS,
                                    ELF::SHF_WRITE | ELF::SHF_ALLOC);
 
   ReadOnlySection =
-      Ctx-&gt;getELFSection(".rodata", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
+      Ctx-&gt;getELFSection(rodataName, ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
 
   TLSDataSection =
       Ctx-&gt;getELFSection(".tdata", ELF::SHT_PROGBITS,
diff -rupN llvm/tools/lto/lto.cpp llvm.patched/tools/lto/lto.cpp
--- llvm/tools/lto/lto.cpp	2023-12-04 17:18:29.086009546 +0000
+++ llvm.patched/tools/lto/lto.cpp	2023-12-04 17:19:00.994403444 +0000
@@ -43,6 +43,10 @@ static cl::opt&lt;bool&gt; EnableFreestanding(
     "lto-freestanding", cl::init(false),
     cl::desc("Enable Freestanding (disable builtins / TLI) during LTO"));
 
+static cl::opt&lt;bool&gt; NoExceptions(
+    "no-exceptions", cl::init(false),
+    cl::desc("Do not generate exception tables"));
+
 #ifdef NDEBUG
 static bool VerifyByDefault = false;
 #else
@@ -155,6 +159,11 @@ static void lto_add_attrs(lto_code_gen_t
   CG-&gt;setOptLevel(OptLevel - '0');
   CG-&gt;setFreestanding(EnableFreestanding);
   CG-&gt;setDisableVerify(DisableVerify);
+  CG-&gt;setFunctionSections(codegen::getFunctionSections());
+  CG-&gt;setDataSections(codegen::getDataSections());
+  CG-&gt;setFloatingABIType(codegen::getFloatABIForCalls());
+  CG-&gt;setNoExceptions(NoExceptions);
+  if (auto FT = codegen::getExplicitFileType()) CG-&gt;setFileType(*FT);
 }
 
 extern const char* lto_get_version() {
diff -rupN clang/include/clang/Driver/Options.td clang.patched/include/clang/Driver/Options.td
--- clang/include/clang/Driver/Options.td	2023-12-04 17:18:30.758030182 +0000
+++ clang.patched/include/clang/Driver/Options.td	2023-12-04 17:19:00.998403493 +0000
@@ -6763,6 +6763,23 @@ def fno_cuda_host_device_constexpr : Fla
 } // let Flags = [CC1Option, NoDriverOption]
 
 //===----------------------------------------------------------------------===//
+// Section Naming Options
+//===----------------------------------------------------------------------===//
+
+let Flags = [CC1Option, NoDriverOption] in {
+
+def mbss_EQ : Joined&lt;["-"], "mbss="&gt;,
+  HelpText&lt;"name the .bss section"&gt;;
+def mdata_EQ : Joined&lt;["-"], "mdata="&gt;,
+  HelpText&lt;"name the .data section"&gt;;
+def mrodata_EQ : Joined&lt;["-"], "mrodata="&gt;,
+  HelpText&lt;"name the .rodata section"&gt;;
+def mtext_EQ : Joined&lt;["-"], "mtext="&gt;,
+  HelpText&lt;"name the .text section"&gt;;
+
+} // let Flags = [CC1Option, NoDriverOption]
+
+//===----------------------------------------------------------------------===//
 // OpenMP Options
 //===----------------------------------------------------------------------===//
 
diff -rupN clang/lib/CodeGen/BackendUtil.cpp clang.patched/lib/CodeGen/BackendUtil.cpp
--- clang/lib/CodeGen/BackendUtil.cpp	2023-12-04 17:18:30.830031071 +0000
+++ clang.patched/lib/CodeGen/BackendUtil.cpp	2023-12-04 17:19:00.998403493 +0000
@@ -384,6 +384,8 @@ static bool initTargetOptions(Diagnostic
     Options.ExceptionModel = llvm::ExceptionHandling::WinEH;
   if (LangOpts.hasDWARFExceptions())
     Options.ExceptionModel = llvm::ExceptionHandling::DwarfCFI;
+  if (!LangOpts.Exceptions &amp;&amp; !LangOpts.CXXExceptions &amp;&amp; !CodeGenOpts.UnwindTables)
+    Options.NoExceptions = true;
   if (LangOpts.hasWasmExceptions())
     Options.ExceptionModel = llvm::ExceptionHandling::Wasm;
 
diff -rupN clang/lib/Frontend/CompilerInvocation.cpp clang.patched/lib/Frontend/CompilerInvocation.cpp
--- clang/lib/Frontend/CompilerInvocation.cpp	2023-12-04 17:18:30.878031663 +0000
+++ clang.patched/lib/Frontend/CompilerInvocation.cpp	2023-12-04 17:19:01.002403542 +0000
@@ -932,6 +932,11 @@ static void GenerateAnalyzerArgs(Analyze
   // Nothing to generate for FullCompilerInvocation.
 }
 
+extern const char *bssName;
+extern const char *textName;
+extern const char *dataName;
+extern const char *rodataName;
+
 static bool ParseAnalyzerArgs(AnalyzerOptions &amp;Opts, ArgList &amp;Args,
                               DiagnosticsEngine &amp;Diags) {
   unsigned NumErrorsBefore = Diags.getNumErrors();
@@ -1969,6 +1974,19 @@ bool CompilerInvocation::ParseCodeGenArg
     NeedLocTracking = true;
   }
 
+  if (Arg *A = Args.getLastArg(OPT_mbss_EQ)) {
+    bssName = A-&gt;getValue();
+  }
+  if (Arg *A = Args.getLastArg(OPT_mdata_EQ)) {
+    dataName = A-&gt;getValue();
+  }
+  if (Arg *A = Args.getLastArg(OPT_mrodata_EQ)) {
+    rodataName = A-&gt;getValue();
+  }
+  if (Arg *A = Args.getLastArg(OPT_mtext_EQ)) {
+    textName = A-&gt;getValue();
+  }
+
   Opts.OptimizationRemark =
       ParseOptimizationRemark(Diags, Args, OPT_Rpass_EQ, "pass");
 
diff -rupN clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp clang.patched/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
--- clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp	2023-12-04 17:18:30.974032848 +0000
+++ clang.patched/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp	2023-12-04 17:19:01.002403542 +0000
@@ -54,23 +54,46 @@ static const SymbolHeaderMapping *getMap
   return LanguageMappings[static_cast&lt;unsigned&gt;(L)];
 }
 
+// Workaround 'SEH unwind data splitting not yet implemented' error when building Windows/arm64 version
+#define SYMBOL(Name, NS, Header) Set.insert(#NS #Name);
+
+static void insertCSymbolMap(llvm::DenseSet&lt;llvm::StringRef&gt; &amp;Set)
+{
+#include "CSymbolMap.inc"
+}
+
+static void insertStdSpecialSymbolMap(llvm::DenseSet&lt;llvm::StringRef&gt; &amp;Set)
+{
+#include "StdSpecialSymbolMap.inc"
+}
+
+static void insertStdSymbolMap(llvm::DenseSet&lt;llvm::StringRef&gt; &amp;Set)
+{
+#include "StdSymbolMap.inc"
+}
+
+static void insertStdTsSymbolMap(llvm::DenseSet&lt;llvm::StringRef&gt; &amp;Set)
+{
+#include "StdTsSymbolMap.inc"
+}
+
 static int countSymbols(Lang Language) {
   llvm::DenseSet&lt;llvm::StringRef&gt; Set;
-#define SYMBOL(Name, NS, Header) Set.insert(#NS #Name);
   switch (Language) {
   case Lang::C:
-#include "CSymbolMap.inc"
+    insertCSymbolMap(Set);
     break;
   case Lang::CXX:
-#include "StdSpecialSymbolMap.inc"
-#include "StdSymbolMap.inc"
-#include "StdTsSymbolMap.inc"
+    insertStdSpecialSymbolMap(Set);
+    insertStdSymbolMap(Set);
+    insertStdTsSymbolMap(Set);
     break;
   }
-#undef SYMBOL
   return Set.size();
 }
 
+#undef SYMBOL
+
 static int initialize(Lang Language) {
   SymbolHeaderMapping *Mapping = new SymbolHeaderMapping();
   LanguageMappings[static_cast&lt;unsigned&gt;(Language)] = Mapping;
</pre></body></html>