RE: System Call parameters

Perez-Gonzalez, Inaky (inaky.perez-gonzalez@intel.com)
Wed, 16 Apr 2003 17:39:36 -0700


> From: Richard B. Johnson [mailto:root@chaos.analogic.com]
>
> Some functions like mmap() take 6 parameters!
> Does anybody know how these parameters get passed?
> I have an "ultra-light" 'C' runtime library I have
> been working on and, so-far, I've got everything up
> to mmap() (in syscall.h) (89 functions) working.
> I thought, maybe ebp was being used, but it doesn't
> seem to be the case.

I use %ebp, it seemed to work last time I played with it:

static inline
int st_mmap (void *addr, size_t len, int protection, int flags, int fd,
off_t offset)
{
int result;
asm volatile (
"pushl %%ebp \n"
"movl %6, %%ebp \n"
"movl %7, %%eax \n"
"int $0x80 \n"
"popl %%ebp \n"
: "=a" (result)
: "b" (addr), "c" (len), "d" (protection),
"S" (flags), "D" (fd), "m" ((offset >> PAGE_SHIFT)),
"i" (__NR_mmap2)
: "memory");
return result;
}

I thing I got it from an straight disassemble dump of glibc's
mmap().

Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own
(and my fault)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/