Different versions of system calls in assembly language
dillon at apollo.backplane.com
Thu Sep 29 08:51:22 PDT 2005
: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
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.
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.
<dillon at xxxxxxxxxxxxx>
More information about the Kernel