Seventh argument seen in mmap on i386

karnajit wangkhem karnajitw at gmail.com
Tue May 23 13:55:09 UTC 2017


Hi All,



I am trying to understand this scenario where a seventh argument is seen in
case of freebsd.x-i386. As per the mmap man page, the libc function
prototype takes in 6 arguments.


Ktrace shows the following

// Freebsd-11.0 – i386 box

44416 a.out    CALL
mmap(0,0x1000,0x7<PROT_READ|PROT_WRITE|PROT_EXEC>,0x1002<MAP_PRIVATE|MAP_ANON>,0xffffffff,0,0)

44416 a.out    RET   mmap 671535104/0x2806d000



// Freebsd-11.0 – amd64 box

366 a.out    CALL
mmap(0,0x1000,0x7<PROT_READ|PROT_WRITE|PROT_EXEC>,0x1002<MAP_PRIVATE|MAP_ANON>,0xffffffff,0)

366 a.out    RET   mmap 34366287872/0x80063f000



Also, the disassemble code show that an extra argument was pushed in i386
case

<SNIP>

->  0x80485e6 <+38>:  movl   %esp, %ebx

    0x80485e8 <+40>:  movl   $0x0, 0x18(%ebx)

    0x80485ef <+47>:  movl   $0x0, 0x14(%ebx)

    0x80485f6 <+54>:  movl   $0xffffffff, 0x10(%ebx)   ; imm = 0xFFFFFFFF

    0x80485fd <+61>:  movl   $0x1002, 0xc(%ebx)        ; imm = 0x1002

    0x8048604 <+68>:  movl   $0x7, 0x8(%ebx)

    0x804860b <+75>:  movl   $0x1000, 0x4(%ebx)        ; imm = 0x1000

    0x8048612 <+82>:  movl   $0x0, (%ebx)

<SNIP>



Please help me understand why this extra argument is seen in case of i386.


Regards,

Karan


More information about the freebsd-hackers mailing list