Hi I made a simple hello world C program and I am compiling it like this :
gcc -c hello.c
ld hello.o -lc -o out
I get a warning from ld : ld : _start not found defaulting to ....
I do an objdump -D hello.o and I cannot find the _start routine in the output.
What am I missing here ?
You’re missing the
crt*stuff which you will see if you link withgcc -v:crt1.o,crtend.o,crtn.o. Look at howgccinvokescollect2(it’s visible withgcc -v) and use the same options forld.mainfunction is not the executable entry point: some initialization for standard library is done beforemain(because it’s either impossible or illogical to do otherwise). Real entry point, which is_startby default, is incrt1.owhich is always linked into your executable.