此错误将停止内核生成进程。
ld: arch/x86/entry/syscall_64.o:(.rodata+0x1120): undefined reference to `__x64_sys_fd'
BTF .btf.vmlinux.bin.o
pahole: .tmp_vmlinux.btf: No such file or directory
LD .tmp_vmlinux.kallsyms1
.btf.vmlinux.bin.o: file not recognized: file format not recognized下面是我在linux内核源代码中修改的文件
fd.c
#include <linux/kernel.h>
#include <linux/syscalls.h>
#include <linux/fdtable.h>
#include <linux/pid.h>
#include <linux/sched/signal.h>
#include <linux/fs.h>
SYSCALL_DEFINE4(fd, pid_t, pid_input, struct fdtable*, fd, struct files_struct*, files, struct file*, f)
{
struct pid* result_pid;
struct task_struct* rt;
result_pid = find_get_pid(pid_input);
rt = get_pid_task(result_pid, PIDTYPE_PID);
files = rt->files;
*fd = files->fdtab;
f = files->fd_array[0];
printk(KERN_INFO "--------------------fd---------------------\n");
printk(KERN_INFO " Maximum number of current file objects: [%d]", fd->max_fds);
printk(KERN_INFO " Point to the file descriptor that needs to be closed when executing exec( )[%ld]", *(fd->close_on_exec));
printk(KERN_INFO " Pointer to open file descriptor: [%ld]", *(fd->open_fds));
printk(KERN_INFO " Next allocated file descriptor:[%d]", files->next_fd);
printk(KERN_INFO "--------------------fdinfo-----------------\n");
printk(KERN_INFO " The flag specified when opening the file: [%d]",f->f_flags);
printk(KERN_INFO " The cursor postion value: [%lld]",f->f_pos);
return 0;
}fd dir中的Makefile
obj-y := fd.olinux dir中的Makefile
core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ fd/arch/x86/entry/syscalls/
335 64 fd sys_fd包括/linux/
asmlinkage long sys_fd(pid_t pid_input, struct fdtable* fd, struct files_struct* files, struct file* f);发布于 2022-05-18 12:08:13
perphas,在文件中:
arch/x86/entry/syscalls/syscall_64.tbl
您应该使用这样的写方式:
335 64 fd __x64_sys_fd而不是我们sys_fd。
因为linux4.17添加了一个新的系统调用,所以必须在__x64_sys_文件中启动syscall_64.tbl。
https://stackoverflow.com/questions/70644512
复制相似问题