flat assembler
Message board for the users of flat assembler.
Index
> Unix > brk vs sbrk vs mmap on FreeBSD |
Author |
|
jb 01 Apr 2007, 00:12
According to the NetBSD 3.1 man page for mmap, MAP_SHARED or MAP_PRIVATE should be present.
Another thing is, you leave out argument #7. Your r9 is not the `offset' but the `pad' parameter. You should push a zero offset for amd64 I think. Anyhow, in NetBSD 3.1/i386 this test program seems to work: $ cat test.asm format elf executable entry start start: push 0 0 ;64 bit offset push 0xdeadbeef ;pad push -1 ;fd push 0x1002 ;MAP_ANON|MAP_PRIVATE push 7 ;rwx push 2*4096 ;give me two pages push 0 ;I don't care where push eax mov eax,197 int 0x80 jc error xor eax,eax ;exit 0 error: push eax push eax xor eax,eax inc eax int 0x80 include 'note.inc' Just after the system call, running under a debugger, the memory map looks like this: 08048000 4K read/write/exec [ heap ] BDBFD000 8K read/write/exec [ anon ] BDBFF000 4K read/exec [ uvm_aobj ] BDC00000 30720K [ stack ] BFA00000 1984K read/write [ stack ] BFBF0000 64K read/write [ stack ] total 2064K The second line shows the 8K allocated. |
|||
01 Apr 2007, 00:12 |
|
Chewy509 04 Apr 2007, 01:39
Thanks for the late reply, but did eventually sort this issue out...
On FreeBSD 6.1, the direct interface to mmap() syscall will always return invalid file descriptor, but if you use the generic syscall interface, it works fine. (The syscall that lets you call other syscalls through it, I'm at work and don't have the syscall number handy). Reading through the FreeBSD libc, and it's mmap() call, it eventually maps through it the kernel mmap() syscall, with an 8th parameter as well (the mmap() man page only has 7 parameters, which is correct for the libc mmap() call, but not for the kernel mmap() call). But in the end I did get it working (somewhat). |
|||
04 Apr 2007, 01:39 |
|
jb 04 Apr 2007, 18:57
Running ktruss (or strace or whatever it is called on FreeBSD) is often a convenient alternative to reading politically correct man pages.
|
|||
04 Apr 2007, 18:57 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.