Re: Finding the architectures of a binary
Re: Finding the architectures of a binary
- Subject: Re: Finding the architectures of a binary
- From: "Clark Cox" <email@hidden>
- Date: Mon, 10 Nov 2008 10:49:40 -0800
On Mon, Nov 10, 2008 at 10:20 AM, Iceberg-Dev <email@hidden> wrote:
>
> On Nov 10, 2008, at 7:06 PM, Clark Cox wrote:
>
>> On Mon, Nov 10, 2008 at 9:23 AM, Iceberg-Dev <email@hidden>
>> wrote:
>>>
>>> On Nov 10, 2008, at 4:08 PM, Finlay Dobbie wrote:
>>>>
>>>>
>>>> http://www.opensource.apple.com/darwinsource/10.5.5/cctools-667.3/misc/lipo.c
>>>
>>> Thanks.
>>>
>>> Is it supoosed to be up-to-date and 64-bit compatible?
>>>
>>> I'm asking because for instance, this line looks suspicious:
>>>
>>> (*((unsigned long *)addr) == MH_MAGIC ||
>>
>> What looks suspicious about it?
>
> The ability to run this code as a 64-bit executable.
>
> The magic cookie is a 32-bit value. AFAIK, if you build a 64-bit executable
> and use unsigned long, it's a 64-bit value.
>
> With a PowerPC, I'm not sure you can guarantee that the higher 4 bytes will
> be equal to 0x00000000 as the magic cookie can be the first 4 bytes of a
> file (non fat). With an Intel Mac, the issue would be different, since it
> would assume that the 4 bytes after the magic cookie in the binary should be
> 0x00000000 instead of the cpu_type.
Ahh, I see what you mean. No, it does not appear to be 64-bit clean.
It probably wouldn't be too hard to hack up your own version that uses
unsigned int (or uint32_t, UInt32, etc.) instead of unsigned long
--
Clark S. Cox III
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden