Reputation: 8129
So I was trying to set my own custom name for main
in my C program, and I found this answer.
You can specify an entry point to your program using the
-e
flag told
. That means you can override the entry point if you like, but you may not want to do that for a C program you intend to run normally on your machine, sincestart
might do all kinds of OS specific stuff that's required before your program runs.
What would be the (possible) drawbacks of not calling _start
from crt0.o
and writing my own that simply does whatever I want it to?
Upvotes: 0
Views: 145
Reputation: 8657
The entry point usually does stuff like
main
and handles its exit
main
and destructors afterenviron
and the likestdio
streams and such.bss
if your loader doesn'tThese things are tightly coupled to your C implementation, so usually you provide your own _start
only when you are targeting a freestanding environment.
Upvotes: 1