Rework MKNodeFieldCPUSubType

Improve the handling of cpu subtype feature flags.
This commit is contained in:
Devin Vaukz 2021-07-04 10:37:18 -07:00
parent 12deebde94
commit 421cb303d4
24 changed files with 881 additions and 226 deletions

View File

@ -466,8 +466,8 @@
D082FD3A20072CED00E6C3E5 /* MKNodeFieldCPUSubTypeX86.m in Sources */ = {isa = PBXBuildFile; fileRef = D082FD3820072CED00E6C3E5 /* MKNodeFieldCPUSubTypeX86.m */; };
D082FD3D20072F6F00E6C3E5 /* MKNodeFieldCPUSubTypePowerPC.h in Headers */ = {isa = PBXBuildFile; fileRef = D082FD3B20072F6F00E6C3E5 /* MKNodeFieldCPUSubTypePowerPC.h */; settings = {ATTRIBUTES = (Public, ); }; };
D082FD3E20072F6F00E6C3E5 /* MKNodeFieldCPUSubTypePowerPC.m in Sources */ = {isa = PBXBuildFile; fileRef = D082FD3C20072F6F00E6C3E5 /* MKNodeFieldCPUSubTypePowerPC.m */; };
D082FD412007326400E6C3E5 /* MKNodeFieldCPUSubTypeCapability.h in Headers */ = {isa = PBXBuildFile; fileRef = D082FD3F2007326400E6C3E5 /* MKNodeFieldCPUSubTypeCapability.h */; settings = {ATTRIBUTES = (Public, ); }; };
D082FD422007326400E6C3E5 /* MKNodeFieldCPUSubTypeCapability.m in Sources */ = {isa = PBXBuildFile; fileRef = D082FD402007326400E6C3E5 /* MKNodeFieldCPUSubTypeCapability.m */; };
D082FD412007326400E6C3E5 /* MKNodeFieldCPUSubTypeFeatures.h in Headers */ = {isa = PBXBuildFile; fileRef = D082FD3F2007326400E6C3E5 /* MKNodeFieldCPUSubTypeFeatures.h */; settings = {ATTRIBUTES = (Public, ); }; };
D082FD422007326400E6C3E5 /* MKNodeFieldCPUSubTypeFeatures.m in Sources */ = {isa = PBXBuildFile; fileRef = D082FD402007326400E6C3E5 /* MKNodeFieldCPUSubTypeFeatures.m */; };
D0848ADF1A959E390076976F /* symbol_table.c in Sources */ = {isa = PBXBuildFile; fileRef = D0848ADD1A959E390076976F /* symbol_table.c */; };
D0848AE11A959E390076976F /* symbol_table.c in Sources */ = {isa = PBXBuildFile; fileRef = D0848ADD1A959E390076976F /* symbol_table.c */; };
D0848AE21A959E390076976F /* symbol_table.h in Headers */ = {isa = PBXBuildFile; fileRef = D0848ADE1A959E390076976F /* symbol_table.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -938,6 +938,8 @@
D0E3FD331A592E31007B2771 /* memory_map.c in Sources */ = {isa = PBXBuildFile; fileRef = D0E3FD311A592E31007B2771 /* memory_map.c */; };
D0E3FD341A592E31007B2771 /* memory_map.h in Headers */ = {isa = PBXBuildFile; fileRef = D0E3FD321A592E31007B2771 /* memory_map.h */; settings = {ATTRIBUTES = (Public, ); }; };
D0E3FD361A59D6B3007B2771 /* memory_map_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = D0E3FD351A59D6B3007B2771 /* memory_map_internal.h */; };
D0E7FD3B268AE269007B856F /* MKNodeFieldCPUSubTypePowerPC64.h in Headers */ = {isa = PBXBuildFile; fileRef = D0E7FD39268AE269007B856F /* MKNodeFieldCPUSubTypePowerPC64.h */; settings = {ATTRIBUTES = (Public, ); }; };
D0E7FD3C268AE269007B856F /* MKNodeFieldCPUSubTypePowerPC64.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E7FD3A268AE269007B856F /* MKNodeFieldCPUSubTypePowerPC64.m */; };
D0E8B8141CB8AE1100237EA1 /* MKObjCImageInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = D0E8B8121CB8AE1100237EA1 /* MKObjCImageInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
D0E8B8151CB8AE1100237EA1 /* MKObjCImageInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E8B8131CB8AE1100237EA1 /* MKObjCImageInfo.m */; };
D0E8B8281CB9800C00237EA1 /* MKPointer.h in Headers */ = {isa = PBXBuildFile; fileRef = D0E8B8241CB9800C00237EA1 /* MKPointer.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -1557,8 +1559,8 @@
D082FD3820072CED00E6C3E5 /* MKNodeFieldCPUSubTypeX86.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MKNodeFieldCPUSubTypeX86.m; sourceTree = "<group>"; };
D082FD3B20072F6F00E6C3E5 /* MKNodeFieldCPUSubTypePowerPC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MKNodeFieldCPUSubTypePowerPC.h; sourceTree = "<group>"; };
D082FD3C20072F6F00E6C3E5 /* MKNodeFieldCPUSubTypePowerPC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MKNodeFieldCPUSubTypePowerPC.m; sourceTree = "<group>"; };
D082FD3F2007326400E6C3E5 /* MKNodeFieldCPUSubTypeCapability.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MKNodeFieldCPUSubTypeCapability.h; sourceTree = "<group>"; };
D082FD402007326400E6C3E5 /* MKNodeFieldCPUSubTypeCapability.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MKNodeFieldCPUSubTypeCapability.m; sourceTree = "<group>"; };
D082FD3F2007326400E6C3E5 /* MKNodeFieldCPUSubTypeFeatures.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MKNodeFieldCPUSubTypeFeatures.h; sourceTree = "<group>"; };
D082FD402007326400E6C3E5 /* MKNodeFieldCPUSubTypeFeatures.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MKNodeFieldCPUSubTypeFeatures.m; sourceTree = "<group>"; };
D0848ADD1A959E390076976F /* symbol_table.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = symbol_table.c; sourceTree = "<group>"; };
D0848ADE1A959E390076976F /* symbol_table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = symbol_table.h; sourceTree = "<group>"; };
D0848AF01A959E6C0076976F /* symbol_table_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = symbol_table_internal.h; sourceTree = "<group>"; };
@ -1918,6 +1920,8 @@
D0E3FD321A592E31007B2771 /* memory_map.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memory_map.h; sourceTree = "<group>"; };
D0E3FD351A59D6B3007B2771 /* memory_map_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memory_map_internal.h; sourceTree = "<group>"; };
D0E3FD9D199971A40097C0FF /* iOS-Framework.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "iOS-Framework.xcconfig"; sourceTree = "<group>"; };
D0E7FD39268AE269007B856F /* MKNodeFieldCPUSubTypePowerPC64.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MKNodeFieldCPUSubTypePowerPC64.h; sourceTree = "<group>"; };
D0E7FD3A268AE269007B856F /* MKNodeFieldCPUSubTypePowerPC64.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MKNodeFieldCPUSubTypePowerPC64.m; sourceTree = "<group>"; };
D0E8B8121CB8AE1100237EA1 /* MKObjCImageInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MKObjCImageInfo.h; sourceTree = "<group>"; };
D0E8B8131CB8AE1100237EA1 /* MKObjCImageInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MKObjCImageInfo.m; sourceTree = "<group>"; };
D0E8B8241CB9800C00237EA1 /* MKPointer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MKPointer.h; sourceTree = "<group>"; };
@ -3149,8 +3153,8 @@
D0A92F392002D9530001C18D /* MKNodeFieldCPUType.m */,
D0A92F382002D9530001C18D /* MKNodeFieldCPUSubType.h */,
D0A92F3A2002D9530001C18D /* MKNodeFieldCPUSubType.m */,
D082FD3F2007326400E6C3E5 /* MKNodeFieldCPUSubTypeCapability.h */,
D082FD402007326400E6C3E5 /* MKNodeFieldCPUSubTypeCapability.m */,
D082FD3F2007326400E6C3E5 /* MKNodeFieldCPUSubTypeFeatures.h */,
D082FD402007326400E6C3E5 /* MKNodeFieldCPUSubTypeFeatures.m */,
D00E88F12008707F00C0FBB7 /* MKNodeFieldCPUSubTypeAny.h */,
D00E88F22008707F00C0FBB7 /* MKNodeFieldCPUSubTypeAny.m */,
D082FD2B2007180600E6C3E5 /* MKNodeFieldCPUSubTypeI386.h */,
@ -3165,6 +3169,8 @@
D076CE222260416D00130F2B /* MKNodeFieldCPUSubTypeARM6432.m */,
D082FD3B20072F6F00E6C3E5 /* MKNodeFieldCPUSubTypePowerPC.h */,
D082FD3C20072F6F00E6C3E5 /* MKNodeFieldCPUSubTypePowerPC.m */,
D0E7FD39268AE269007B856F /* MKNodeFieldCPUSubTypePowerPC64.h */,
D0E7FD3A268AE269007B856F /* MKNodeFieldCPUSubTypePowerPC64.m */,
);
name = "CPU Type";
path = CPUType;
@ -3703,7 +3709,7 @@
D05ED7CD21EEF94900F5A6BE /* MKMachO+SplitSegment.h in Headers */,
D0A1D8F219E4EEB80095870C /* load_command_version_min_macosx.h in Headers */,
D06CEC5622629D57001FF343 /* MKBindThreadedApply.h in Headers */,
D082FD412007326400E6C3E5 /* MKNodeFieldCPUSubTypeCapability.h in Headers */,
D082FD412007326400E6C3E5 /* MKNodeFieldCPUSubTypeFeatures.h in Headers */,
D019EBD4207AA3F7008B94FF /* MKSectionIndirectSymbolTableIndexing.h in Headers */,
D030301C1A23B86600288B3E /* MKLCLoadDylinker.h in Headers */,
D03EF60120411E9700B8022C /* MKNodeFieldObjCImageInfoFlagsType.h in Headers */,
@ -4013,6 +4019,7 @@
D0E30A851E623D2F0005A882 /* MKNodeFieldDataOperationExtractChildNodeData.h in Headers */,
D06C874621F5322F0006574C /* MKNodeFieldSplitSegmentInfoV1FixupType.h in Headers */,
D0302FFF1A22DB1B00288B3E /* MKNodeDescription.h in Headers */,
D0E7FD3B268AE269007B856F /* MKNodeFieldCPUSubTypePowerPC64.h in Headers */,
D091459C1E5122C500959648 /* MKNodeFieldValueRecipe.h in Headers */,
D08E5ECC1B771E1E009185FE /* MKDSCDylibInfos.h in Headers */,
D05E7EB620389F84000C72B7 /* MKNodeFieldTypeOffset.h in Headers */,
@ -4656,6 +4663,7 @@
D017317E1C687967007CB0A1 /* MKDSCSlideInfoPage.m in Sources */,
D0CF9D8B200DC89A00B508C4 /* MKFunctionOffset.m in Sources */,
D0A1E9221B69F3080061843F /* MKDSCMappingInfo.m in Sources */,
D0E7FD3C268AE269007B856F /* MKNodeFieldCPUSubTypePowerPC64.m in Sources */,
D06618631CBB3171006979A1 /* MKObjCClassMethodList.m in Sources */,
D05ED7CE21EEF94900F5A6BE /* MKMachO+SplitSegment.m in Sources */,
D010F7051CB86D66004025F5 /* MKObjCClassListSection.m in Sources */,
@ -4667,7 +4675,7 @@
D0A0D2321DE22C16003F0A08 /* MKPointerListSection.m in Sources */,
D06C873C21F528D90006574C /* MKSplitSegmentInfoV1Opcode.m in Sources */,
D0E30A801E614D210005A882 /* MKOptionSetFormatter.m in Sources */,
D082FD422007326400E6C3E5 /* MKNodeFieldCPUSubTypeCapability.m in Sources */,
D082FD422007326400E6C3E5 /* MKNodeFieldCPUSubTypeFeatures.m in Sources */,
D0B261841CAB7C9A0058F04C /* MKCommonSymbol.m in Sources */,
D010F6FF1CB868EF004025F5 /* MKResult.m in Sources */,
D03030051A22F2D200288B3E /* MKLCSegment.m in Sources */,

