flat assembler
Message board for the users of flat assembler.
Index
> Linux > mmap |
Author |
|
revolution 04 Dec 2019, 05:50
If I can I avoid looking at C code to decipher things. Instead I go to the docs:
https://linux.die.net/man/2/mmap |
|||
04 Dec 2019, 05:50 |
|
redsock 04 Dec 2019, 20:35
My x86_64 library includes mmap in various places:
https://2ton.com.au/library_as_html/heap.inc.html https://2ton.com.au/library_as_html/mapped.inc.html https://2ton.com.au/library_as_html/privmapped.inc.html |
|||
04 Dec 2019, 20:35 |
|
revolution 05 Dec 2019, 04:18
@moveax41h, note that when calling Linux system functions you place the arguments in registers and then use int 0x80.
There are also other ways to call the system with sysenter and syscall. The exact usage depends upon your CPU (AMD or Intel) and the Linux version (32 or 64 bits). But int 0x80 is the safest and works on all variants. Some will say that using int 0x80 is not performant, and they might be correct. But unless you intend to be calling the system thousands of times per second it probably won't matter much. |
|||
05 Dec 2019, 04:18 |
|
st 08 Dec 2019, 04:05
fasmg itself is using mmap inside malloc since Linux kernel 5.2 changes https://github.com/tgrysztar/fasmg/blob/274b098b9d5af2058b29e70f218f9073ccf8d2c8/core/source/linux/x64/malloc.inc#L143
revolution wrote:
Code: /* * 32-bit legacy system call entry. * * 32-bit x86 Linux system calls traditionally used the INT $0x80 * instruction. INT $0x80 lands here. * * This entry point can be used by 32-bit and 64-bit programs to perform * 32-bit system calls. Instances of INT $0x80 can be found inline in * various programs and libraries. It is also used by the vDSO's * __kernel_vsyscall fallback for hardware that doesn't support a faster * entry method. Restarted 32-bit system calls also fall back to INT * $0x80 regardless of what instruction was originally used to do the * system call. * * This is considered a slow path. It is not used by most libc * implementations on modern hardware except during process startup. * * Arguments: * eax system call number * ebx arg1 * ecx arg2 * edx arg3 * esi arg4 * edi arg5 * ebp arg6 */ ENTRY(entry_INT80_compat) https://github.com/torvalds/linux/blob/v5.3/arch/x86/entry/entry_64_compat.S#L316-L342 |
|||
08 Dec 2019, 04:05 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.