`vsyscall` is obsolete, and is replaced by `linux-gate.so.1`, which is a virtual library mapped to the memory of each process. `linux-gate.so.1` abstracts the difference between architectures, so you do not have to invoke `int 80h` or `syscall` or `sysenter` or `epc`, instead, just the entry point provided by `linux-gate.so.1`.
Note `vsyscall` has been reported to be much slower than `linux-gate.so.1`, and some ones suspects this is on purpose. It also has been reported that `vsyscall` will issue a warning at runtime with future Linux kernel versions.
Look there for some talks on the topic:
Issue 1933: runtime: stop using vsyscall page on Linux. Jun 8, 2011
`linux-gate.so.1` is a vDSO, which you access via a reference provided in AUXV, which is a vector of parameters located in the stack, at an address above the argv and envp vectors provided to all Linux processes. Note its address (the one of `linux-gate.so.1`) is randomized for security reason, and will be different for each Linux process image: there will be no more magic static address to call in the future.
If you want to learn more on Linux vDSO, `linux-gate.so.1` and AUXV, here are some reference:
If you wish to play with some assembly, here is a sample assembly which print a short text on the standard output, not using `int 80h` nor `sysenter`, but `linux-gate.so.1` only, whose address it retrieve from AUXV passed in the stack at process initialization.
The original which I grabbed on the web, was for FASM, I changed it to NASM, I also changed some tiny things, but kept the original author's name :-p :
Code: Select all
; Luke McCarthy 2008-06-02
; Find linux-gate VDSO
; http://shaurz.wordpress.com/2008/06/02/finding-linux-gateso1-in-assembly/
; format ELF executable
; entry _start
SYS_EXIT equ 1
SYS_WRITE equ 4
STDOUT equ 1
AT_SYSINFO equ 32
; segment readable executable
global _start
_start:
mov ecx, [esp] ; ecx = argc
lea esi, [8+esp+ecx*4] ; esi = envp
.find_auxv:
mov eax, [esi]
lea esi, [esi+4]
test eax, eax
jnz .find_auxv
; esi = auxv
.find_sysinfo:
mov eax, [esi]
cmp eax, AT_SYSINFO
je .found_sysinfo
lea esi, [esi+8]
test eax, eax
jnz .find_sysinfo
jmp .not_found_sysinfo
.found_sysinfo:
mov ebp, [esi+4] ; ebp = sysinfo
mov eax, SYS_WRITE
mov ebx, STDOUT
mov ecx, msg_succ
mov edx, msg_succ_size
call ebp ; syscall
mov eax, SYS_EXIT
xor ebx, ebx
jmp ebp ; syscall
.not_found_sysinfo:
mov eax, SYS_WRITE
mov ebx, STDOUT
mov ecx, msg_fail
mov edx, msg_fail_size
int 0x80
mov eax, SYS_EXIT
mov ebx, 1
int 0x80
; segment readable
msg_succ db "linux gate found :-)", 10
msg_succ_size equ $ - msg_succ
msg_fail db "linux gate not found :-(", 10
msg_fail_size equ $ - msg_fail