Change in compiling methods for linux system calls

Source: Internet
Author: User

In the 2.6 era, the steps for writing a linux system call are as follows:

  1. Compile the actual operation function
  2. Add macro definitions in linux/include/asm-i386/unistd. h
    #define __NR_myfunctioin 399

  3. In linux/arch/i386/kernel/entry. S, add
    .long SYMBOL_NAME(myfunction)

  4. Compile the kernel
  5. Use _ syscall [1-6] (type, name, type, arg1) to call
The corresponding macro definition file cannot be found at the corresponding location of the kernel in the latest version.

Unistd. modify the H file to reference the 32-bit and 64-bit versions respectively, and placed in/arch/x86/include/uapi/asm/unistd _ [32 | 64 | x32]. h. arm is stored in/arch/arm/uapi/asm/unistd. h, the other architectures are similar.

In addition, some files are modified to the _ SYSCALL (n, call) method definition.

The sys_call_table definition in the entry. S file is also placed in the syscall. h file, and the original assembly is modified to the definition method of the C array.

_ SYSCALL is a macro.

#define __SYSCALL(n, call) [nr] = (call),#define __SYSCALL_XX(n, sym, compat)

In addition, the sys_call_table [nr_syscils] array is added.

void *sys_call_table[NR_syscalls] = {    [0 ... NR_syscalls-1] =  sys_ni_syscall,#include <asm/unistd.h>}

Currently, there are two ways in the kernel to define system calls: macro-defined numbers and _ SYSCALL.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.