简体   繁体   中英

Syscall implementation in glibc

I'm currently trying to get a syscall on my Linux X64 done via inline assembler in C. As none of my approaches worked, I wanted to figure out, how this is done in glibc. What I found was the following in /misc/syscall.c

long int
syscall (callno)
     long int callno;
{
  __set_errno (ENOSYS);
  return -1;
}

I have to say I'm new to C (I'm a Java developer) so I don't understand the syntax here.

My questions are the following:

  1. Is it correct that I can write the declaration of function parameters after the list of parameters in the brackets like this:

    void foo(bar) long int bar; { //function code }

  2. How can I find the actual implementation in assembler of syscalls in glibc? (Doesn't need to be the correct position, any hint is appreciated)

Syscalls are not solely defined in the source by glibc. Glibc creates the syntax for syscalls on the fly via this shell script: /sysdeps/unix/make-syscalls.sh . The script uses the syscalls.list files appropiate for the relevant operating system. In addition there are some files regarding the architecture to determine the correct opcode for trapping to the kernel. Eg X86_64 defines "syscall" as the opcode to jump to the kernel (See the sysdep.h for X86_64 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM