Antonio Rizzo
Antonio Rizzo

Reputation: 788

In Linux x86_64 are syscalls and int 0x80 related?

I know that in Linux x64 "syscall" and "int 0x80" assembler instructions generate an interrupt in software asking the kernel to do some work. They have different opcodes (0F 05 vs CD 80) and the former is faster.
It's not clear to me if there is any relationship between them: are they really independent? (i.e.: does "syscall" call "int 0x80"?) Thank you.

Upvotes: 7

Views: 3923

Answers (3)

zwol
zwol

Reputation: 140826

The syscall (x86-64) and sysenter (x86-32) instructions are newer and faster, and so are used when available; but the int 0x80 mechanism is preserved for compatibility with old binaries. There is no semantic difference -- system call numbering is the same regardless of which instruction is used to transfer control into the kernel, and I think the arguments are all in the same places as well.

I have a dim recollection of there being a small number of system calls that could only be made using int 0x80 because of their unusual stack-related behavior (clone? execve? sigreturn?) but that might no longer be true.

Upvotes: 6

David C. Rankin
David C. Rankin

Reputation: 84642

int 0x80 is the 32-bit interrupt used with 8086 - 80386 assembly. x86_64 uses syscall in its place. See the differences in /usr/include/asm/unistd_32.h and unistd_64.h for the different call numbers each expect to invoke the various kernel functions.

Upvotes: 1

int 0x80 is rumored to be obsolete (since slow). BTW, you really want to use vdso(7)

AFAIK, both instructions are going inside the kernel, and each has some (short) sequence of kernel processing which ultimately jump into the syscall table.

Upvotes: 1

Related Questions