For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > October 2007 > How to make system calls having 64-bit arguments using 'int 80h' in 32-bit Linux









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to make system calls having 64-bit arguments using 'int 80h' in 32-bit Linux
Visa Inquirer

2007-10-24, 4:32 am

If I need to make a system call with 6 arguments I can use the code:
" push %esi\n"
" push %edi\n"
" push %ebx\n"
" push %ebp\n"
" movl 16+ 4(%esp),%eax\n" // syscall_num
" movl 16+ 8(%esp),%ebx\n" // arg1
" movl 16+12(%esp),%ecx\n" // arg2
" movl 16+16(%esp),%edx\n" // arg3
" movl 16+20(%esp),%esi\n" // arg4
" movl 16+24(%esp),%edi\n" // arg5
" movl 16+28(%esp),%ebp\n" // arg6
" int $0x80\n"
" popl %ebp\n"
" popl %ebx\n"
" popl %edi\n"
" popl %esi\n"
" ret\n"

But what happens for system calls like 'mmap'?
void * mmap(void *start, size_t length, int prot , int flags, int
fd, off_t offset);
It's last argument is off_t which is 64-bit. Where should the high
part of this offset fit in? There is not enough registers...
Same for ls:
off_t ls(int fildes, off_t offset, int whence);
how will the high part of 'offset' argument be passed?

Is there any documentation about this?

Visa Inquirer

2007-10-25, 4:26 am

> Your question is necessarily OS-specific, yet you didn't give any
> indication of which OS you are using.
>
> The UserAgent gives a clue that you might be interested in something
> other than Linux: "Mozilla/5.0 (X11; U; FreeBSD i386...".


I specified in subject: ".. in 32-bit Linux". This + assembly language
used narrows OS down to x86-lInox.
I use FreeBSD for posting but my question refers to Linux.


Visa Inquirer

2007-10-25, 7:14 pm

> But what happens for system calls like 'mmap'?

Thanks for your replies. Now I see that it's impossible to have 64-bit
args in 32-bit Linux and also it's impossible to have syscalls with
more than 6 arguments.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com