Error in adding system call in OpenBSD 6.3


#1

Hello guys,

I am facing some issue during adding system call on OpenBSD 6.3. I
have shown my pathways to add system call, please guys correct me if
somewhere I have forgotten something to add or build.

  1. echo “331 { int sys_hello(void); }” >> /usr/src/sys/kern/syscalls.master

  2. make init_sysent.c

  3. Add this file in /usr/src/sys/kern/sys_hello.c

    #include <sys/types.h>
    #include <sys/param.h>
    #include <sys/kernel.h>
    #include <sys/syscallargs.h>

    int
    sys_hello(struct proc *p, void *v, register_t *retval)
    {
    printf(“Hello world from kernel space.\n”);
    return (0);
    }

  4. echo “file kern/sys_hello.c” >> /usr/src/sys/conf/files

  5. cd /usr/src/sys/arch/amd64/compile/CUSTOM.MP/

  6. make obj && make -j4

And, then, It throws an error given below,

ld -T ld.script -X --warn-common -nopie -o bsd ${SYSTEM_HEAD} vers.o ${OBJS}

init_sysent.o:(.data+0x14b8): undefined reference to `sys_hello’

*** Error 1 in /usr/src/sys/arch/amd64/compile/CUSTOM.MP (Makefile:918
’bsd’: @echo ld -T ld.script -X --warn-common -nopie -o bsd
’${SYSTEM…)

I have even tried to “make” with “-n” and "-d"options, so, that I can
debug make process, but, it didn’t help me.

I have also tried to manually include sys.hello.o in {OBJS} in file
"/usr/src/sys/arch/amd64/compile/CUSTOM.MP/obj/Makefile" and also in
{CFILES} etc. like all other system calls files included. For example,
sys_generic.c etc.

But, some days ago, I did the same with OpenBSD 6.2 or 6.3 (I forgot)
in VirtualBox and it was working at that time.
The system call was added successfully at that time.

Alternative approach:

But, instead of adding a file for code of system call, I write “int sys_hello()” function inside sys_generic.c, like, sys_write() or sys_read() then there is no problem, I mean everything is compiled successfully and after booting into new kernel. I have used my implemented new system call.

Here, you guys can find link for my question in tech@openbsd.org

OpenBSD Tech Mailing List


#2

Hi,

I think @jggimi can answer that.