jeudi 21 juillet 2016

Why is stdlib required to link programs? [duplicate]

This question already has an answer here:

Take the following C program:

int main(){}

It's not using anything from the C standard library.
I assumed we could disable linkage 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 the _start symbol is and who is responsible for providing it?
How would one go about using -nostdlib?


Per the docs, I have also tried:

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

Same behaviour is seen with clang.

Aucun commentaire:

Enregistrer un commentaire