Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does a c-compiler recognizes system-calls?

Let's say we want to create a socket using the "socket"-function. How does the compiler know that it has to invoke a system call for that corresponding function? Is there any internal table that records with functions belong to a specific set of library?

like image 642
NHSH Avatar asked Aug 31 '25 20:08

NHSH


1 Answers

The usual method is this:

Your platform's library includes a function called socket that contains the actual code needed to make a system call on your platform. The compiler reads in a header file that tells it that this function exists, the linker connects the compiled code to that function, and the library's implementation of that function makes the actual system call.

like image 138
David Schwartz Avatar answered Sep 04 '25 04:09

David Schwartz