I just noticed that the __syscall call is dropping the 6th argument
(providing garbage) when I use it on amd64.  The attached program
makes an mmap call "normally" and with __syscall.  Running the
program in ktrace reveals that the last argument is garbage when
using the __syscall entry, and not when using the "normal" entry.
Is this known/expected behavior or a bug?

---
$ ktrace ./a.out
p 0x100000
p 0x100528

---
$ kdump
  2631 a.out    CALL
 mmap(0,0x10000,0x3<PROT_READ|PROT_WRITE>,0x1002<MAP_PRIVATE|MAP_ANON>,-1,0)
  2631 a.out    RET   mmap 27609139748864/0x191c40f7a000

  2631 a.out    CALL
 
mmap(0x100000,0x4000,0x7<PROT_READ|PROT_WRITE|PROT_EXEC>,0x1000<MAP_ANON>,-1,0x7f7ffffc5bd8)
  2631 a.out    RET   mmap 1051608/0x100bd8

----
#include <stdio.h>
#include <sys/mman.h>

int
main(int argc, char **argv)
{
    void *p;
    unsigned long long p2;

    p = mmap((void*)0x100000, 4*4096, 7, MAP_ANON, -1, 0);
    printf("p %p\n", p);
    munmap(p, 4*4096);

    p2 = __syscall(197, 0x100000, 4*4096, 7, MAP_ANON, -1, 0);
    printf("p 0x%llx\n", p2);
    return 0;
}


-- 
Tim Newsham | www.thenewsh.com/~newsham | @newshtwit | thenewsh.blogspot.com

Reply via email to