Skip to contentSkip to conversation

x86_64 system call entry points

DISCUSSION Chuck Ebbert 1 participant 1 message Jun 6, 2006

lore
Share & tools
lore
#0 lore raw

In-Reply-To: <[email protected]>

Quoted 15 lines · Martin Bisson

- sysenter/32 bits, executed on a 32 bit machine: I get a segfault on the sysenter instruction. I use the following code to enter the system call:
pid_t getpid32()

{
    pid_t resultvar;

    asm volatile (
    "push    %%ebp\n\t"
    "push    %%ecx\n\t"
    "push    %%edx\n\t"
    "mov     %%esp,%%ebp\n\t"
    "sysenter\n\t"
    ".space 20,0x90\n\t"
    "pop     %%edx\n\t"
Quoted 8 lines
    "pop     %%ecx\n\t"
    "pop     %%ebp\n\t"
    : "=a" (resultvar)   
    : "0" (__NR_getpid)
    : "memory");

    return resultvar;
}

sysenter always returns to a fixed address (in the vdso) no matter where you invoke it from.

Signature · 1 line
Chuck