[llvm] 470a599 - [ORC] Move MachO object format details into their own header (NFC).
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 22 09:23:56 PDT 2024
Author: Lang Hames
Date: 2024-10-22T09:23:48-07:00
New Revision: 470a5991920730242acd18c90449d77fabdada63
URL: https://github.com/llvm/llvm-project/commit/470a5991920730242acd18c90449d77fabdada63
DIFF: https://github.com/llvm/llvm-project/commit/470a5991920730242acd18c90449d77fabdada63.diff
LOG: [ORC] Move MachO object format details into their own header (NFC).
Added:
llvm/include/llvm/ExecutionEngine/Orc/Shared/MachOObjectFormat.h
llvm/lib/ExecutionEngine/Orc/Shared/MachOObjectFormat.cpp
Modified:
llvm/include/llvm/ExecutionEngine/Orc/Shared/ObjectFormats.h
llvm/lib/ExecutionEngine/Orc/Shared/CMakeLists.txt
llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/MachOObjectFormat.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/MachOObjectFormat.h
new file mode 100644
index 00000000000000..f886203f8e3fb5
--- /dev/null
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/MachOObjectFormat.h
@@ -0,0 +1,64 @@
+//===---- MachOObjectFormat.h - MachO format details for ORC ----*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// ORC-specific MachO object format details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_EXECUTIONENGINE_ORC_SHARED_MACHOOBJECTFORMAT_H
+#define LLVM_EXECUTIONENGINE_ORC_SHARED_MACHOOBJECTFORMAT_H
+
+#include "llvm/ADT/StringRef.h"
+
+namespace llvm {
+namespace orc {
+
+// FIXME: Move these to BinaryFormat?
+
+// MachO section names.
+
+extern StringRef MachODataCommonSectionName;
+extern StringRef MachODataDataSectionName;
+extern StringRef MachOEHFrameSectionName;
+extern StringRef MachOCompactUnwindInfoSectionName;
+extern StringRef MachOCStringSectionName;
+extern StringRef MachOModInitFuncSectionName;
+extern StringRef MachOObjCCatListSectionName;
+extern StringRef MachOObjCCatList2SectionName;
+extern StringRef MachOObjCClassListSectionName;
+extern StringRef MachOObjCClassNameSectionName;
+extern StringRef MachOObjCClassRefsSectionName;
+extern StringRef MachOObjCConstSectionName;
+extern StringRef MachOObjCDataSectionName;
+extern StringRef MachOObjCImageInfoSectionName;
+extern StringRef MachOObjCMethNameSectionName;
+extern StringRef MachOObjCMethTypeSectionName;
+extern StringRef MachOObjCNLCatListSectionName;
+extern StringRef MachOObjCNLClassListSectionName;
+extern StringRef MachOObjCProtoListSectionName;
+extern StringRef MachOObjCProtoRefsSectionName;
+extern StringRef MachOObjCSelRefsSectionName;
+extern StringRef MachOSwift5ProtoSectionName;
+extern StringRef MachOSwift5ProtosSectionName;
+extern StringRef MachOSwift5TypesSectionName;
+extern StringRef MachOSwift5TypeRefSectionName;
+extern StringRef MachOSwift5FieldMetadataSectionName;
+extern StringRef MachOSwift5EntrySectionName;
+extern StringRef MachOThreadBSSSectionName;
+extern StringRef MachOThreadDataSectionName;
+extern StringRef MachOThreadVarsSectionName;
+
+extern StringRef MachOInitSectionNames[22];
+
+bool isMachOInitializerSection(StringRef SegName, StringRef SecName);
+bool isMachOInitializerSection(StringRef QualifiedName);
+
+} // end namespace orc
+} // end namespace llvm
+
+#endif // LLVM_EXECUTIONENGINE_ORC_SHARED_MACHOOBJECTFORMAT_H
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/ObjectFormats.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/ObjectFormats.h
index ebd6ead8324e6b..2773758970b511 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Shared/ObjectFormats.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/ObjectFormats.h
@@ -14,45 +14,11 @@
#define LLVM_EXECUTIONENGINE_ORC_SHARED_OBJECTFORMATS_H
#include "llvm/ADT/StringRef.h"
+#include "llvm/ExecutionEngine/Orc/Shared/MachOObjectFormat.h"
namespace llvm {
namespace orc {
-// MachO section names.
-
-extern StringRef MachODataCommonSectionName;
-extern StringRef MachODataDataSectionName;
-extern StringRef MachOEHFrameSectionName;
-extern StringRef MachOCompactUnwindInfoSectionName;
-extern StringRef MachOCStringSectionName;
-extern StringRef MachOModInitFuncSectionName;
-extern StringRef MachOObjCCatListSectionName;
-extern StringRef MachOObjCCatList2SectionName;
-extern StringRef MachOObjCClassListSectionName;
-extern StringRef MachOObjCClassNameSectionName;
-extern StringRef MachOObjCClassRefsSectionName;
-extern StringRef MachOObjCConstSectionName;
-extern StringRef MachOObjCDataSectionName;
-extern StringRef MachOObjCImageInfoSectionName;
-extern StringRef MachOObjCMethNameSectionName;
-extern StringRef MachOObjCMethTypeSectionName;
-extern StringRef MachOObjCNLCatListSectionName;
-extern StringRef MachOObjCNLClassListSectionName;
-extern StringRef MachOObjCProtoListSectionName;
-extern StringRef MachOObjCProtoRefsSectionName;
-extern StringRef MachOObjCSelRefsSectionName;
-extern StringRef MachOSwift5ProtoSectionName;
-extern StringRef MachOSwift5ProtosSectionName;
-extern StringRef MachOSwift5TypesSectionName;
-extern StringRef MachOSwift5TypeRefSectionName;
-extern StringRef MachOSwift5FieldMetadataSectionName;
-extern StringRef MachOSwift5EntrySectionName;
-extern StringRef MachOThreadBSSSectionName;
-extern StringRef MachOThreadDataSectionName;
-extern StringRef MachOThreadVarsSectionName;
-
-extern StringRef MachOInitSectionNames[22];
-
// ELF section names.
extern StringRef ELFEHFrameSectionName;
@@ -68,9 +34,6 @@ extern StringRef ELFInitSectionNames[3];
extern StringRef ELFThreadBSSSectionName;
extern StringRef ELFThreadDataSectionName;
-bool isMachOInitializerSection(StringRef SegName, StringRef SecName);
-bool isMachOInitializerSection(StringRef QualifiedName);
-
bool isELFInitializerSection(StringRef SecName);
bool isCOFFInitializerSection(StringRef Name);
diff --git a/llvm/lib/ExecutionEngine/Orc/Shared/CMakeLists.txt b/llvm/lib/ExecutionEngine/Orc/Shared/CMakeLists.txt
index 985ac6f1409e66..f4e4a6b4f53fce 100644
--- a/llvm/lib/ExecutionEngine/Orc/Shared/CMakeLists.txt
+++ b/llvm/lib/ExecutionEngine/Orc/Shared/CMakeLists.txt
@@ -1,5 +1,6 @@
add_llvm_component_library(LLVMOrcShared
AllocationActions.cpp
+ MachOObjectFormat.cpp
ObjectFormats.cpp
OrcError.cpp
OrcRTBridge.cpp
diff --git a/llvm/lib/ExecutionEngine/Orc/Shared/MachOObjectFormat.cpp b/llvm/lib/ExecutionEngine/Orc/Shared/MachOObjectFormat.cpp
new file mode 100644
index 00000000000000..7f4c2934d026ad
--- /dev/null
+++ b/llvm/lib/ExecutionEngine/Orc/Shared/MachOObjectFormat.cpp
@@ -0,0 +1,75 @@
+//===-------- MachOObjectFormat.cpp -- MachO format details for ORC -------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// ORC-specific MachO object format details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ExecutionEngine/Orc/Shared/MachOObjectFormat.h"
+
+namespace llvm {
+namespace orc {
+
+StringRef MachODataCommonSectionName = "__DATA,__common";
+StringRef MachODataDataSectionName = "__DATA,__data";
+StringRef MachOEHFrameSectionName = "__TEXT,__eh_frame";
+StringRef MachOCompactUnwindInfoSectionName = "__TEXT,__unwind_info";
+StringRef MachOCStringSectionName = "__TEXT,__cstring";
+StringRef MachOModInitFuncSectionName = "__DATA,__mod_init_func";
+StringRef MachOObjCCatListSectionName = "__DATA,__objc_catlist";
+StringRef MachOObjCCatList2SectionName = "__DATA,__objc_catlist2";
+StringRef MachOObjCClassListSectionName = "__DATA,__objc_classlist";
+StringRef MachOObjCClassNameSectionName = "__TEXT,__objc_classname";
+StringRef MachOObjCClassRefsSectionName = "__DATA,__objc_classrefs";
+StringRef MachOObjCConstSectionName = "__DATA,__objc_const";
+StringRef MachOObjCDataSectionName = "__DATA,__objc_data";
+StringRef MachOObjCImageInfoSectionName = "__DATA,__objc_imageinfo";
+StringRef MachOObjCMethNameSectionName = "__TEXT,__objc_methname";
+StringRef MachOObjCMethTypeSectionName = "__TEXT,__objc_methtype";
+StringRef MachOObjCNLCatListSectionName = "__DATA,__objc_nlcatlist";
+StringRef MachOObjCNLClassListSectionName = "__DATA,__objc_nlclslist";
+StringRef MachOObjCProtoListSectionName = "__DATA,__objc_protolist";
+StringRef MachOObjCProtoRefsSectionName = "__DATA,__objc_protorefs";
+StringRef MachOObjCSelRefsSectionName = "__DATA,__objc_selrefs";
+StringRef MachOSwift5ProtoSectionName = "__TEXT,__swift5_proto";
+StringRef MachOSwift5ProtosSectionName = "__TEXT,__swift5_protos";
+StringRef MachOSwift5TypesSectionName = "__TEXT,__swift5_types";
+StringRef MachOSwift5TypeRefSectionName = "__TEXT,__swift5_typeref";
+StringRef MachOSwift5FieldMetadataSectionName = "__TEXT,__swift5_fieldmd";
+StringRef MachOSwift5EntrySectionName = "__TEXT,__swift5_entry";
+StringRef MachOThreadBSSSectionName = "__DATA,__thread_bss";
+StringRef MachOThreadDataSectionName = "__DATA,__thread_data";
+StringRef MachOThreadVarsSectionName = "__DATA,__thread_vars";
+
+StringRef MachOInitSectionNames[22] = {
+ MachOModInitFuncSectionName, MachOObjCCatListSectionName,
+ MachOObjCCatList2SectionName, MachOObjCClassListSectionName,
+ MachOObjCClassNameSectionName, MachOObjCClassRefsSectionName,
+ MachOObjCConstSectionName, MachOObjCDataSectionName,
+ MachOObjCImageInfoSectionName, MachOObjCMethNameSectionName,
+ MachOObjCMethTypeSectionName, MachOObjCNLCatListSectionName,
+ MachOObjCNLClassListSectionName, MachOObjCProtoListSectionName,
+ MachOObjCProtoRefsSectionName, MachOObjCSelRefsSectionName,
+ MachOSwift5ProtoSectionName, MachOSwift5ProtosSectionName,
+ MachOSwift5TypesSectionName, MachOSwift5TypeRefSectionName,
+ MachOSwift5FieldMetadataSectionName, MachOSwift5EntrySectionName,
+};
+
+bool isMachOInitializerSection(StringRef SegName, StringRef SecName) {
+ for (auto &InitSection : MachOInitSectionNames) {
+ // Loop below assumes all MachO init sectios have a length-6
+ // segment name.
+ assert(InitSection[6] == ',' && "Init section seg name has length != 6");
+ if (InitSection.starts_with(SegName) && InitSection.substr(7) == SecName)
+ return true;
+ }
+ return false;
+}
+
+} // namespace orc
+} // namespace llvm
diff --git a/llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp b/llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp
index f94f4832c5409c..3bd6c1e5be2cf5 100644
--- a/llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp
@@ -15,51 +15,6 @@
namespace llvm {
namespace orc {
-StringRef MachODataCommonSectionName = "__DATA,__common";
-StringRef MachODataDataSectionName = "__DATA,__data";
-StringRef MachOEHFrameSectionName = "__TEXT,__eh_frame";
-StringRef MachOCompactUnwindInfoSectionName = "__TEXT,__unwind_info";
-StringRef MachOCStringSectionName = "__TEXT,__cstring";
-StringRef MachOModInitFuncSectionName = "__DATA,__mod_init_func";
-StringRef MachOObjCCatListSectionName = "__DATA,__objc_catlist";
-StringRef MachOObjCCatList2SectionName = "__DATA,__objc_catlist2";
-StringRef MachOObjCClassListSectionName = "__DATA,__objc_classlist";
-StringRef MachOObjCClassNameSectionName = "__TEXT,__objc_classname";
-StringRef MachOObjCClassRefsSectionName = "__DATA,__objc_classrefs";
-StringRef MachOObjCConstSectionName = "__DATA,__objc_const";
-StringRef MachOObjCDataSectionName = "__DATA,__objc_data";
-StringRef MachOObjCImageInfoSectionName = "__DATA,__objc_imageinfo";
-StringRef MachOObjCMethNameSectionName = "__TEXT,__objc_methname";
-StringRef MachOObjCMethTypeSectionName = "__TEXT,__objc_methtype";
-StringRef MachOObjCNLCatListSectionName = "__DATA,__objc_nlcatlist";
-StringRef MachOObjCNLClassListSectionName = "__DATA,__objc_nlclslist";
-StringRef MachOObjCProtoListSectionName = "__DATA,__objc_protolist";
-StringRef MachOObjCProtoRefsSectionName = "__DATA,__objc_protorefs";
-StringRef MachOObjCSelRefsSectionName = "__DATA,__objc_selrefs";
-StringRef MachOSwift5ProtoSectionName = "__TEXT,__swift5_proto";
-StringRef MachOSwift5ProtosSectionName = "__TEXT,__swift5_protos";
-StringRef MachOSwift5TypesSectionName = "__TEXT,__swift5_types";
-StringRef MachOSwift5TypeRefSectionName = "__TEXT,__swift5_typeref";
-StringRef MachOSwift5FieldMetadataSectionName = "__TEXT,__swift5_fieldmd";
-StringRef MachOSwift5EntrySectionName = "__TEXT,__swift5_entry";
-StringRef MachOThreadBSSSectionName = "__DATA,__thread_bss";
-StringRef MachOThreadDataSectionName = "__DATA,__thread_data";
-StringRef MachOThreadVarsSectionName = "__DATA,__thread_vars";
-
-StringRef MachOInitSectionNames[22] = {
- MachOModInitFuncSectionName, MachOObjCCatListSectionName,
- MachOObjCCatList2SectionName, MachOObjCClassListSectionName,
- MachOObjCClassNameSectionName, MachOObjCClassRefsSectionName,
- MachOObjCConstSectionName, MachOObjCDataSectionName,
- MachOObjCImageInfoSectionName, MachOObjCMethNameSectionName,
- MachOObjCMethTypeSectionName, MachOObjCNLCatListSectionName,
- MachOObjCNLClassListSectionName, MachOObjCProtoListSectionName,
- MachOObjCProtoRefsSectionName, MachOObjCSelRefsSectionName,
- MachOSwift5ProtoSectionName, MachOSwift5ProtosSectionName,
- MachOSwift5TypesSectionName, MachOSwift5TypeRefSectionName,
- MachOSwift5FieldMetadataSectionName, MachOSwift5EntrySectionName,
-};
-
StringRef ELFEHFrameSectionName = ".eh_frame";
StringRef ELFInitArrayFuncSectionName = ".init_array";
@@ -78,17 +33,6 @@ StringRef ELFInitSectionNames[3]{
StringRef ELFThreadBSSSectionName = ".tbss";
StringRef ELFThreadDataSectionName = ".tdata";
-bool isMachOInitializerSection(StringRef SegName, StringRef SecName) {
- for (auto &InitSection : MachOInitSectionNames) {
- // Loop below assumes all MachO init sectios have a length-6
- // segment name.
- assert(InitSection[6] == ',' && "Init section seg name has length != 6");
- if (InitSection.starts_with(SegName) && InitSection.substr(7) == SecName)
- return true;
- }
- return false;
-}
-
bool isMachOInitializerSection(StringRef QualifiedName) {
for (auto &InitSection : MachOInitSectionNames)
if (InitSection == QualifiedName)
More information about the llvm-commits
mailing list