简体   繁体   English

c 编译器如何识别系统调用?

[英]How does a c-compiler recognizes system-calls?

Let's say we want to create a socket using the "socket"-function.假设我们想使用“socket”函数创建一个套接字。 How does the compiler know that it has to invoke a system call for that corresponding function?编译器如何知道它必须为相应的 function 调用系统调用? Is there any internal table that records with functions belong to a specific set of library?是否有记录功能属于特定库集的内部表?

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.您平台的库包括一个名为 function 的socket ,其中包含在您的平台上进行系统调用所需的实际代码。 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.编译器读入一个 header 文件,该文件告诉它这个 function 存在,linker 将编译后的代码连接到那个 function,而库对那个 function 的实现进行实际的系统调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM