NASM - The Netwide Assembler

NASM Forum => Other Discussion => Topic started by: cheery on September 18, 2010, 10:18:16 PM

Title: mmap linux syscall
Post by: cheery on September 18, 2010, 10:18:16 PM
I wonder how can I call mmap system call. I found only the old_mmap from system call tables.

Where's the sys_mmap2?
Title: Re: mmap linux syscall
Post by: Keith Kanios on September 19, 2010, 12:03:05 AM
http://www.lxhp.in-berlin.de/lhpsysc4.html#mmap2 (http://www.lxhp.in-berlin.de/lhpsysc4.html#mmap2)
Title: Re: mmap linux syscall
Post by: Frank Kotler on September 19, 2010, 12:09:29 AM
Yeah, or just "man 2 mmap2".... Looks to be pretty near the same thing...

Best,
Frank

Title: Re: mmap linux syscall
Post by: Frank Kotler on September 19, 2010, 07:04:55 AM
Looks to be pretty near the same thing...

Mmmm... that's only semi-true... It is fairly typical that "old" sys_calls which take six parameters put 'em in a structure, with the address of the structure in ebx. The "new" versions use ebp, and put all parameters in registers. That's the case here - besides the fact that the last parameter, "offset", is in bytes for mmap, and "pgoffset", in pages for mmap2. (I mostly want zero, in either case...)

Best,
Frank

Title: Re: mmap linux syscall
Post by: cheery on September 19, 2010, 10:31:07 PM
Yuck. Usage of ebp as a sixth register seems a bit nasty to me.

x86_64 doesn't seem to have mmap2 which is quite weird too. Maybe I'll end up using the 'old' mmap. It's not getting away anytime soon I guess. :)