verma wrote:
> Thanks Ali for your response.
> Ali wrote:
>> I may be missing something, but if foo() is
>> your entry point, what are you returning to?
> Yes foo() is my entry point.
> 
>> I think exit(0) is your only way out.
> Ok but why exit(0) is required. Why I can not use return 0.
>  

Because the code that makes that work is the code
you pushed out of the way by specifying your
own entry point. This was the point of my
original question: What would foo() be returning to?

In a normal executable, the entry point is _start.
_start sets things up, and then calls your main()
function (note that main() is not your entry point).
When main() returns, it is returning to _start().
That code calls exit() for you.

Changing your entry point to foo() pushes all of that
code aside. Sorry, but I don't know what you have to
supply to replace it. You could dig into the code for
ld.so.1 to figure out why your code core dumps on exit
from foo().

- Ali

Reply via email to