site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=pOEozQg9vdCfn3577auXMTvND2LCFE3vytThGjCCFpU=; b=qdB6AI+7MATjLaoDXhEJBqlOQcj7Tj3+lI9UhF5ywwhbsNO+bxLP9s/rr9rS2NUmdg6SThdiVEFsBY7VNFvbvMHQEeH2kGSti0+WzvFSJPMmS+rkhSWg4Hv80NPYXhOMcVzmBmokTIiVWuW0wHvPTi64B5B7uY0QQnmQsePSavI= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=G913oS+ZivX0aQyip24rNMehNMrUOAlwuTFZvJf2e3iNx5KGZRdvTTzf7Vg5vMMP8OWyQ5OZLLDOd53u8My3xPHrDIX03C8Z5wMFfaS9b0zdoujyI9EIp3gjya6lxi6i+oJaG3NmHPgETbkM4H11oFQtPy0lPktbrmpeN0heVRI= ok it seems that you want to get the compatibility version and the current version of a shared object? - like otool does? - do you try to determine the version for dlopening it? On Fri, Apr 11, 2008 at 6:31 AM, Graham J Lee <leeg@thaesofereode.info> wrote:
On 11 Apr 2008, at 14:13, anukriti_shrimal wrote:
Now, my problem is that for all fat_arch structs, I am getting cpu_type =
0
or 3. But the header file mach/machine.h doen't define 3 or 0 to be valid types. My machine is having cpu_type = 7 (x86) and cpu_subtype = 4. Since these don't match, I m unable to proceed further.
Hi,
I can only guess that you're doing it wrong :-(. I've written code to investigate the content of Mach-O and Mach fat files, and getting the CPU type information just works. Here are some snippits (some error-checking and tracing code removed). Getting this into a state where you could use the code is left as an exercise for the reader...
Thanks, Graham.
- (NSArray *)architectureStrings { GLInstanceMethodEntryLog(@"finding architectures"); int i; NSMutableArray *strings = [NSMutableArray array]; for (i = 0; i < header.nfat_arch; i++) { struct fat_arch arch = eachFatArch[i]; NSString *string = MachArchitectureForCpu(arch.cputype, arch.cpusubtype); [strings addObject: string]; } GLInstanceMethodExitLog(@"copying and returning %@", strings); return [[strings copy] autorelease]; }
- (id)initWithPath: (NSString *)fatFile { GLInstanceMethodEntryLog(@"instantiating with path: %@", fatFile); self = [super init]; if (self) { int fd, bytesRead, fatArchesToRead, i; NSFileManager *fm = [NSFileManager defaultManager]; char *cPath = (char *)[fm fileSystemRepresentationWithPath: fatFile]; //read the Fat header in fd = open(cPath, O_RDONLY); bytesRead = read(fd, &header, sizeof(struct fat_header)); // do some byteswap header.magic = NSSwapBigIntToHost(header.magic); if (header.magic != FAT_MAGIC) { GLInstanceMethodExitLog(@"this isn't a Fat file!"); close(fd); return nil; } header.nfat_arch = NSSwapBigIntToHost(header.nfat_arch); // read the fat_arch headers in fatArchesToRead = header.nfat_arch * sizeof(struct fat_arch); eachFatArch = malloc(fatArchesToRead); bytesRead = read(fd, eachFatArch, fatArchesToRead); close(fd); // do something with the fat_arch headers } return self;
}
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-kernel/openspecies%40gmail.com
This email sent to openspecies@gmail.com
-- -mmw _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
mm w