The goal of this post is to document some problems that I had building the Android image and its respective kernel. You might think that I am being redundant, as you [might] have the same issues with a traditional Linux kernel. I've done this only for Android platform, so I don't know for other kernels. I'm also having some other problems, such as ARMv8-64 asm file compilation inside the kernel, but this will be described in another poster.
Basically, in my project, I have to create new syscalls and also change the sys_call_table to intercept existing ones, such as NR_write, NR_open, etc. You can check another post that describes how to create new syscalls and how to intercept existing syscalls. So, what is different?
1. Some syscalls have changed, some have been created and some others are not supported anymore.
For example, check the syscalls under the #def body __ARCH_WANT_SYSCALL_DEPRECATED and __ARCH_WANT_SYSCALL_NO_AT (file include/uapi/asm-generic/unistd.h)
In addition, the syscall number has also been changed. For example, NR_write changed from 3 to 63. Remember to change your code in userpsace that has any reference to one of these numbers.
2. Much easier than before: now, you only need to change less files. Add the definition of your syscalls in the following files:
asmlinkage long sys_seccomp(unsigned int op, unsigned int flags,
const char __user *uargs);
asmlinkage long sys_my_syscall(void __user *buf);
#define __NR_seccomp 277
#define __NR_my_syscall 278
#define __NR_syscalls 279
kernel/my_syscall_code.c (this file should contain the implementation of your syscall)
obj-y = ....
async.o range.o groups.o lglock.o smpboot.o \
3. Don't forget to add asm/unistd.h as part of your head files.
4. Kernel modules are implemented the same way as before. To build it, remember to set cflags properly
There's just a small change on building the module. Call make with CFLAGS_MODULE=-fno-pic
5. And of course, the syscall table address table has changed as well.
Check the symbol sys_call_table in the file System.map.
EDIT (31/07/2015) : this is a good guide for 32 bits -> 64 bits porting