View File

@ -25,36 +25,19 @@
//| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//----------------------------------------------------------------------------//
#include <MachOKit/macho.h>
#import <Foundation/Foundation.h>
#include <mach/machine.h>
#import <MachOKit/MKBase.h>
#import <MachOKit/MKNodeFieldTypeDoubleWord.h>
#import <MachOKit/MKNodeFieldBitfieldType.h>
#import <MachOKit/MKNodeFieldCPUSubTypeCapability.h>
#import <MachOKit/MKNodeFieldCPUSubTypeAny.h>
#import <MachOKit/MKNodeFieldCPUSubTypeI386.h>
#import <MachOKit/MKNodeFieldCPUSubTypeX86.h>
#import <MachOKit/MKNodeFieldCPUSubTypeARM.h>
#import <MachOKit/MKNodeFieldCPUSubTypeARM64.h>
#import <MachOKit/MKNodeFieldCPUSubTypeARM6432.h>
#import <MachOKit/MKNodeFieldCPUSubTypePowerPC.h>
#include <mach/machine.h>
NS_ASSUME_NONNULL_BEGIN
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubType : MKNodeFieldTypeDoubleWord <MKNodeFieldBitfieldType> {
@package
MKNodeFieldCPUSubTypeAny *_implType;
NSFormatter *_formatter;
}
@interface MKNodeFieldCPUSubType : MKNodeFieldTypeDoubleWord <MKNodeFieldBitfieldType>
+ (__kindof MKNodeFieldCPUSubType*)cpuSubTypeForCPUType:(cpu_type_t)cpuType;
- (instancetype)initWithCPUSubType:(nullable MKNodeFieldCPUSubTypeAny*)subtype NS_DESIGNATED_INITIALIZER;
@end
NS_ASSUME_NONNULL_END

View File

