How are void* pointers returned in C?

assembly, c, gcc, return

Solution

This is not a valid way to write inline asm. Even if you put the return value in the right register, it could be lost/clobbered by the time the function actually returns, because the compiler can add arbitrary epilogue code. You must use output constraints and a `return` statement to return the results of inline asm:

void* kmalloc(unsigned int size)
{
    void *p;
    asm("int $0x80" : "=a"(p) : "S"(size), "a"(9));
    return p;
}

Problem

Basically I need to know what register void* pointers are placed in when they are returned from a C function. I have this code: ``` void* kmalloc(unsigned int size) { asm("mov %[size], %%esi" : /* no outputs */ : [size] "m" (size) : "esi"); asm("movl $9, %eax"); asm("int $0x80"); } ``` which should put an address into EAX. I thought that return values in C were stored in EAX, but apparently not, (oh and I am using GCC BTW). I need to some how return EAX, register int won't work either because of the compiler settings. Is there a register that is used for returning pointers? Or is it like pushed onto the stack or something?

Original source