--- /dev/null
+ .section __TEXT,__text,regular,pure_instructions
+ .build_version macos, 14, 0 sdk_version 14, 0
+ .p2align 2
+"+[Foo foo]":
+ mov w0, wzr
+ ret
+
+ .section __TEXT,__objc_classname,cstring_literals
+l_OBJC_CLASS_NAME_:
+ .asciz "Foo"
+
+ .section __TEXT,__objc_methname,cstring_literals
+l_OBJC_METH_VAR_NAME_:
+ .asciz "foo"
+
+ .section __TEXT,__objc_methtype,cstring_literals
+l_OBJC_METH_VAR_TYPE_:
+ .asciz "i16@0:8"
+
+ .section __DATA,__objc_const
+ .p2align 3
+__OBJC_$_CLASS_METHODS_Foo:
+ .long 24
+ .long 1
+ .quad l_OBJC_METH_VAR_NAME_
+ .quad l_OBJC_METH_VAR_TYPE_
+ .quad "+[Foo foo]"
+
+ .p2align 3
+__OBJC_METACLASS_RO_$_Foo:
+ .long 1
+ .long 40
+ .long 40
+ .space 4
+ .quad 0
+ .quad l_OBJC_CLASS_NAME_
+ .quad __OBJC_$_CLASS_METHODS_Foo
+ .quad 0
+ .quad 0
+ .quad 0
+ .quad 0
+
+ .section __DATA,__objc_data
+ .globl _OBJC_METACLASS_$_Foo
+ .p2align 3
+_OBJC_METACLASS_$_Foo:
+ .quad _OBJC_METACLASS_$_NSObject
+ .quad _OBJC_METACLASS_$_NSObject
+ .quad __objc_empty_cache
+ .quad 0
+ .quad __OBJC_METACLASS_RO_$_Foo
+
+ .section __DATA,__objc_const
+ .p2align 3
+__OBJC_CLASS_RO_$_Foo:
+ .long 0
+ .long 8
+ .long 8
+ .space 4
+ .quad 0
+ .quad l_OBJC_CLASS_NAME_
+ .quad 0
+ .quad 0
+ .quad 0
+ .quad 0
+ .quad 0
+
+ .section __DATA,__objc_data
+ .globl _OBJC_CLASS_$_Foo
+ .p2align 3
+_OBJC_CLASS_$_Foo:
+ .quad _OBJC_METACLASS_$_Foo
+ .quad _OBJC_CLASS_$_NSObject
+ .quad __objc_empty_cache
+ .quad 0
+ .quad __OBJC_CLASS_RO_$_Foo
+
+ .section __DATA,__objc_classlist,regular,no_dead_strip
+ .p2align 3
+l_OBJC_LABEL_CLASS_$:
+ .quad _OBJC_CLASS_$_Foo
+
+ .section __DATA,__objc_imageinfo,regular,no_dead_strip
+L_OBJC_IMAGE_INFO:
+ .long 0
+ .long 64
+
+.subsections_via_symbols
--- /dev/null
+// Test that calls to Objective-C methods in other files work.
+//
+// RUN: %clang -c -o %t.o %s
+// RUN: %clang -c -o %t.aux.o %S/Inputs/objc-Foo-foo-class-method.S
+// RUN: %llvm_jitlink -preload libobjc.A.dylib %t.o %t.aux.o
+
+ .section __TEXT,__text,regular,pure_instructions
+ .build_version macos, 14, 0 sdk_version 14, 0
+ .globl _main
+ .p2align 2
+_main:
+ adrp x8, _OBJC_CLASSLIST_REFERENCES_$_@PAGE
+ ldr x0, [x8, _OBJC_CLASSLIST_REFERENCES_$_@PAGEOFF]
+ adrp x8, _OBJC_SELECTOR_REFERENCES_@PAGE
+ ldr x1, [x8, _OBJC_SELECTOR_REFERENCES_@PAGEOFF]
+ b _objc_msgSend
+
+ .section __DATA,__objc_classrefs,regular,no_dead_strip
+ .p2align 3, 0x0
+_OBJC_CLASSLIST_REFERENCES_$_:
+ .quad _OBJC_CLASS_$_Foo
+
+ .section __TEXT,__objc_methname,cstring_literals
+l_OBJC_METH_VAR_NAME_:
+ .asciz "foo"
+
+ .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip
+ .p2align 3, 0x0
+_OBJC_SELECTOR_REFERENCES_:
+ .quad l_OBJC_METH_VAR_NAME_
+
+ .section __DATA,__objc_imageinfo,regular,no_dead_strip
+L_OBJC_IMAGE_INFO:
+ .long 0
+ .long 64
+
+.subsections_via_symbols
// address in the first graph that it appears in, then verify and discard it
// in all subsequent graphs. In this pass we preserve unconditionally -- we'll
// manually throw it away in the processObjCImageInfo pass.
- if (auto *ObjCImageInfoSec = G.findSectionByName("__DATA,__objc_imageinfo")) {
+ if (auto *ObjCImageInfoSec =
+ G.findSectionByName(MachOObjCImageInfoSectionName)) {
if (ObjCImageInfoSec->blocks_size() != 1)
return make_error<StringError>(
"In " + G.getName() +
inconvertibleErrorCode());
G.addAnonymousSymbol(**ObjCImageInfoSec->blocks().begin(), 0, 0, false,
true);
+
+ for (auto *B : ObjCImageInfoSec->blocks())
+ if (!B->edges_empty())
+ return make_error<StringError>("In " + G.getName() + ", " +
+ MachOObjCImageInfoSectionName +
+ " contains references to symbols",
+ inconvertibleErrorCode());
}
// Init sections are important: We need to preserve them and so that their
// registerObjectPlatformSections.
JITLinkSymbolSet InitSectionSymbols;
for (auto &InitSectionName : MachOInitSectionNames) {
+ // Skip ObjCImageInfo -- this shouldn't have any dependencies, and we may
+ // remove it later.
+ if (InitSectionName == MachOObjCImageInfoSectionName)
+ continue;
+
// Skip non-init sections.
auto *InitSection = G.findSectionByName(InitSectionName);
if (!InitSection)