@ -29,69 +29,71 @@
#import "MKInternal.h"
#import "MKNodeDescription.h"
#import "MKNodeFieldCPUSubTypeI386.h"
#import "MKNodeFieldCPUSubTypeX86.h"
#import "MKNodeFieldCPUSubTypeARM.h"
#import "MKNodeFieldCPUSubTypeARM64.h"
#import "MKNodeFieldCPUSubTypeARM6432.h"
#import "MKNodeFieldCPUSubTypePowerPC.h"
#import "MKNodeFieldCPUSubTypePowerPC64.h"
extern void OBJC_CLASS_$_MKNodeFieldCPUSubType;
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubType
static MKNodeFieldBitfieldMasks *s_Bits = nil;
static NSFormatter *s_Formatter = nil;
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
{
if (s_Bits != nil)
if (self != &OBJC_CLASS_$_MKNodeFieldCPUSubType)
return;
s_Bits = [[NSArray alloc] initWithObjects:
_$((uint32_t)CPU_SUBTYPE_MASK),
_$(~(uint32_t)CPU_SUBTYPE_MASK),
nil];
MKBitfieldFormatterMask *subtypeMask = [MKBitfieldFormatterMask new];
subtypeMask.mask = _$(~(uint32_t)CPU_SUBTYPE_MASK);
subtypeMask.formatter = MKNodeFieldCPUSubTypeAnySubType.sharedInstance.formatter;
MKBitfieldFormatterMask *capabilitiesMask = [MKBitfieldFormatterMask new];
capabilitiesMask.mask = _$((uint32_t)CPU_SUBTYPE_MASK);
capabilitiesMask.formatter = MKNodeFieldCPUSubTypeFeatures.sharedInstance.formatter;
capabilitiesMask.ignoreZero = YES;
NSArray *bits = [[NSArray alloc] initWithObjects:capabilitiesMask, subtypeMask, nil];
MKBitfieldFormatter *formatter = [MKBitfieldFormatter new];
formatter.bits = bits;
s_Formatter = formatter;
[bits release];
[capabilitiesMask release];
[subtypeMask release];
}
//|++++++++++++++++++++++++++++++++++++|//
+ (MKNodeFieldCPUSubType*)cpuSubTypeForCPUType:(cpu_type_t)cpuType
{
switch (cpuType) {
case CPU_TYPE_X86:
{
static MKNodeFieldCPUSubType *s_I386Type = nil;
if (s_I386Type == nil)
s_I386Type = [[MKNodeFieldCPUSubType alloc] initWithCPUSubType:MKNodeFieldCPUSubTypeI386.sharedInstance];
return s_I386Type;
}
case CPU_TYPE_I386:
return MKNodeFieldCPUSubTypeI386.sharedInstance;
case CPU_TYPE_X86_64:
{
static MKNodeFieldCPUSubType *s_X86_64Type = nil;
if (s_X86_64Type == nil)
s_X86_64Type = [[MKNodeFieldCPUSubType alloc] initWithCPUSubType:MKNodeFieldCPUSubTypeX86.sharedInstance];
return s_X86_64Type;
}
return MKNodeFieldCPUSubTypeX86.sharedInstance;
case CPU_TYPE_ARM:
{
static MKNodeFieldCPUSubType *s_ARMType = nil;
if (s_ARMType == nil)
s_ARMType = [[MKNodeFieldCPUSubType alloc] initWithCPUSubType:MKNodeFieldCPUSubTypeARM.sharedInstance];
return s_ARMType;
}
return MKNodeFieldCPUSubTypeARM.sharedInstance;
case CPU_TYPE_ARM64:
{
static MKNodeFieldCPUSubType *s_ARM64Type = nil;
if (s_ARM64Type == nil)
s_ARM64Type = [[MKNodeFieldCPUSubType alloc] initWithCPUSubType:MKNodeFieldCPUSubTypeARM64.sharedInstance];
return s_ARM64Type;
}
return MKNodeFieldCPUSubTypeARM64.sharedInstance;
case CPU_TYPE_ARM64_32:
{
static MKNodeFieldCPUSubType *s_ARM6432Type = nil;
if (s_ARM6432Type == nil)
s_ARM6432Type = [[MKNodeFieldCPUSubType alloc] initWithCPUSubType:MKNodeFieldCPUSubTypeARM6432.sharedInstance];
return s_ARM6432Type;
}
return MKNodeFieldCPUSubTypeARM6432.sharedInstance;
case CPU_TYPE_POWERPC:
{
static MKNodeFieldCPUSubType *s_PowerPCType = nil;
if (s_PowerPCType == nil)
s_PowerPCType = [[MKNodeFieldCPUSubType alloc] initWithCPUSubType:MKNodeFieldCPUSubTypePowerPC.sharedInstance];
return s_PowerPCType;
}
return MKNodeFieldCPUSubTypePowerPC.sharedInstance;
case CPU_TYPE_POWERPC64:
return MKNodeFieldCPUSubTypePowerPC64.sharedInstance;
default:
{
static MKNodeFieldCPUSubType *s_DefaultType = nil;
@ -102,49 +104,6 @@ static MKNodeFieldBitfieldMasks *s_Bits = nil;
}
}
//|++++++++++++++++++++++++++++++++++++|//
- (instancetype)initWithCPUSubType:(MKNodeFieldCPUSubTypeAny*)subtype
{
self = [super init];
if (self == nil) return nil;
_implType = [subtype ?: MKNodeFieldCPUSubTypeAny.sharedInstance retain];
MKBitfieldFormatterMask *subtypeMask = [MKBitfieldFormatterMask new];
subtypeMask.mask = _$(~(uint32_t)CPU_SUBTYPE_MASK);
subtypeMask.formatter = _implType.formatter;
MKBitfieldFormatterMask *capabilitiesMask = [MKBitfieldFormatterMask new];
capabilitiesMask.mask = _$((uint32_t)CPU_SUBTYPE_MASK);
capabilitiesMask.formatter = MKNodeFieldCPUSubTypeCapability.sharedInstance.formatter;
capabilitiesMask.ignoreZero = YES;
NSArray *bits = [[NSArray alloc] initWithObjects:capabilitiesMask, subtypeMask, nil];
MKBitfieldFormatter *formatter = [MKBitfieldFormatter new];
formatter.bits = bits;
_formatter = formatter;
[bits release];
[capabilitiesMask release];
[subtypeMask release];
return self;
}
//|++++++++++++++++++++++++++++++++++++|//
- (instancetype)init
{ return [self initWithCPUSubType:nil]; }
//|++++++++++++++++++++++++++++++++++++|//
- (void)dealloc
{
[_formatter release];
[_implType release];
[super dealloc];
}
////
#pragma mark - MKNodeFieldBitfieldType
////
@ -157,9 +116,9 @@ static MKNodeFieldBitfieldMasks *s_Bits = nil;
- (id<MKNodeFieldNumericType>)typeForMask:(NSNumber*)mask
{
if ([mask isEqual:_$((uint32_t)CPU_SUBTYPE_MASK)])
return MKNodeFieldCPUSubTypeCapability.sharedInstance;
return MKNodeFieldCPUSubTypeFeatures.sharedInstance;
else
return _implType;
return MKNodeFieldCPUSubTypeAnySubType.sharedInstance;
}
//|++++++++++++++++++++++++++++++++++++|//
@ -176,6 +135,6 @@ static MKNodeFieldBitfieldMasks *s_Bits = nil;
//|++++++++++++++++++++++++++++++++++++|//
- (NSFormatter*)formatter
{ return _formatter; }
{ return s_Formatter; }
@end

View File

@ -25,18 +25,16 @@
//| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//----------------------------------------------------------------------------//
#include <MachOKit/macho.h>
#import <Foundation/Foundation.h>
#import <MachOKit/MKNodeFieldCPUSubType.h>
#import <MachOKit/MKNodeFieldCPUSubTypeFeatures.h>
#import <MachOKit/MKNodeFieldCPUSubTypeAny.h>
NS_ASSUME_NONNULL_BEGIN
//----------------------------------------------------------------------------//
//! @name ARM CPU SubTypes
//! @relates MKNodeFieldCPUSubTypeARM
//! @relates MKNodeFieldCPUSubTypeARMSubType
//!
//
NS_SWIFT_NAME(MKCPUSubType.ARM_All)
static const MKCPUSubType MKARMCPUSubTypeAll = CPU_SUBTYPE_ARM_ALL;
NS_SWIFT_NAME(MKCPUSubType.ARM_V4T)
@ -67,7 +65,16 @@ static const MKCPUSubType MKARMCPUSubTypeV8 = CPU_SUBTYPE_ARM_V8;
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypeARM : MKNodeFieldCPUSubTypeAny
@interface MKNodeFieldCPUSubTypeARM : MKNodeFieldCPUSubType
+ (instancetype)sharedInstance;
@end
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypeARMSubType : MKNodeFieldCPUSubTypeAnySubType
+ (instancetype)sharedInstance;

View File

@ -29,13 +29,65 @@
#import "MKInternal.h"
#import "MKNodeDescription.h"
extern void OBJC_CLASS_$_MKNodeFieldCPUSubTypeARM;
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypeARM
static NSFormatter *s_BitfieldFormatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeARM)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
{
if (self != &OBJC_CLASS_$_MKNodeFieldCPUSubTypeARM)
return;
MKBitfieldFormatterMask *subtypeMask = [MKBitfieldFormatterMask new];
subtypeMask.mask = _$(~(uint32_t)CPU_SUBTYPE_MASK);
subtypeMask.formatter = MKNodeFieldCPUSubTypeARMSubType.sharedInstance.formatter;
MKBitfieldFormatterMask *capabilitiesMask = [MKBitfieldFormatterMask new];
capabilitiesMask.mask = _$((uint32_t)CPU_SUBTYPE_MASK);
capabilitiesMask.formatter = MKNodeFieldCPUSubTypeFeatures.sharedInstance.formatter;
capabilitiesMask.ignoreZero = YES;
NSArray *bits = [[NSArray alloc] initWithObjects:capabilitiesMask, subtypeMask, nil];
MKBitfieldFormatter *formatter = [MKBitfieldFormatter new];
formatter.bits = bits;
s_BitfieldFormatter = formatter;
[bits release];
[capabilitiesMask release];
[subtypeMask release];
}
//|++++++++++++++++++++++++++++++++++++|//
- (id<MKNodeFieldNumericType>)typeForMask:(NSNumber*)mask
{
if ([mask isEqual:_$((uint32_t)CPU_SUBTYPE_MASK)])
return MKNodeFieldCPUSubTypeFeatures.sharedInstance;
else
return MKNodeFieldCPUSubTypeARMSubType.sharedInstance;
}
//|++++++++++++++++++++++++++++++++++++|//
- (NSFormatter*)formatter
{ return s_BitfieldFormatter; }
@end
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypeARMSubType
static NSDictionary *s_Types = nil;
static MKEnumerationFormatter *s_Formatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeARM)
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeARMSubType)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize

