DragonFly kernel List (threaded) for 2005-09
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Re: Different versions of system calls in assembly language
:
:
:I'm continuing my foray into assembly language programming, and today I ran
:into a problem calling mmap. The problem came from the fact that the version
:I was apparently calling (libc?) was expecting an additional 'pad' argument.
:
:Since the man page does not mention this (I found it in syscalls.master) where
:should I have found the information when setting up this call? Better yet,
:how could I access the original mmap with one less argument, other than a
:direct int80?
:
:jcm
:--
For historical reasons (meaning that the original authors of the
syscall code did something really stupid), 64 bit system call
arguments such as the off_t parameter in lseek and mmap are 64
bit aligned, rather then simply use the C ABI. Because GCC does not
64-bit align 64 bit arguments, we can't just have the system call
function issue an int 0x80 but instead must reorganize the arguments
to add the additional alignment.
See:
/usr/src/lib/libc/sys/mmap.c
/usr/src/lib/libc/sys/lseek.c
It's really stupid because the stack itself is not 64-bit aligned,
so the layout on the stack winds up not being aligned anyway. But
the PAD is still required because the kernel expects it.
Generally speaking, you should not be calling int 0x80 directly
but should instead call into libc, but I understand you are trying
to create some level of code obscurity in your current project.
-Matt
Matthew Dillon
<dillon@xxxxxxxxxxxxx>
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]