template <typename A>
class ObjCImageInfoAtom : public ld::Atom {
public:
- ObjCImageInfoAtom(ld::File::ObjcConstraint objcConstraint,
- bool compaction, bool abi2, bool hasCategoryClassProperties, uint8_t swiftVersion);
+ ObjCImageInfoAtom(bool abi2, bool hasCategoryClassProperties, uint8_t swiftVersion);
virtual const ld::File* file() const { return NULL; }
virtual const char* name() const { return "objc image info"; }
template <typename A>
-ObjCImageInfoAtom<A>::ObjCImageInfoAtom(ld::File::ObjcConstraint objcConstraint, bool compaction,
- bool abi2, bool hasCategoryClassProperties, uint8_t swiftVersion)
+ObjCImageInfoAtom<A>::ObjCImageInfoAtom(bool abi2, bool hasCategoryClassProperties, uint8_t swiftVersion)
: ld::Atom(abi2 ? _s_sectionABI2 : _s_sectionABI1, ld::Atom::definitionRegular, ld::Atom::combineNever,
ld::Atom::scopeLinkageUnit, ld::Atom::typeUnclassified,
symbolTableNotIn, false, false, false, ld::Atom::Alignment(2))
{
uint32_t value = 0;
- switch ( objcConstraint ) {
- case ld::File::objcConstraintNone:
- case ld::File::objcConstraintRetainRelease:
- if ( compaction )
- warning("ignoring -objc_gc_compaction because code not compiled for ObjC garbage collection");
- break;
- case ld::File::objcConstraintRetainReleaseOrGC:
- value |= OBJC_IMAGE_SUPPORTS_GC;
- if ( compaction )
- value |= OBJC_IMAGE_SUPPORTS_COMPACTION;
- break;
- case ld::File::objcConstraintGC:
- value |= OBJC_IMAGE_SUPPORTS_GC | OBJC_IMAGE_REQUIRES_GC;
- if ( compaction )
- value |= OBJC_IMAGE_SUPPORTS_COMPACTION;
- break;
- case ld::File::objcConstraintRetainReleaseForSimulator:
- value |= OBJC_IMAGE_IS_SIMULATED;
- break;
- }
-
if ( hasCategoryClassProperties ) {
value |= OBJC_IMAGE_HAS_CATEGORY_CLASS_PROPERTIES;
}
const ld::Atom* Category<A>::getClassProperties(ld::Internal& state, const ld::Atom* contentAtom)
{
// Only specially-marked files have this field.
- if (!contentAtom->file()->objcHasCategoryClassPropertiesField()) return NULL;
-
- return ObjCData<A>::getPointerInContent(state, contentAtom, 6*sizeof(pint_t)); // category_t.classProperties
+ if ( const ld::relocatable::File* objFile = dynamic_cast<const ld::relocatable::File*>(contentAtom->file()) ) {
+ if ( objFile->objcHasCategoryClassPropertiesField() ) {
+ return ObjCData<A>::getPointerInContent(state, contentAtom, 6*sizeof(pint_t)); // category_t.classProperties
+ }
+ }
+ return NULL;
}
haveCategoriesWithNonNullClassProperties = true;
// fprintf(stderr, "category in file %s has non-null class properties\n", categoryAtom->safeFilePath());
}
-
- if (!categoryAtom->file()->objcHasCategoryClassPropertiesField()) {
- haveCategoriesWithoutClassPropertyStorage = true;
- // fprintf(stderr, "category in file %s has no storage for class properties\n", categoryAtom->safeFilePath());
+
+ if ( const ld::relocatable::File* objFile = dynamic_cast<const ld::relocatable::File*>(categoryAtom->file()) ) {
+ if ( !objFile->objcHasCategoryClassPropertiesField() ) {
+ haveCategoriesWithoutClassPropertyStorage = true;
+ // fprintf(stderr, "category in file %s has no storage for class properties\n", categoryAtom->safeFilePath());
+ }
}
}
}
void doPass(const Options& opts, ld::Internal& state)
{
// Do nothing if the output has no ObjC content.
- if ( state.objcObjectConstraint == ld::File::objcConstraintNone ) {
+ if ( !state.hasObjC ) {
return;
}
-
- // verify dylibs are GC compatible with object files
- if ( state.objcObjectConstraint != state.objcDylibConstraint ) {
- if ( (state.objcDylibConstraint == ld::File::objcConstraintRetainRelease)
- && (state.objcObjectConstraint == ld::File::objcConstraintGC) ) {
- throw "Linked dylibs built for retain/release but object files built for GC-only";
- }
- else if ( (state.objcDylibConstraint == ld::File::objcConstraintGC)
- && (state.objcObjectConstraint == ld::File::objcConstraintRetainRelease) ) {
- throw "Linked dylibs built for GC-only but object files built for retain/release";
- }
- }
-
+
if ( opts.objcCategoryMerging() ) {
// optimize classes defined in this linkage unit by merging in categories also in this linkage unit
OptimizeCategories<A>::doit(opts, state);
// add image info atom
// The HasCategoryClassProperties bit is set as often as possible.
- state.addAtom(*new ObjCImageInfoAtom<A>(state.objcObjectConstraint, opts.objcGcCompaction(), isObjC2,
- !haveCategoriesWithoutClassPropertyStorage, state.swiftVersion));
+ state.addAtom(*new ObjCImageInfoAtom<A>(isObjC2, !haveCategoriesWithoutClassPropertyStorage, state.swiftVersion));
}
#endif
#if SUPPORT_ARCH_arm64
case CPU_TYPE_ARM64:
+#if SUPPORT_ARCH_arm64e
+ if (opts.subArchitecture() == CPU_SUBTYPE_ARM64_E) {
+ doPass<arm64e, true>(opts, state);
+ break;
+ }
+#endif
doPass<arm64, true>(opts, state);
break;
#endif