View File

@ -25,9 +25,8 @@
//| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//----------------------------------------------------------------------------//
#include <MachOKit/macho.h>
#import <Foundation/Foundation.h>
#import <MachOKit/MKNodeFieldCPUSubType.h>
#import <MachOKit/MKNodeFieldCPUSubTypeFeatures.h>
#import <MachOKit/MKNodeFieldCPUSubTypeAny.h>
NS_ASSUME_NONNULL_BEGIN
@ -36,7 +35,6 @@ NS_ASSUME_NONNULL_BEGIN
//! @name ARM64 CPU SubTypes
//! @relates MKNodeFieldCPUSubTypeARM64
//!
//
NS_SWIFT_NAME(MKCPUSubType.ARM64_ALL)
static const MKCPUSubType MKARM64CPUSubTypeAll = CPU_SUBTYPE_ARM64_ALL;
NS_SWIFT_NAME(MKCPUSubType.ARM64_V8)
@ -45,9 +43,36 @@ NS_SWIFT_NAME(MKCPUSubType.ARM64_E)
static const MKCPUSubType MKARM64CPUSubTypeE = CPU_SUBTYPE_ARM64E;
//----------------------------------------------------------------------------//
//! @name CPU Subtype Features for ARM64
//! @relates MKNodeFieldCPUSubTypeARM64Features
//!
typedef NS_OPTIONS(uint32_t, MKCPUSubTypeARM64Features) {
MKCPUSubTypeARM64FeaturePtrAuthABI = CPU_SUBTYPE_PTRAUTH_ABI
};
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypeARM64 : MKNodeFieldCPUSubTypeAny
@interface MKNodeFieldCPUSubTypeARM64 : MKNodeFieldCPUSubType
+ (instancetype)sharedInstance;
@end
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypeARM64SubType : MKNodeFieldCPUSubTypeAnySubType
+ (instancetype)sharedInstance;
@end
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypeARM64Features : MKNodeFieldCPUSubTypeFeatures <MKNodeFieldOptionSetType>
+ (instancetype)sharedInstance;

View File

@ -29,13 +29,65 @@
#import "MKInternal.h"
#import "MKNodeDescription.h"
extern void OBJC_CLASS_$_MKNodeFieldCPUSubTypeARM64;
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypeARM64
static NSFormatter *s_BitfieldFormatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeARM64)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
{
if (self != &OBJC_CLASS_$_MKNodeFieldCPUSubTypeARM64)
return;
MKBitfieldFormatterMask *subtypeMask = [MKBitfieldFormatterMask new];
subtypeMask.mask = _$(~(uint32_t)CPU_SUBTYPE_MASK);
subtypeMask.formatter = MKNodeFieldCPUSubTypeARM64SubType.sharedInstance.formatter;
MKBitfieldFormatterMask *capabilitiesMask = [MKBitfieldFormatterMask new];
capabilitiesMask.mask = _$((uint32_t)CPU_SUBTYPE_MASK);
capabilitiesMask.formatter = MKNodeFieldCPUSubTypeARM64Features.sharedInstance.formatter;
capabilitiesMask.ignoreZero = YES;
NSArray *bits = [[NSArray alloc] initWithObjects:capabilitiesMask, subtypeMask, nil];
MKBitfieldFormatter *formatter = [MKBitfieldFormatter new];
formatter.bits = bits;
s_BitfieldFormatter = formatter;
[bits release];
[capabilitiesMask release];
[subtypeMask release];
}
//|++++++++++++++++++++++++++++++++++++|//
- (id<MKNodeFieldNumericType>)typeForMask:(NSNumber*)mask
{
if ([mask isEqual:_$((uint32_t)CPU_SUBTYPE_MASK)])
return MKNodeFieldCPUSubTypeARM64Features.sharedInstance;
else
return MKNodeFieldCPUSubTypeARM64SubType.sharedInstance;
}
//|++++++++++++++++++++++++++++++++++++|//
- (NSFormatter*)formatter
{ return s_BitfieldFormatter; }
@end
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypeARM64SubType
static NSDictionary *s_Types = nil;
static MKEnumerationFormatter *s_Formatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeARM64)
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeARM64SubType)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
@ -77,3 +129,54 @@ MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeARM64)
{ return s_Formatter; }
@end
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypeARM64Features
static NSDictionary *s_Capability = nil;
static MKOptionSetFormatter *s_CapabilityFormatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeARM64Features)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
{
if (s_Capability != nil && s_CapabilityFormatter != nil)
return;
s_Capability = [@{
_$((uint32_t)CPU_SUBTYPE_PTRAUTH_ABI): @"CPU_SUBTYPE_PTRAUTH_ABI",
} retain];
MKOptionSetFormatter *formatter = [MKOptionSetFormatter new];
formatter.options = s_Capability;
s_CapabilityFormatter = formatter;
}
////
#pragma mark - MKNodeFieldOptionSetType
////
//|++++++++++++++++++++++++++++++++++++|//
- (MKNodeFieldOptionSetOptions*)options
{ return s_Capability; }
//|++++++++++++++++++++++++++++++++++++|//
- (MKNodeFieldOptionSetTraits)optionSetTraits
{ return 0; }
////
#pragma mark - MKNodeFieldType
////
//|++++++++++++++++++++++++++++++++++++|//
- (NSString*)name
{ return @"ARM64 CPU Subtype Features"; }
//|++++++++++++++++++++++++++++++++++++|//
- (NSFormatter*)formatter
{ return s_CapabilityFormatter; }
@end

View File

@ -25,9 +25,8 @@
//| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//----------------------------------------------------------------------------//
#include <MachOKit/macho.h>
#import <Foundation/Foundation.h>
#import <MachOKit/MKNodeFieldCPUSubType.h>
#import <MachOKit/MKNodeFieldCPUSubTypeFeatures.h>
#import <MachOKit/MKNodeFieldCPUSubTypeAny.h>
NS_ASSUME_NONNULL_BEGIN
@ -36,7 +35,6 @@ NS_ASSUME_NONNULL_BEGIN
//! @name ARM64_32 CPU SubTypes
//! @relates MKNodeFieldCPUSubTypeARM6432
//!
//
NS_SWIFT_NAME(MKCPUSubType.ARM64_32_ALL)
static const MKCPUSubType MKARM6432CPUSubTypeAll = CPU_SUBTYPE_ARM64_32_ALL;
NS_SWIFT_NAME(MKCPUSubType.ARM64_32_V8)
@ -45,7 +43,16 @@ static const MKCPUSubType MKARM6432CPUSubTypeV8 = CPU_SUBTYPE_ARM64_32_V8;
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypeARM6432 : MKNodeFieldCPUSubTypeAny
@interface MKNodeFieldCPUSubTypeARM6432 : MKNodeFieldCPUSubType
+ (instancetype)sharedInstance;
@end
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypeARM6432SubType : MKNodeFieldCPUSubTypeAnySubType
+ (instancetype)sharedInstance;

