Re: Version of dynamic library
Re: Version of dynamic library
- Subject: Re: Version of dynamic library
- From: "mm w" <email@hidden>
- Date: Fri, 11 Apr 2008 07:19:53 -0700
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 <email@hidden> 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 (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
>
> This email sent to email@hidden
>
--
-mmw
_______________________________________________
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