Re: Executable entry point
Re: Executable entry point
- Subject: Re: Executable entry point
- From: Geoffrey Lee <email@hidden>
- Date: Sun, 18 Mar 2007 18:50:05 +1100
On Sun, Mar 18, 2007 at 01:43:48AM +0000, Filipe Cabecinhas wrote:
> Hi
>
> I'm trying to port a compiler we had in class for Mac OS X but I'm
> having a little problem with the executable's entry point.
>
> Our compiler translates from the source language to assembly, then I
> would assemble it with NASM, link it with our run-time library and
> then I could run it.
>
> I tried to port the run-time library (changing the "int 0x80" to
> "sysenter"s and some other house-keeping stuff) and I'm trying to
> test it to see if that went well.
>
> The problem is: After the assembling and linking part (both go well,
> without any kind of warnings or errors), I try to execute it but it
> doesn't run. I was thinking darwin would call the _start function but
> maybe that's not the case. I also tried googling to see if I could
> tell nasm/ld which function was the entry point but I had no luck.
>
> The question is: how does darwin know where is the entry point of the
> binary and how can I choose it?
>
Use -e flag in ld(1). It is actually stored in the thread state,
the kernel loads this thread state when the binary is loaded, you can
see for yourself with otool -l, srr0 on ppc and eip on 32bit x86.
- gl
> If I should post in another list please tell me which. By reading the
> titles of the lists, this one seemed the best.
>
> Thanks for the help
>
> Filipe Cabecinhas
>
> _______________________________________________
> 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
>
_______________________________________________
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