This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: what's the right way to use custom entry point
- From: Cong Monkey <congzhangzh at gmail dot com>
- To: Florian Weimer <fw at deneb dot enyo dot de>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sun, 6 Nov 2016 19:57:27 +0800
- Subject: Re: what's the right way to use custom entry point
- Authentication-results: sourceware.org; auth=none
- References: <CAOXDmPrEA1hEaP35Cu29LtzVHMPqBqveGj8E5cowZgngqBWxSA@mail.gmail.com> <8737jk42d8.fsf@mid.deneb.enyo.de>
Tks for your advice:)
Another question:
What's the easy way to self get (int argc, char** argv) for self entry point!
I use a not so elegant way like:
https://gist.github.com/congzhangzh/5141f1c4de4e7ac85d6f8d6a630207e7
2016-10-26 4:09 GMT+08:00 Florian Weimer <fw@deneb.enyo.de>:
> * 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.