View File

@ -29,13 +29,65 @@
#import "MKInternal.h"
#import "MKNodeDescription.h"
extern void OBJC_CLASS_$_MKNodeFieldCPUSubTypeARM6432;
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypeARM6432
static NSFormatter *s_BitfieldFormatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeARM6432)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
{
if (self != &OBJC_CLASS_$_MKNodeFieldCPUSubTypeARM6432)
return;
MKBitfieldFormatterMask *subtypeMask = [MKBitfieldFormatterMask new];
subtypeMask.mask = _$(~(uint32_t)CPU_SUBTYPE_MASK);
subtypeMask.formatter = MKNodeFieldCPUSubTypeARM6432.sharedInstance.formatter;
MKBitfieldFormatterMask *capabilitiesMask = [MKBitfieldFormatterMask new];
capabilitiesMask.mask = _$((uint32_t)CPU_SUBTYPE_MASK);
capabilitiesMask.formatter = MKNodeFieldCPUSubTypeFeatures.sharedInstance.formatter;
capabilitiesMask.ignoreZero = YES;
NSArray *bits = [[NSArray alloc] initWithObjects:capabilitiesMask, subtypeMask, nil];
MKBitfieldFormatter *formatter = [MKBitfieldFormatter new];
formatter.bits = bits;
s_BitfieldFormatter = formatter;
[bits release];
[capabilitiesMask release];
[subtypeMask release];
}
//|++++++++++++++++++++++++++++++++++++|//
- (id<MKNodeFieldNumericType>)typeForMask:(NSNumber*)mask
{
if ([mask isEqual:_$((uint32_t)CPU_SUBTYPE_MASK)])
return MKNodeFieldCPUSubTypeFeatures.sharedInstance;
else
return MKNodeFieldCPUSubTypeARM6432SubType.sharedInstance;
}
//|++++++++++++++++++++++++++++++++++++|//
- (NSFormatter*)formatter
{ return s_BitfieldFormatter; }
@end
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypeARM6432SubType
static NSDictionary *s_Types = nil;
static MKEnumerationFormatter *s_Formatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeARM6432)
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeARM6432SubType)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize

View File

@ -25,9 +25,7 @@
//| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//----------------------------------------------------------------------------//
#include <MachOKit/macho.h>
#import <Foundation/Foundation.h>
#import <MachOKit/MKBase.h>
#import <MachOKit/MKNodeFieldTypeDoubleWord.h>
#import <MachOKit/MKNodeFieldEnumerationType.h>
@ -35,19 +33,21 @@ NS_ASSUME_NONNULL_BEGIN
//----------------------------------------------------------------------------//
//! @name CPU SubTypes
//! @relates MKNodeFieldCPUSubTypeAny
//! @relates MKNodeFieldCPUSubTypeAnySubType
//!
//
typedef cpu_subtype_t MKCPUSubType NS_TYPED_EXTENSIBLE_ENUM;
NS_SWIFT_NAME(MKCPUSubType.Multiple)
static const MKCPUSubType MKCPUSubTypeMultiple = CPU_SUBTYPE_MULTIPLE;
NS_SWIFT_NAME(MKCPUSubType.Multiple_LittleEndian)
static const MKCPUSubType MKCPUSubTypeLittleEndian = CPU_SUBTYPE_LITTLE_ENDIAN;
NS_SWIFT_NAME(MKCPUSubType.Multiple_BigEndian)
static const MKCPUSubType MKCPUSubTypeBigEndian = CPU_SUBTYPE_BIG_ENDIAN;
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypeAny : MKNodeFieldTypeDoubleWord <MKNodeFieldEnumerationType>
@interface MKNodeFieldCPUSubTypeAnySubType : MKNodeFieldTypeDoubleWord <MKNodeFieldEnumerationType>
+ (instancetype)sharedInstance;

View File

@ -30,12 +30,12 @@
#import "MKNodeDescription.h"
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypeAny
@implementation MKNodeFieldCPUSubTypeAnySubType
static NSDictionary *s_Types = nil;
static MKEnumerationFormatter *s_Formatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeAny)
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeAnySubType)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize

View File

@ -1,7 +1,7 @@
//----------------------------------------------------------------------------//
//|
//| MachOKit - A Lightweight Mach-O Parsing Library
//! @file MKNodeFieldCPUSubTypeCapability.h
//! @file MKNodeFieldCPUSubTypeFeatures.h
//!
//! @author D.V.
//! @copyright Copyright (c) 2014-2015 D.V. All rights reserved.
@ -25,24 +25,14 @@
//| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//----------------------------------------------------------------------------//
#include <MachOKit/macho.h>
#import <Foundation/Foundation.h>
#import <MachOKit/MKBase.h>
#import <MachOKit/MKNodeFieldTypeDoubleWord.h>
#import <MachOKit/MKNodeFieldOptionSetType.h>
NS_ASSUME_NONNULL_BEGIN
//----------------------------------------------------------------------------//
//! @name CPU SubType Capabilities
//! @relates MKNodeFieldCPUSubTypeCapability
//
typedef NS_OPTIONS(uint32_t, MKCPUSubTypeCapability) {
MKCPUSubTypeCapabilityLib64 = CPU_SUBTYPE_LIB64
};
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypeCapability : MKNodeFieldTypeDoubleWord <MKNodeFieldOptionSetType>
@interface MKNodeFieldCPUSubTypeFeatures : MKNodeFieldTypeDoubleWord
+ (instancetype)sharedInstance;

View File

@ -1,7 +1,7 @@
//----------------------------------------------------------------------------//
//|
//| MachOKit - A Lightweight Mach-O Parsing Library
//| MKNodeFieldCPUSubTypeCapability.m
//| MKNodeFieldCPUSubTypeFeatures.m
//|
//| D.V.
//| Copyright (c) 2014-2015 D.V. All rights reserved.
@ -25,44 +25,14 @@
//| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//----------------------------------------------------------------------------//
#import "MKNodeFieldCPUSubTypeCapability.h"
#import "MKNodeFieldCPUSubTypeFeatures.h"
#import "MKInternal.h"
#import "MKNodeDescription.h"
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypeCapability
@implementation MKNodeFieldCPUSubTypeFeatures
static NSDictionary *s_Capability = nil;
static MKOptionSetFormatter *s_Formatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeCapability)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
{
if (s_Capability != nil && s_Formatter != nil)
return;
s_Capability = [@{
_$((uint32_t)CPU_SUBTYPE_LIB64): @"CPU_SUBTYPE_LIB64",
} retain];
MKOptionSetFormatter *formatter = [MKOptionSetFormatter new];
formatter.options = s_Capability;
s_Formatter = formatter;
}
////
#pragma mark - MKNodeFieldOptionSetType
////
//|++++++++++++++++++++++++++++++++++++|//
- (MKNodeFieldOptionSetOptions*)options
{ return s_Capability; }
//|++++++++++++++++++++++++++++++++++++|//
- (MKNodeFieldOptionSetTraits)optionSetTraits
{ return 0; }
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeFeatures)
////
#pragma mark - MKNodeFieldType
@ -70,10 +40,6 @@ MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeCapability)
//|++++++++++++++++++++++++++++++++++++|//
- (NSString*)name
{ return @"CPU Subtype Capability"; }
//|++++++++++++++++++++++++++++++++++++|//
- (NSFormatter*)formatter
{ return s_Formatter; }
{ return @"CPU Subtype Features"; }
@end

View File

