Reputation: 1838
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.
[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?
[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?
[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
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 struct
s. On amd64, GNU/Linux supports three ABIs natively:
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:
[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.[abi]
: "common" system calls can be used for both amd64 ABIs, but some, like those with pointers to struct
s, need special handling to account for ABI differences.[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