This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: what's the right way to use custom entry point


* Cong Monkey:

> Hi,
>
> I want use custom entry point, but it's very strange!
>
> entry_point_test.c file:
>
> int sayhello(int argc, char** argv)
> {
>     return 0;
> }

> if I do:
>    cc  ../entry_point_test.c  -o entry_point_test -Wl,-esayhello
> -nostartfiles #cc works
>    ./a.out
> then I get:
>    # Segmentation fault
>
> anyone can help what should I do?

It depends on the system.  In general, the entry point function must
not return because there is nothing to return to.  In general, you
need to perform a system call to terminate the process.

I checked your example on Linux, and it works.  The crash happens
after the function returns.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]