如果您对有没有原始的linux系统调用API/ABI文档和linux调用http感兴趣,那么这篇文章一定是您不可错过的。我们将详细讲解有没有原始的linux系统调用API/ABI文档的各种细节,并对l
如果您对有没有原始的linux系统调用API / ABI文档和linux调用http感兴趣,那么这篇文章一定是您不可错过的。我们将详细讲解有没有原始的linux系统调用API / ABI文档的各种细节,并对linux调用http进行深入的分析,此外还有关于Linux System Calls (Linux系统调用)、linux – 从/ proc / kcore获取系统调用表中的系统调用地址、linux – 如果程序在仅EABI内核中进行OABI样式的系统调用会发生什么?、linux 内核学习中遇到的有关 系统调用号和系统调用表的问题的实用技巧。
本文目录一览:- 有没有原始的linux系统调用API / ABI文档(linux调用http)
- Linux System Calls (Linux系统调用)
- linux – 从/ proc / kcore获取系统调用表中的系统调用地址
- linux – 如果程序在仅EABI内核中进行OABI样式的系统调用会发生什么?
- linux 内核学习中遇到的有关 系统调用号和系统调用表的问题
有没有原始的linux系统调用API / ABI文档(linux调用http)
系统调用有两(2)页,但这些页面描述了位于系统调用之上的C库(glibc)的行为。 原始系统调用API / ABIlogging在某处(UseTheSourceLuke除外)? 我在man手册中看到了一些kernel / libc之间的区别,但是我并没有觉得把这些差异logging下来是最重要的。
我真正的意思是说:C库是否被POLICY认为是稳定/有logging的Linux API,并且内核的系统调用API / ABI被认为是不稳定的(可能会改变),因此没有目的或低优先级?
那么更改系统调用的内核开发人员在glibc中做出了解决方法? 那么其他的libc呢?
我可以find关于这个问题的历史讨论吗?
4GB / 4GB内核虚拟机分割
没有find新的系统调用(Linux内核3.0.0)我应该从哪里开始寻找?
从用户模式访问内核内存(Windows)
在VmWare虚拟机内实现一个Linux客户操作系统的内核debugging模块
为什么在内核编程中使用了u8而不是unsigned int?
编辑:所以ABI是稳定的,也是系统调用的行为,但是它们没有被内核开发者logging。 glibc正在logging它们(带有自己的添加/更改)。 正确?
linux内核开发
linux kallsyms R符号不显示
如何在Linux中解码/ proc / pid / pagemap条目?
IP数据包在源主机上的频率是多less?
在linux内核中,会不会打电话给kfree?
我不认为内核开发者会发布中断API,但是你可以找到像这样的第三方图表。
你的问题的答案是在系统调用手册页 。 特别要注意章节标题“架构调用约定”,并注意到John Bollinger所提到的,这个信息可能因内核版本而异。
我真正的意思是说:C库是否被POLICY认为是稳定的/有记录的Linux API,并且内核的系统调用API / ABI被认为是不稳定的(可能会改变),因此没有目的或低优先级?
没有明确规定谁的政策, 什么政策,就不可能讲政策。
编程“Linux”的人通常实际上是为一种或多种GNU / Linux编程,而不是裸核。 因此,我倾向于说我们可能不考虑内核开发者策略。 事实上,如果C库接口是可用的,那么我们不是在谈论一个裸机内核。 而且,根据你的标签,我假设你在问C编程。 如果你是在程序集中编程,那么原始的系统调用接口将是自然和适当的,其余大部分我的意见不适用。
如果你的确把GNU / Linux作为排除其他任何事情的话,那么这个问题就有些明智了。 另一方面,通常情况下,人们更喜欢为了更广泛的兼容性而编程。 在这种情况下,使用C库系统调用接口确实没有其他选择,因为每个系统的原始系统调用是不同的。 Glibc的系统调用接口在符合POSIX和SUS方面做得相当不错,所以正确使用它们对可移植性来说是一个巨大的优势。 即使其他类Unix系统(如OS X,BSD,Solaris等)不是直接的目标,在这样的系统上开放使用软件的可能性也是很少的损失。
无论如何,如果您决定让您的软件直接执行Linux系统调用,那么您是否确实要插入内联汇编来随心所欲地执行该操作? 当然不是 – 你会写封装函数。 那么为什么要反对使用C库已经提供的经过充分测试和充分记录的包装函数呢?
当然Linux系统调用接口在内核版本之间确实有所变化。 这可以被认为是使版本不同的东西(我的意思是x.2y – > x.2z或xy – > zw )。 我并没有很好地了解这种变化通常会有多大,但过去一直存在不兼容的变化,并且使用C库接口在某种程度上使您免于这种变化。 不过,如上所述,我认为还有其他更喜欢C库接口的更多原因。
Linux System Calls (Linux系统调用)
POSIX APIs and System Calls
The difference between an API and a system call
API: Function definition that specifies how to obtain a given service
System Call: an explicit request to the kernel made via a software interrupt
Wrapper routine: routine whose only purpose is to issue a system call
POSIX standard refer to a set of APIs and not to system calls.
System Call Handler and System Routine
The conventions for return values of system calls are different from those of wrapper routines.
0 or positive integers indicate a successful termination of the system call while negative integers indicate a failure. It is the wrapper routines’ responsibility to set errno.
System call number: specify the system call to invoke
System call handler: similar to exception handlers
Save registers -> call system call service routine -> load registers and switch back to user mode
Naming rules:
System call: xxxx()
System service routine: sys_xxxx()
System call dispatch table
System call number ßà service routine
Entering and Exiting a system call
Two ways to enter and exit a system call
Enter: int $0x80 Exit: iret
Enter: sysenter Exit: sysexit
0x80 (128) in Interrupt Descriptor Table
Set_system_gate(0x80, &system_call)
(See interrupt, trap and system gates in chapter 4)
Parameter passing
System call numbers: (example)
#define __NR_restart_syscall (__NR_SYSCALL_BASE+ 0)
#define __NR_exit (__NR_SYSCALL_BASE+ 1)
#define __NR_fork (__NR_SYSCALL_BASE+ 2)
#define __NR_read (__NR_SYSCALL_BASE+ 3)
#define __NR_write (__NR_SYSCALL_BASE+ 4)
#define __NR_open (__NR_SYSCALL_BASE+ 5)
#define __NR_close (__NR_SYSCALL_BASE+ 6)
/* 7 was sys_waitpid */
#define __NR_creat (__NR_SYSCALL_BASE+ 8)
#define __NR_link (__NR_SYSCALL_BASE+ 9)
#define __NR_unlink (__NR_SYSCALL_BASE+ 10)
#define __NR_execve (__NR_SYSCALL_BASE+ 11)
#define __NR_chdir (__NR_SYSCALL_BASE+ 12)
#define __NR_time (__NR_SYSCALL_BASE+ 13)
#define __NR_mknod (__NR_SYSCALL_BASE+ 14)
#define __NR_chmod (__NR_SYSCALL_BASE+ 15)
The system call number is set by wrapper routines, so the programmer usually does not need to care about it.
è Set eax register to the system call number
è Write parameters into CPU registers (we cannot write parameters into stacks as usual because the system call cross both kernel stack and user mode stack.
è The kernel copies the parameters into the kernel mode stack
è Call int 0x80 or sysenter
(Ordinary C functions use parameters via a stack, either kernel mode stack or user mode stack.)
Because we use registers to pass parameters, two conditions must be satisfied:
1. The length of the parameter cannot exceed the length of a register.
2. The number of parameters cannot exceed six, besides the system call number passed by eax.
These two conditions implies to two things. One, large parameters must be passed by reference. Two, if more than six parameters are needed, a single register is used to point to a memory area in the process address space. Of course, the programmer need not care about this workaround. The wrapper routine will find the appropriate way to pass the parameters to the kernel.
Kernel Wrapper Routines
Although system calls are mainly used by User Mode processes, they can also be invoked by kernel threads, which cannot use library functions.
References:
Understanding the Linux Kernel, 3rd
linux – 从/ proc / kcore获取系统调用表中的系统调用地址
解决方法
获取x86-64本机系统调用表是类似的:不是使用sidt重建中断表,而是读取处理器的IA32_LSTAR MSR. (高<< 32 |低)的地址是系统调用调度程序.像以前一样扫描内存,从调用指令中提取sys_call_table地址,但记得屏蔽地址的高32位. 这掩盖了许多更加技术性的信息(比如要搜索的字节),你应该在内核代码中探讨之前理解这些信息.快速谷歌搜索后,我发现整个过程都有记录(带有示例模块代码)here.
祝你好运,尽量不要惹恼自己!
linux – 如果程序在仅EABI内核中进行OABI样式的系统调用会发生什么?
解决方法
编辑:ARM ARM确认SWI对其论点没有做任何有用的事情. (物理页面634 /逻辑页面A7-118.)
linux 内核学习中遇到的有关 系统调用号和系统调用表的问题
最近刚开始看《linux 内核设计与实现》这本书,有这么一段话:
由于系统调用表中的项是以 64 位(8 字节)类型存放的,所以内核需要将给定的内核调用号乘以 4,然后用得到的结果在该表中查询其位置。在 x86-32 系统上,代码类似,只是用 4 代替 8.
我现在感到困惑的是,为什么要把内核调用号乘以 4???
我们今天的关于有没有原始的linux系统调用API / ABI文档和linux调用http的分享已经告一段落,感谢您的关注,如果您想了解更多关于Linux System Calls (Linux系统调用)、linux – 从/ proc / kcore获取系统调用表中的系统调用地址、linux – 如果程序在仅EABI内核中进行OABI样式的系统调用会发生什么?、linux 内核学习中遇到的有关 系统调用号和系统调用表的问题的相关信息,请在本站查询。
本文标签: