Rom
Rom

Reputation: 1838

Parameters of files syscall_32.tbl, syscall_64.tbl in build linux kernel

I'm praticing to build a new linux kernel on virtual machine. I have some question about 2 files syscall_32.tbl and syscall_64.tbl in step import parameters of a module in them.

I'm know that file syscall_32.tbl have 5 parameters [number] [abi] [name], [entry point], [compat entry point], and file syscall_64.tbl have 4 without [compat entry point].

I have some questions that I can't find answer for them.

  1. [number]: what is range value of this column. I find out that the numbers are union and increasing sequence. If now I import new with large number (such as 10^6), is it OK?

  2. [abi]: I know that in file syscall_64.tbl, the value of column maybe common, 64, x32. What is meaning of each value? Why is different between them? And why machine 64-bit have value x32 in this column?

  3. [name]: I know that [entry point] and [compat entry point] is used for function to run the syscall. And when user call system call, we don't need call the name, we only use the [number] and kernel space use [entry point] to run. What is a reason for this column ([name])?

Thanks for your view and answer. Sorry for my bad english.

Upvotes: 2

Views: 1540

Answers (1)

a3f
a3f

Reputation: 8657

For different binaries to interact, they need to agree on a set of interfaces, e.g. the size of types and layout (padding) of structs. On amd64, GNU/Linux supports three ABIs natively:

  • i386: For compatibility with x86 32-bit binaries. System calls are defined in syscall_32.tbl
  • x86_64: Native 64-bit binaries. System calls are defined syscall_64.tbl with abi=64
  • x32: ILP32 (32-bit int, long and pointers), but with amd64 goodies: e.g. registers are 64-bit and there is more of them than in i386. System calls are defined syscall_64.tbl with abi=x32

A binary's ABI is configured at compilation time (-m32, -m64 and -mx32 respectively for GCC), but the kernel runs in long mode in all three cases and sometimes conversions are necessary to account for ABI differences.

Regarding your questions:

  1. [number]: Size depends on the system call convention. e.g. with int 80h, the system call number is passed through the 32-bit wide eax.
  2. [abi]: "common" system calls can be used for both amd64 ABIs, but some, like those with pointers to structs, need special handling to account for ABI differences.
  3. [name]: Linux provides headers with system call number definitions, e.g. #define __NR_exit 1. The macro name is generated from the [name] column. See this answer for more information.

Upvotes: 3

Related Questions