[llvm] 2766f21 - [ORC] Loosen __objc_imageinfo flag merging to match ld (#91767)
via llvm-commits
llvm-commits at lists.llvm.org
Tue May 14 08:08:22 PDT 2024
Author: Ben Langmuir
Date: 2024-05-14T08:08:18-07:00
New Revision: 2766f2174e428842a9ab1a9ba5b320be5878f87d
URL: https://github.com/llvm/llvm-project/commit/2766f2174e428842a9ab1a9ba5b320be5878f87d
DIFF: https://github.com/llvm/llvm-project/commit/2766f2174e428842a9ab1a9ba5b320be5878f87d.diff
LOG: [ORC] Loosen __objc_imageinfo flag merging to match ld (#91767)
Allow mixing objects with/without signed class ro data and category
class properties as long as it happens before we register the metadata.
These combinations are a warning in ld, not a hard error. The only case
that is ABI-breaking is if we already registered with the feature
enabled but later try to load an object that doesn't support it.
rdar://127336061
Added:
Modified:
compiler-rt/test/orc/TestCases/Darwin/arm64/objc-imageinfo.S
compiler-rt/test/orc/TestCases/Darwin/x86-64/objc-imageinfo.S
llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/orc/TestCases/Darwin/arm64/objc-imageinfo.S b/compiler-rt/test/orc/TestCases/Darwin/arm64/objc-imageinfo.S
index d58943f9681da..2ee7d3f5eac17 100644
--- a/compiler-rt/test/orc/TestCases/Darwin/arm64/objc-imageinfo.S
+++ b/compiler-rt/test/orc/TestCases/Darwin/arm64/objc-imageinfo.S
@@ -27,9 +27,6 @@
// Check error conditions.
-// RUN: not %llvm_jitlink %t/main.o %t/objc_old.o %t/objc_new.o 2>&1 | FileCheck %s -check-prefix=CATEGORY
-// CATEGORY: ObjC category class property support in {{.*}} does not match first registered flags
-
// RUN: not %llvm_jitlink %t/main.o %t/swift_4.o %t/swift_5.o 2>&1 | FileCheck %s -check-prefix=SWIFT_ABI
// SWIFT_ABI: Swift ABI version in {{.*}} does not match first registered flags
@@ -47,6 +44,14 @@
// RUN: %llvm_jitlink -debug-only=orc %t/main.o %t/swift_59.o %t/swift_5.o %t/objc_new.o 2>&1 | FileCheck %s -check-prefix=SWIFT_MIX3
// SWIFT_MIX3: MachOPlatform: Merging __objc_imageinfo flags for main {{.*}} -> 0x5000740
+// Disable categories.
+// RUN: %llvm_jitlink -debug-only=orc %t/main.o %t/objc_old.o %t/objc_new.o 2>&1 | FileCheck %s -check-prefix=SWIFT_MIX4
+// SWIFT_MIX4: MachOPlatform: Merging __objc_imageinfo flags for main {{.*}} -> 0x0000
+
+// Disable signed class_ro.
+// RUN: %llvm_jitlink -debug-only=orc %t/main.o %t/objc_new.o %t/objc_new_signed_ro.o 2>&1 | FileCheck %s -check-prefix=SWIFT_MIX5
+// SWIFT_MIX5: MachOPlatform: Merging __objc_imageinfo flags for main {{.*}} -> 0x0040
+
//--- main.S
.section __TEXT,__text,regular,pure_instructions
.globl _main
@@ -76,6 +81,17 @@ L_OBJC_IMAGE_INFO:
.long 0
.long 64
+//--- objc_new_signed_ro.S
+.section __TEXT,__text,regular,pure_instructions
+.globl _objc3
+_objc3:
+ ret
+
+ .section __DATA,__objc_imageinfo,regular,no_dead_strip
+L_OBJC_IMAGE_INFO:
+ .long 0
+ .long 80
+
//--- swift_4.S
.section __TEXT,__text,regular,pure_instructions
.globl _swift4
diff --git a/compiler-rt/test/orc/TestCases/Darwin/x86-64/objc-imageinfo.S b/compiler-rt/test/orc/TestCases/Darwin/x86-64/objc-imageinfo.S
index 90b5c3a38eebe..d4e9b4b05fb88 100644
--- a/compiler-rt/test/orc/TestCases/Darwin/x86-64/objc-imageinfo.S
+++ b/compiler-rt/test/orc/TestCases/Darwin/x86-64/objc-imageinfo.S
@@ -27,9 +27,6 @@
// Check error conditions.
-// RUN: not %llvm_jitlink %t/main.o %t/objc_old.o %t/objc_new.o 2>&1 | FileCheck %s -check-prefix=CATEGORY
-// CATEGORY: ObjC category class property support in {{.*}} does not match first registered flags
-
// RUN: not %llvm_jitlink %t/main.o %t/swift_4.o %t/swift_5.o 2>&1 | FileCheck %s -check-prefix=SWIFT_ABI
// SWIFT_ABI: Swift ABI version in {{.*}} does not match first registered flags
@@ -47,6 +44,14 @@
// RUN: %llvm_jitlink -debug-only=orc %t/main.o %t/swift_59.o %t/swift_5.o %t/objc_new.o 2>&1 | FileCheck %s -check-prefix=SWIFT_MIX3
// SWIFT_MIX3: MachOPlatform: Merging __objc_imageinfo flags for main {{.*}} -> 0x5000740
+// Disable categories.
+// RUN: %llvm_jitlink -debug-only=orc %t/main.o %t/objc_old.o %t/objc_new.o 2>&1 | FileCheck %s -check-prefix=SWIFT_MIX4
+// SWIFT_MIX4: MachOPlatform: Merging __objc_imageinfo flags for main {{.*}} -> 0x0000
+
+// Disable signed class_ro.
+// RUN: %llvm_jitlink -debug-only=orc %t/main.o %t/objc_new.o %t/objc_new_signed_ro.o 2>&1 | FileCheck %s -check-prefix=SWIFT_MIX5
+// SWIFT_MIX5: MachOPlatform: Merging __objc_imageinfo flags for main {{.*}} -> 0x0040
+
//--- main.S
.section __TEXT,__text,regular,pure_instructions
.globl _main
@@ -76,6 +81,17 @@ L_OBJC_IMAGE_INFO:
.long 0
.long 64
+//--- objc_new_signed_ro.S
+.section __TEXT,__text,regular,pure_instructions
+.globl _objc3
+_objc3:
+ ret
+
+ .section __DATA,__objc_imageinfo,regular,no_dead_strip
+L_OBJC_IMAGE_INFO:
+ .long 0
+ .long 80
+
//--- swift_4.S
.section __TEXT,__text,regular,pure_instructions
.globl _swift4
diff --git a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
index 1fa8a1274911c..2b397b2d48e7d 100644
--- a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
@@ -1134,12 +1134,16 @@ Error MachOPlatform::MachOPlatformPlugin::mergeImageInfoFlags(
" does not match first registered flags",
inconvertibleErrorCode());
- if (Old.HasCategoryClassProperties != New.HasCategoryClassProperties)
+ // HasCategoryClassProperties and HasSignedObjCClassROs can be disabled before
+ // they are registered, if necessary, but once they are in use must be
+ // supported by subsequent objects.
+ if (Info.Finalized && Old.HasCategoryClassProperties &&
+ !New.HasCategoryClassProperties)
return make_error<StringError>("ObjC category class property support in " +
G.getName() +
" does not match first registered flags",
inconvertibleErrorCode());
- if (Old.HasSignedObjCClassROs != New.HasSignedObjCClassROs)
+ if (Info.Finalized && Old.HasSignedObjCClassROs && !New.HasSignedObjCClassROs)
return make_error<StringError>("ObjC class_ro_t pointer signing in " +
G.getName() +
" does not match first registered flags",
@@ -1158,6 +1162,12 @@ Error MachOPlatform::MachOPlatformPlugin::mergeImageInfoFlags(
// Add a Swift ABI version if it was pure objc before.
if (!New.SwiftABIVersion)
New.SwiftABIVersion = Old.SwiftABIVersion;
+ // Disable class properties if any object does not support it.
+ if (Old.HasCategoryClassProperties != New.HasCategoryClassProperties)
+ New.HasCategoryClassProperties = false;
+ // Disable signed class ro data if any object does not support it.
+ if (Old.HasSignedObjCClassROs != New.HasSignedObjCClassROs)
+ New.HasSignedObjCClassROs = false;
LLVM_DEBUG({
dbgs() << "MachOPlatform: Merging __objc_imageinfo flags for "
More information about the llvm-commits
mailing list