[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Changing entry point function
From: |
John V. Shahid |
Subject: |
Re: Changing entry point function |
Date: |
Thu, 09 Aug 2007 04:58:11 -0400 |
On Wed, 2007-08-08 at 18:15 -0700, Paul Pluzhnikov wrote:
> You can ask gcc not to add crt0.o (-nostdlib), and make liker set
> entry point to mymain(), but the result will likely crash either
> before or after mymain. For example, on my system:
>
> $ g++ -g junk.cpp -nostdlib -lstdc++ -lc -Wl,-emymain__Fv
> $ ./a.out
> my-main
> Segmentation fault (core dumped)
>
> This particular crash is happening because mymain() returns to
> address 0x00000001, which is actually argc, pushed onto stack by
> the kernel.
But you can always call exit() instead of returning. I tried it and it
seems to be working, but there's still the question, why do you need to
break the rules ? I just can't see the reason, can you point out to
them.
Regards,
--
John V. Shahid <jvshahid@gmail.com>