@ -25,18 +25,16 @@
//| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//----------------------------------------------------------------------------//
#include <MachOKit/macho.h>
#import <Foundation/Foundation.h>
#import <MachOKit/MKNodeFieldCPUSubType.h>
#import <MachOKit/MKNodeFieldCPUSubTypeFeatures.h>
#import <MachOKit/MKNodeFieldCPUSubTypeAny.h>
NS_ASSUME_NONNULL_BEGIN
//----------------------------------------------------------------------------//
//! @name I386 CPU SubTypes
//! @relates MKNodeFieldCPUSubTypeI386
//! @relates MKNodeFieldCPUSubTypeI386SubType
//!
//
NS_SWIFT_NAME(MKCPUSubType.I386_All)
static const MKCPUSubType MKI386CPUSubTypeAll = CPU_SUBTYPE_I386_ALL;
NS_SWIFT_NAME(MKCPUSubType.I386_486)
@ -79,7 +77,16 @@ static const MKCPUSubType MKI386CPUSubTypeXeonMP = CPU_SUBTYPE_XEON_MP;
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypeI386 : MKNodeFieldCPUSubTypeAny
@interface MKNodeFieldCPUSubTypeI386 : MKNodeFieldCPUSubType
+ (instancetype)sharedInstance;
@end
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypeI386SubType : MKNodeFieldCPUSubTypeAnySubType
+ (instancetype)sharedInstance;

View File

@ -29,13 +29,65 @@
#import "MKInternal.h"
#import "MKNodeDescription.h"
extern void OBJC_CLASS_$_MKNodeFieldCPUSubTypeI386;
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypeI386
static NSFormatter *s_BitfieldFormatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeI386)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
{
if (self != &OBJC_CLASS_$_MKNodeFieldCPUSubTypeI386)
return;
MKBitfieldFormatterMask *subtypeMask = [MKBitfieldFormatterMask new];
subtypeMask.mask = _$(~(uint32_t)CPU_SUBTYPE_MASK);
subtypeMask.formatter = MKNodeFieldCPUSubTypeI386SubType.sharedInstance.formatter;
MKBitfieldFormatterMask *capabilitiesMask = [MKBitfieldFormatterMask new];
capabilitiesMask.mask = _$((uint32_t)CPU_SUBTYPE_MASK);
capabilitiesMask.formatter = MKNodeFieldCPUSubTypeFeatures.sharedInstance.formatter;
capabilitiesMask.ignoreZero = YES;
NSArray *bits = [[NSArray alloc] initWithObjects:capabilitiesMask, subtypeMask, nil];
MKBitfieldFormatter *formatter = [MKBitfieldFormatter new];
formatter.bits = bits;
s_BitfieldFormatter = formatter;
[bits release];
[capabilitiesMask release];
[subtypeMask release];
}
//|++++++++++++++++++++++++++++++++++++|//
- (id<MKNodeFieldNumericType>)typeForMask:(NSNumber*)mask
{
if ([mask isEqual:_$((uint32_t)CPU_SUBTYPE_MASK)])
return MKNodeFieldCPUSubTypeFeatures.sharedInstance;
else
return MKNodeFieldCPUSubTypeI386SubType.sharedInstance;
}
//|++++++++++++++++++++++++++++++++++++|//
- (NSFormatter*)formatter
{ return s_BitfieldFormatter; }
@end
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypeI386SubType
static NSDictionary *s_Types = nil;
static MKEnumerationFormatter *s_Formatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeI386)
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeI386SubType)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize

View File

@ -25,9 +25,8 @@
//| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//----------------------------------------------------------------------------//
#include <MachOKit/macho.h>
#import <Foundation/Foundation.h>
#import <MachOKit/MKNodeFieldCPUSubType.h>
#import <MachOKit/MKNodeFieldCPUSubTypeFeatures.h>
#import <MachOKit/MKNodeFieldCPUSubTypeAny.h>
NS_ASSUME_NONNULL_BEGIN
@ -36,7 +35,6 @@ NS_ASSUME_NONNULL_BEGIN
//! @name PowerPC CPU SubTypes
//! @relates MKNodeFieldCPUSubTypePowerPC
//!
//
NS_SWIFT_NAME(MKCPUSubType.PowerPC_All)
static const MKCPUSubType MKPowerPCCPUSubTypeAll = CPU_SUBTYPE_POWERPC_ALL;
NS_SWIFT_NAME(MKCPUSubType.PowerPC_601)
@ -67,7 +65,16 @@ static const MKCPUSubType MKPowerPCCPUSubType970 = CPU_SUBTYPE_POWERPC_970;
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypePowerPC : MKNodeFieldCPUSubTypeAny
@interface MKNodeFieldCPUSubTypePowerPC : MKNodeFieldCPUSubType
+ (instancetype)sharedInstance;
@end
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypePowerPCSubType : MKNodeFieldCPUSubTypeAnySubType
+ (instancetype)sharedInstance;

View File

@ -29,13 +29,65 @@
#import "MKInternal.h"
#import "MKNodeDescription.h"
extern void OBJC_CLASS_$_MKNodeFieldCPUSubTypePowerPC;
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypePowerPC
static NSFormatter *s_BitfieldFormatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypePowerPC)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
{
if (self != &OBJC_CLASS_$_MKNodeFieldCPUSubTypePowerPC)
return;
MKBitfieldFormatterMask *subtypeMask = [MKBitfieldFormatterMask new];
subtypeMask.mask = _$(~(uint32_t)CPU_SUBTYPE_MASK);
subtypeMask.formatter = MKNodeFieldCPUSubTypePowerPCSubType.sharedInstance.formatter;
MKBitfieldFormatterMask *capabilitiesMask = [MKBitfieldFormatterMask new];
capabilitiesMask.mask = _$((uint32_t)CPU_SUBTYPE_MASK);
capabilitiesMask.formatter = MKNodeFieldCPUSubTypeFeatures.sharedInstance.formatter;
capabilitiesMask.ignoreZero = YES;
NSArray *bits = [[NSArray alloc] initWithObjects:capabilitiesMask, subtypeMask, nil];
MKBitfieldFormatter *formatter = [MKBitfieldFormatter new];
formatter.bits = bits;
s_BitfieldFormatter = formatter;
[bits release];
[capabilitiesMask release];
[subtypeMask release];
}
//|++++++++++++++++++++++++++++++++++++|//
- (id<MKNodeFieldNumericType>)typeForMask:(NSNumber*)mask
{
if ([mask isEqual:_$((uint32_t)CPU_SUBTYPE_MASK)])
return MKNodeFieldCPUSubTypeFeatures.sharedInstance;
else
return MKNodeFieldCPUSubTypePowerPCSubType.sharedInstance;
}
//|++++++++++++++++++++++++++++++++++++|//
- (NSFormatter*)formatter
{ return s_BitfieldFormatter; }
@end
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypePowerPCSubType
static NSDictionary *s_Types = nil;
static MKEnumerationFormatter *s_Formatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypePowerPC)
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypePowerPCSubType)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
@ -56,6 +108,8 @@ MKMakeSingletonInitializer(MKNodeFieldCPUSubTypePowerPC)
_$(CPU_SUBTYPE_POWERPC_750): @"CPU_SUBTYPE_POWERPC_750",
_$(CPU_SUBTYPE_POWERPC_7400): @"CPU_SUBTYPE_POWERPC_7400",
_$(CPU_SUBTYPE_POWERPC_7450): @"CPU_SUBTYPE_POWERPC_7450",
// PowerPC 970 is the "G5" - unclear if this subtype could appear
// alongside the CPU_TYPE_POWERPC in a valid Mach-O. TODO.
_$(CPU_SUBTYPE_POWERPC_970): @"CPU_SUBTYPE_POWERPC_970"
} retain];

View File

@ -0,0 +1,69 @@
//----------------------------------------------------------------------------//
//|
//| MachOKit - A Lightweight Mach-O Parsing Library
//! @file MKNodeFieldCPUSubTypePowerPC64.h
//!
//! @author D.V.
//! @copyright Copyright (c) 2014-2015 D.V. All rights reserved.
//|
//| Permission is hereby granted, free of charge, to any person obtaining a
//| copy of this software and associated documentation files (the "Software"),
//| to deal in the Software without restriction, including without limitation
//| the rights to use, copy, modify, merge, publish, distribute, sublicense,
//| and/or sell copies of the Software, and to permit persons to whom the
//| Software is furnished to do so, subject to the following conditions:
//|
//| The above copyright notice and this permission notice shall be included
//| in all copies or substantial portions of the Software.
//|
//| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
//| OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
//| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
//| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
//| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
//| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
//| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//----------------------------------------------------------------------------//
#import <MachOKit/MKNodeFieldCPUSubType.h>
#import <MachOKit/MKNodeFieldCPUSubTypeFeatures.h>
#import <MachOKit/MKNodeFieldCPUSubTypeAny.h>
NS_ASSUME_NONNULL_BEGIN
//----------------------------------------------------------------------------//
//! @name CPU Subtype Features for PowerPC 64-bit
//! @relates MKNodeFieldCPUSubTypePowerPC64Features
//!
typedef NS_OPTIONS(uint32_t, MKCPUSubTypePowerPC64Features) {
MKCPUSubTypePowerPC64FeatureLib64 = CPU_SUBTYPE_LIB64
};
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypePowerPC64 : MKNodeFieldCPUSubType
+ (instancetype)sharedInstance;
@end
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypePowerPC64SubType : MKNodeFieldCPUSubTypeAnySubType
+ (instancetype)sharedInstance;
@end
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypePowerPC64Features : MKNodeFieldCPUSubTypeFeatures <MKNodeFieldOptionSetType>
+ (instancetype)sharedInstance;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,182 @@
//----------------------------------------------------------------------------//
//|
//| MachOKit - A Lightweight Mach-O Parsing Library
//| MKNodeFieldCPUSubTypePowerPC64.m
//|
//| D.V.
//| Copyright (c) 2014-2015 D.V. All rights reserved.
//|
//| Permission is hereby granted, free of charge, to any person obtaining a
//| copy of this software and associated documentation files (the "Software"),
//| to deal in the Software without restriction, including without limitation
//| the rights to use, copy, modify, merge, publish, distribute, sublicense,
//| and/or sell copies of the Software, and to permit persons to whom the
//| Software is furnished to do so, subject to the following conditions:
//|
//| The above copyright notice and this permission notice shall be included
//| in all copies or substantial portions of the Software.
//|
//| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
//| OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
//| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
//| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
//| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
//| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
//| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//----------------------------------------------------------------------------//
#import "MKNodeFieldCPUSubTypePowerPC64.h"
#import "MKInternal.h"
#import "MKNodeDescription.h"
extern void OBJC_CLASS_$_MKNodeFieldCPUSubTypePowerPC64;
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypePowerPC64
static NSFormatter *s_BitfieldFormatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypePowerPC64)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
{
if (self != &OBJC_CLASS_$_MKNodeFieldCPUSubTypePowerPC64)
return;
MKBitfieldFormatterMask *subtypeMask = [MKBitfieldFormatterMask new];
subtypeMask.mask = _$(~(uint32_t)CPU_SUBTYPE_MASK);
subtypeMask.formatter = MKNodeFieldCPUSubTypePowerPC64SubType.sharedInstance.formatter;
MKBitfieldFormatterMask *capabilitiesMask = [MKBitfieldFormatterMask new];
capabilitiesMask.mask = _$((uint32_t)CPU_SUBTYPE_MASK);
capabilitiesMask.formatter = MKNodeFieldCPUSubTypePowerPC64Features.sharedInstance.formatter;
capabilitiesMask.ignoreZero = YES;
NSArray *bits = [[NSArray alloc] initWithObjects:capabilitiesMask, subtypeMask, nil];
MKBitfieldFormatter *formatter = [MKBitfieldFormatter new];
formatter.bits = bits;
s_BitfieldFormatter = formatter;
[bits release];
[capabilitiesMask release];
[subtypeMask release];
}
//|++++++++++++++++++++++++++++++++++++|//
- (id<MKNodeFieldNumericType>)typeForMask:(NSNumber*)mask
{
if ([mask isEqual:_$((uint32_t)CPU_SUBTYPE_MASK)])
return MKNodeFieldCPUSubTypePowerPC64Features.sharedInstance;
else
return MKNodeFieldCPUSubTypePowerPC64SubType.sharedInstance;
}
//|++++++++++++++++++++++++++++++++++++|//
- (NSFormatter*)formatter
{ return s_BitfieldFormatter; }
@end
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypePowerPC64SubType
static NSDictionary *s_Types = nil;
static MKEnumerationFormatter *s_Formatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypePowerPC64SubType)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
{
if (s_Types != nil && s_Formatter != nil)
return;
s_Types = [@{
// PowerPC 970 is the "G5" - the only 64-bit PowerPC processor
// supported by Darwin.
_$(CPU_SUBTYPE_POWERPC_970): @"CPU_SUBTYPE_POWERPC_970"
} retain];
MKEnumerationFormatter *formatter = [MKEnumerationFormatter new];
formatter.name = @"CPU_SUBTYPE_POWERPC64";
formatter.elements = s_Types;
formatter.fallbackFormatter = NSFormatter.mk_decimalNumberFormatter;
s_Formatter = formatter;
}
////
#pragma mark - MKNodeFieldEnumerationType
////
//|++++++++++++++++++++++++++++++++++++|//
- (MKNodeFieldEnumerationElements*)elements
{ return s_Types; }
////
#pragma mark - MKNodeFieldType
////
//|++++++++++++++++++++++++++++++++++++|//
- (NSString*)name
{ return @"PowerPC CPU Subtype"; }
//|++++++++++++++++++++++++++++++++++++|//
- (NSFormatter*)formatter
{ return s_Formatter; }
@end
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypePowerPC64Features
static NSDictionary *s_Capability = nil;
static MKOptionSetFormatter *s_CapabilityFormatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypePowerPC64Features)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
{
if (s_Capability != nil && s_CapabilityFormatter != nil)
return;
s_Capability = [@{
_$((uint32_t)CPU_SUBTYPE_LIB64): @"CPU_SUBTYPE_LIB64",
} retain];
MKOptionSetFormatter *formatter = [MKOptionSetFormatter new];
formatter.options = s_Capability;
s_CapabilityFormatter = formatter;
}
////
#pragma mark - MKNodeFieldOptionSetType
////
//|++++++++++++++++++++++++++++++++++++|//
- (MKNodeFieldOptionSetOptions*)options
{ return s_Capability; }
//|++++++++++++++++++++++++++++++++++++|//
- (MKNodeFieldOptionSetTraits)optionSetTraits
{ return 0; }
////
#pragma mark - MKNodeFieldType
////
//|++++++++++++++++++++++++++++++++++++|//
- (NSString*)name
{ return @"PowerPC64 CPU Subtype Features"; }
//|++++++++++++++++++++++++++++++++++++|//
- (NSFormatter*)formatter
{ return s_CapabilityFormatter; }
@end

View File

@ -25,37 +25,54 @@
//| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//----------------------------------------------------------------------------//
#include <MachOKit/macho.h>
#import <Foundation/Foundation.h>
#import <MachOKit/MKNodeFieldCPUSubType.h>
#import <MachOKit/MKNodeFieldCPUSubTypeFeatures.h>
#import <MachOKit/MKNodeFieldCPUSubTypeAny.h>
NS_ASSUME_NONNULL_BEGIN
//----------------------------------------------------------------------------//
//! @name X86 CPU SubTypes
//! @relates MKNodeFieldCPUSubTypeX86
//! @relates MKNodeFieldCPUSubTypeX86SubType
//!
//
NS_SWIFT_NAME(MKCPUSubType.X86_All)
static const MKCPUSubType MKX86CPUSubTypeAll = CPU_SUBTYPE_X86_ALL;
//----------------------------------------------------------------------------//
//! @name X86-64 CPU SubTypes
//! @relates MKNodeFieldCPUSubTypeX86
//!
//
NS_SWIFT_NAME(MKCPUSubType.X8664_All)
static const MKCPUSubType MKX8664CPUSubTypeAll = CPU_SUBTYPE_X86_64_ALL;
NS_SWIFT_NAME(MKCPUSubType.X8664_Haswell)
static const MKCPUSubType MKX8664CPUSubTypeHaswell = CPU_SUBTYPE_X86_64_H;
//----------------------------------------------------------------------------//
//! @name CPU Subtype Features for X86 64-bit
//! @relates MKNodeFieldCPUSubTypeX86Features
//!
typedef NS_OPTIONS(uint32_t, MKCPUSubTypeX86Features) {
MKCPUSubTypeX86FeatureLib64 = CPU_SUBTYPE_LIB64
};
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypeX86 : MKNodeFieldCPUSubTypeAny
@interface MKNodeFieldCPUSubTypeX86 : MKNodeFieldCPUSubType
+ (instancetype)sharedInstance;
@end
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypeX86SubType : MKNodeFieldCPUSubTypeAnySubType
+ (instancetype)sharedInstance;
@end
//----------------------------------------------------------------------------//
@interface MKNodeFieldCPUSubTypeX86Features : MKNodeFieldCPUSubTypeFeatures <MKNodeFieldOptionSetType>
+ (instancetype)sharedInstance;

View File

@ -29,13 +29,65 @@
#import "MKInternal.h"
#import "MKNodeDescription.h"
extern void OBJC_CLASS_$_MKNodeFieldCPUSubTypeX86;
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypeX86
static NSFormatter *s_BitfieldFormatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeX86)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
{
if (self != &OBJC_CLASS_$_MKNodeFieldCPUSubTypeX86)
return;
MKBitfieldFormatterMask *subtypeMask = [MKBitfieldFormatterMask new];
subtypeMask.mask = _$(~(uint32_t)CPU_SUBTYPE_MASK);
subtypeMask.formatter = MKNodeFieldCPUSubTypeX86SubType.sharedInstance.formatter;
MKBitfieldFormatterMask *capabilitiesMask = [MKBitfieldFormatterMask new];
capabilitiesMask.mask = _$((uint32_t)CPU_SUBTYPE_MASK);
capabilitiesMask.formatter = MKNodeFieldCPUSubTypeX86Features.sharedInstance.formatter;
capabilitiesMask.ignoreZero = YES;
NSArray *bits = [[NSArray alloc] initWithObjects:capabilitiesMask, subtypeMask, nil];
MKBitfieldFormatter *formatter = [MKBitfieldFormatter new];
formatter.bits = bits;
s_BitfieldFormatter = formatter;
[bits release];
[capabilitiesMask release];
[subtypeMask release];
}
//|++++++++++++++++++++++++++++++++++++|//
- (id<MKNodeFieldNumericType>)typeForMask:(NSNumber*)mask
{
if ([mask isEqual:_$((uint32_t)CPU_SUBTYPE_MASK)])
return MKNodeFieldCPUSubTypeX86Features.sharedInstance;
else
return MKNodeFieldCPUSubTypeX86SubType.sharedInstance;
}
//|++++++++++++++++++++++++++++++++++++|//
- (NSFormatter*)formatter
{ return s_BitfieldFormatter; }
@end
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypeX86SubType
static NSDictionary *s_Types = nil;
static MKEnumerationFormatter *s_Formatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeX86)
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeX86SubType)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
@ -44,8 +96,8 @@ MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeX86)
return;
s_Types = [@{
_$(CPU_SUBTYPE_X86_ALL): @"CPU_SUBTYPE_X86_ALL",
_$(CPU_SUBTYPE_X86_64_ALL): @"CPU_SUBTYPE_X86_64_ALL",
_$(CPU_SUBTYPE_X86_ARCH1): @"CPU_SUBTYPE_X86_ARCH1",
_$(CPU_SUBTYPE_X86_64_H): @"CPU_SUBTYPE_X86_64_H"
} retain];
@ -77,3 +129,54 @@ MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeX86)
{ return s_Formatter; }
@end
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUSubTypeX86Features
static NSDictionary *s_Capability = nil;
static MKOptionSetFormatter *s_CapabilityFormatter = nil;
MKMakeSingletonInitializer(MKNodeFieldCPUSubTypeX86Features)
//|++++++++++++++++++++++++++++++++++++|//
+ (void)initialize
{
if (s_Capability != nil && s_CapabilityFormatter != nil)
return;
s_Capability = [@{
_$((uint32_t)CPU_SUBTYPE_LIB64): @"CPU_SUBTYPE_LIB64",
} retain];
MKOptionSetFormatter *formatter = [MKOptionSetFormatter new];
formatter.options = s_Capability;
s_CapabilityFormatter = formatter;
}
////
#pragma mark - MKNodeFieldOptionSetType
////
//|++++++++++++++++++++++++++++++++++++|//
- (MKNodeFieldOptionSetOptions*)options
{ return s_Capability; }
//|++++++++++++++++++++++++++++++++++++|//
- (MKNodeFieldOptionSetTraits)optionSetTraits
{ return 0; }
////
#pragma mark - MKNodeFieldType
////
//|++++++++++++++++++++++++++++++++++++|//
- (NSString*)name
{ return @"x86 CPU Subtype Features"; }
//|++++++++++++++++++++++++++++++++++++|//
- (NSFormatter*)formatter
{ return s_CapabilityFormatter; }
@end

View File

@ -25,21 +25,19 @@
//| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//----------------------------------------------------------------------------//
#include <MachOKit/macho.h>
#import <Foundation/Foundation.h>
#include <mach/machine.h>
#import <MachOKit/MKBase.h>
#import <MachOKit/MKDataModel.h>
#import <MachOKit/MKNodeFieldTypeDoubleWord.h>
#import <MachOKit/MKNodeFieldEnumerationType.h>
#include <mach/machine.h>
NS_ASSUME_NONNULL_BEGIN
//----------------------------------------------------------------------------//
//! @name CPU Types
//! @relates MKNodeFieldCPUType
//!
//
typedef cpu_type_t MKCPUType NS_TYPED_EXTENSIBLE_ENUM;
static const MKCPUType MKCPUTypeAny = CPU_TYPE_ANY;
@ -61,6 +59,7 @@ static const MKCPUType MKCPUTypeI860 = CPU_TYPE_I860;
/* skip 16,17 */
static const MKCPUType MKCPUTypePowerPC = CPU_TYPE_POWERPC;
static const MKCPUType MKCPUTypePowerPC64 = CPU_TYPE_POWERPC64;
/* skip 19,20,21,22 */

View File

@ -28,6 +28,7 @@
#import "MKNodeFieldCPUType.h"
#import "MKInternal.h"
#import "MKNodeDescription.h"
#import "MKDataModel+Layout_Internal.h"
//----------------------------------------------------------------------------//
@implementation MKNodeFieldCPUType
@ -67,6 +68,10 @@ MKMakeSingletonInitializer(MKNodeFieldCPUType)
/* skip ((cpu_type_t) 17) */
_$(CPU_TYPE_POWERPC): @"CPU_TYPE_POWERPC",
_$(CPU_TYPE_POWERPC64): @"CPU_TYPE_POWERPC64"
/* skip ((cpu_type_t) 19) */
/* skip ((cpu_type_t) 20) */
/* skip ((cpu_type_t) 21) */
/* skip ((cpu_type_t) 22) */
} retain];
MKEnumerationFormatter *formatter = [MKEnumerationFormatter new];

View File

@ -27,3 +27,11 @@
#import <MachOKit/MKNodeFieldCPUType.h>
#import <MachOKit/MKNodeFieldCPUSubType.h>
#import <MachOKit/MKNodeFieldCPUSubTypeFeatures.h>
#import <MachOKit/MKNodeFieldCPUSubTypeAny.h>
#import <MachOKit/MKNodeFieldCPUSubTypeI386.h>
#import <MachOKit/MKNodeFieldCPUSubTypeX86.h>
#import <MachOKit/MKNodeFieldCPUSubTypeARM.h>
#import <MachOKit/MKNodeFieldCPUSubTypeARM64.h>
#import <MachOKit/MKNodeFieldCPUSubTypeARM6432.h>
#import <MachOKit/MKNodeFieldCPUSubTypePowerPC.h>