Author Topic: mmap linux syscall  (Read 8427 times)

Offline cheery

  • Jr. Member
  • *
  • Posts: 2
mmap linux syscall
« 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?

Offline Keith Kanios

  • Full Member
  • **
  • Posts: 383
  • Country: us
    • Personal Homepage
Re: mmap linux syscall
« Reply #1 on: September 19, 2010, 12:03:05 AM »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2373
  • Country: us
Re: mmap linux syscall
« Reply #2 on: September 19, 2010, 12:09:29 AM »
Yeah, or just "man 2 mmap2".... Looks to be pretty near the same thing...

Best,
Frank


Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2373
  • Country: us
Re: mmap linux syscall
« Reply #3 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


Offline cheery

  • Jr. Member
  • *
  • Posts: 2
Re: mmap linux syscall
« Reply #4 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. :)