我是内核编码的新手,我正在完成一项学校作业。我应该将一个系统调用添加到内核并编译它。 到目前为止我所做的事情如下: 我在内核中创建了一个文件夹,称之为syscalls。
在syscall文件夹中我添加了3个文件:
1)syscall.c 2)syscall.h 3)makefile
make文件只有一行代码如下
obj-y := syscall.o
syscall.c有一个方法如下:
asmlinkage long sys_call_function(struct array_stats *stats, long data[],long size)
然后我将以下内容添加到arch / x86 / syscalls / syscall_64.tbl
330 common syscall sys_call_function
然后我将粗体文本添加到内核的Make文件中 core-y + = kernel / mm / fs / ipc / security / crypto / block / 系统调用 /
然后我 make clean 然后 make -j3 但我得到以下错误:
make[1]: *** No rule to make target `syscalls/syscall.o', needed by `syscalls/built-in.o'. Stop.
make: * [cs300]错误2 make:* 等待未完成的工作......
任何人都可以给我一些提示。我被困住了,无法前进。
答案 0 :(得分:0)
使用此补丁(针对v4.0-rc7)
diff --git a/Makefile b/Makefile
index 54430f9..874ac96 100644
--- a/Makefile
+++ b/Makefile
@@ -884,7 +884,7 @@ export mod_sign_cmd
ifeq ($(KBUILD_EXTMOD),)
-core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
+core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ xyz/
vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
$(core-y) $(core-m) $(drivers-y) $(drivers-m) \
diff --git a/xyz/Makefile b/xyz/Makefile
new file mode 100644
index 0000000..0096b34
--- /dev/null
+++ b/xyz/Makefile
@@ -0,0 +1 @@
+obj-y := abc.o
diff --git a/xyz/abc.c b/xyz/abc.c
new file mode 100644
index 0000000..1edff5b
--- /dev/null
+++ b/xyz/abc.c
@@ -0,0 +1,4 @@
+int somefunc(int somevar)
+{
+ return somevar + 2;
+}
我无法重现你的问题。你可以发贴补丁吗?