不同内核情况不同
静态编译
将驱动程序增加到内核源码中,通过 Kconfig对驱动进行配置
内核源码树的目录下都有两个文档Kconfig 和Makefile
- 分布到各目录的Kconfig构成了一个分布式的内 核配置数据库,每个Kconfig分别描述了所属目 录源文档相关的内核配置菜单。
- 在内核配置make menuconfig(或xconfig等)时, 从 Kconfig 中 读 出 菜 单 , 用 户 选 择 后 保 存 到.config的内核配置文档中。
执行 sudo make mrproper 清除.config和.o文件。
还原最初的状态
syscall_32.tbl contains system calls for x86 32 bit and
syscall_64.tbl contains intel x86-64bit syscalls. add new entry into appropriate table as per x86 variant you are using .
Step 1:
sudo vim arch/x86/entry/syscalls/syscall_64.tbl
333 64 newscall sys_newscal
Step 2:
sudo vim include/linux/syscalls.h
asmlinkage long sys_newscall(void);
Step 3:
Step 4:
重新编译内核
Step 5:
用户空间下建立一个文件 syscall.c
编译并运行
#include <stdio.h>
#include <stdlib.h>
int newscall() {
int ret;
__asm__("movl $***, %eax");
__asm__("int $0x80");
__asm__("movl %eax, -4(%ebp)");
return ret;
}
int main(void) {
long ret;
ret = newscall();
if (ret < 0)
exit(1);
printf("%ld\n", ret);
return 0;
}
(未完待续……)
也可以参考 https://blog.csdn.net/qvjunping/article/details/72771848