Why is stdlib required for linking programs?

Take the following program C:

int main(){}

It does not use anything from the C standard library.
I suggested that we can disconnect communication through - nostdlib .

However, this results in the following error:

$ gcc -nostdlib -o main main.c
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000400150

Can someone clarify what is a symbol _startand who is responsible for providing it?
How can i use it -nostdlib?


In the docs, I also tried:

$ gcc -nostdlib -o main main.c -lgcc

The same behavior is observed with clang.

+4
source share
1 answer

_start - , . . libc , , , main. , libc, C- .

libc, _start. , , , . - libc, , _exit.

+1

All Articles