Re: Version of dynamic library
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Hi, Thanks, Graham. _______________________________________________ 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... 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. 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... - (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; } This email sent to site_archiver@lists.apple.com
participants (1)
-
Graham J Lee