Re: Version of dynamic library
Re: Version of dynamic library
- Subject: Re: Version of dynamic library
- From: Graham J Lee <email@hidden>
- Date: Fri, 11 Apr 2008 14:31:56 +0100
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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden