0

故事

我有一个自动生成系统调用编号列表的 C 程序,因为我更喜欢从现实世界的参考中自动生成,而不是在适用时手写生成的文件。目标是一个 Ada 包。我已经使用涉及公共write系统调用的经典“Hello world”进行了测试……它失败了。我认为系统调用号是错误的:64 而不是 4。

我从 C 程序生成了列表,包括<asm-generic/unistd.h>. 该平台为 32 位,从未安装过针对 64 位平台的工具链。

示例定义unistd.h:(#define __NR_write 64应该是 4)、#define __NR_read 63(应该是 3)、#define __NR_getuid 174(应该是 24)等等……</p>

我已经在所有文件中运行了文本搜索,以查找将是预期定义的一部分的出现,但没有找到/usr/**__NR_write

问题

为什么此标头指定奇怪的系统调用号?为什么找不到预期的定义?这是新的 ABI 吗?

注:平台为 Ubuntu 12.04,32 位。

更新

我想出了一些运行这个命令的东西:

find /usr/include/ -name "unistd*" -exec nano '{}' \;

它显示标题/usr/include/i386-linux-gnu/asm/unistd_32.h包含正确的数字,并且该标题包含在 中/usr/include/i386-linux-gnu/asm/unistd.h,但包含时未定义许多符号<asm/unistd.h>

更新 2

不仅数字不同,而且名称也不同。前任。__NR_socket__NR_socketcall。解释的开头可能在可能的副本中给出:  arch/x86/include/asm/unistd.h vs. include/asm-generic/unistd.h

4

2 回答 2

3

如果您从/usr/include/sys/syscall.h开始(如 syscall(2) 中所示)并重复遵循包含指令,您将到达/usr/include/asm/unistd_32.h。因此,我建议您使用此标头。

于 2013-04-11T11:28:16.517 回答
0

从来源asm-generic.h

  6 /*
  7  * This file contains the system call numbers, based on the
  8  * layout of the x86-64 architecture, which embeds the
                     ^^^^^^
  9  * pointer to the syscall in the table.
 10  *
       ...
 15  */
于 2013-04-10T23:30:39.970 回答