Skip to content

Commit

Permalink
Think this fixes some problems with fat files, finding the desired arch.
Browse files Browse the repository at this point in the history
  • Loading branch information
nygard committed Jun 26, 2009
1 parent a4717bc commit 345f00b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions CDFatArch.h
Expand Up @@ -25,6 +25,7 @@
- (void)dealloc;

- (cpu_type_t)cpuType;
- (cpu_type_t)maskedCPUType;
- (cpu_subtype_t)cpuSubtype;
- (uint32_t)offset;
- (uint32_t)size;
Expand Down
10 changes: 8 additions & 2 deletions CDFatArch.m
Expand Up @@ -27,7 +27,7 @@ - (id)initWithDataCursor:(CDDataCursor *)cursor;
fatArch.align = [cursor readBigInt32];

uses64BitABI = (fatArch.cputype & CPU_ARCH_MASK) == CPU_ARCH_ABI64;
fatArch.cputype &= ~CPU_ARCH_MASK;
//fatArch.cputype &= ~CPU_ARCH_MASK;
#if 0
NSLog(@"type: 64 bit? %d, 0x%x, subtype: 0x%x, offset: 0x%x, size: 0x%x, align: 0x%x",
uses64BitABI, fatArch.cputype, fatArch.cpusubtype, fatArch.offset, fatArch.size, fatArch.align);
Expand All @@ -50,6 +50,11 @@ - (cpu_type_t)cpuType;
return fatArch.cputype;
}

- (cpu_type_t)maskedCPUType;
{
return fatArch.cputype & ~CPU_ARCH_MASK;
}

- (cpu_subtype_t)cpuSubtype;
{
return fatArch.cpusubtype;
Expand Down Expand Up @@ -95,9 +100,10 @@ - (NSString *)description;
// Must not return nil.
- (NSString *)archName;
{
#if 0
if (uses64BitABI)
return CDNameForCPUType(fatArch.cputype | CPU_ARCH_ABI64, fatArch.cpusubtype);

#endif
return CDNameForCPUType(fatArch.cputype, fatArch.cpusubtype);
}

Expand Down
10 changes: 6 additions & 4 deletions CDFatFile.m
Expand Up @@ -92,17 +92,17 @@ - (NSString *)bestMatchForLocalArch;

// This architecture, 32 bit
for (CDFatArch *fatArch in arches) {
if ([fatArch cpuType] == targetType && [fatArch uses64BitABI] == NO)
if ([fatArch maskedCPUType] == targetType && [fatArch uses64BitABI] == NO)
return [fatArch archName];
}

// This architecture, 64 bit
for (CDFatArch *fatArch in arches) {
#ifdef __LP64__
if ([fatArch cpuType] == targetType && [fatArch uses64BitABI])
if ([fatArch maskedCPUType] == targetType && [fatArch uses64BitABI])
return [fatArch archName];
#else
if ([fatArch cpuType] == targetType && [fatArch uses64BitABI])
if ([fatArch maskedCPUType] == targetType && [fatArch uses64BitABI])
didFind64BitArch = YES;
#endif
}
Expand Down Expand Up @@ -141,11 +141,13 @@ - (CDMachOFile *)machOFileWithArchName:(NSString *)name;
const NXArchInfo *archInfo;
cpu_type_t maskedCPUType;

NSLog(@"%s, name=%@", _cmd, name);
archInfo = NXGetArchInfoFromName([name UTF8String]);
if (archInfo == NULL)
return nil;

maskedCPUType = archInfo->cputype & ~CPU_ARCH_MASK;
//maskedCPUType = archInfo->cputype & ~CPU_ARCH_MASK;
maskedCPUType = archInfo->cputype;
for (CDFatArch *arch in arches) {
if ([arch cpuType] == maskedCPUType)
return [arch machOFile];
Expand Down

0 comments on commit 345f00b

Please sign in to comment.