flat assembler
Message board for the users of flat assembler.

flat assembler > Linux > linux 2.6+ system calls reference

Goto page Previous  1, 2, 3, 4
Author
Thread Post new topic Reply to topic
d.j.peters



Joined: 11 Aug 2004
Posts: 7
Location: Germany
first sorry about my bad english.

i have a nobe question
what heppent if a 32 bit x86 binary with syscall execute on a 64 bit CPU with a 64 bit Linux distro ?

is it a unsupported instruction or exists a 32 bit syscall emulation on a 64 bit kernal ?

I can't test it, i have only one P4 and one 32 bit AMD Athlon linux box.

by the way
exist any 64 bit "software" CPU emulator for a 32 bit CPU ?
(like QEMU, Virtual Box, VM Ware, ...)

Thank you for any infos.

DJ

_________________
(sorry about my bad English)


Last edited by d.j.peters on 10 Aug 2010, 10:13; edited 1 time in total
Post 08 Aug 2010, 10:03
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4634
Location: Argentina
d.j.peters, Yes, I've tried it several times with Ubuntu for AMD64, using INT $80 from a 32-bit executable works correctly (and I think that also SYSENTER and maybe SYSCALL). In 64-bit, you should use SYSCALL instead (which is guaranteed to be available in both Intel and AMD). I think that INT $80 is also available in 64-bit, but I'm not sure (and it is slower anyway). Check the examples in the fasm for Linux package.
Post 08 Aug 2010, 18:14
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3475
Location: Bulgaria
Int 80h is supported in 64 bit Linux, so, all 32 bit ELF executables will work. The only possible problems is if the executable dynamically links to some 32 bit libraries. They are not installed by default, so the application will end with error.
Post 02 Feb 2013, 14:14
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
keantoken



Joined: 19 Mar 2008
Posts: 69
Okay, let's look at the documentation for sys_clone. man clone:

Code:
On success, the thread ID of the child process is returned in the call
       er's thread of execution.  On failure, -1 is returned in  the  caller's
       context, no child process will be created, and errno will be set appro
       priately.    


And now the reference in the first post:

Code:
If the system call succeeds the return value is 0.
If the system call fails the return value is one of the following errno values:     


This is a direct contradiction. Also, doesn't anyone want to know what the return value is for the CHILD? Huh? How do you tell the child apart from the caller then!? It doesn't appear to be the same way it's done with sys_fork.
Post 27 Mar 2013, 01:58
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3475
Location: Bulgaria
keantoken wrote:
Okay, let's look at the documentation for sys_clone. man clone:

Code:
On success, the thread ID of the child process is returned in the call
       er's thread of execution.  On failure, -1 is returned in  the  caller's
       context, no child process will be created, and errno will be set appro
       priately.    



It seems to be the C/C++ wrapper description. There is no "errno" variable actually. The system calls return negative error codes instead.

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 27 Mar 2013, 06:15
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
randall



Joined: 03 Dec 2011
Posts: 153
Location: Poland
keantoken wrote:
Okay, let's look at the documentation for sys_clone. man clone:

Code:
On success, the thread ID of the child process is returned in the call
       er's thread of execution.  On failure, -1 is returned in  the  caller's
       context, no child process will be created, and errno will be set appro
       priately.    


And now the reference in the first post:

Code:
If the system call succeeds the return value is 0.
If the system call fails the return value is one of the following errno values:     


This is a direct contradiction. Also, doesn't anyone want to know what the return value is for the CHILD? Huh? How do you tell the child apart from the caller then!? It doesn't appear to be the same way it's done with sys_fork.


sys_clone returns thread id (value grater than zero) in the parent thread and zero in the child thread.

For example:

Code:
        sys_clone
        test eax,eax
        jnz .L0
        ; child
        pop rsi rdi
        call rsi
        sys_exit 0
.L0:  ; parent
    
Post 27 Mar 2013, 15:11
View user's profile Send private message Visit poster's website Reply with quote
keantoken



Joined: 19 Mar 2008
Posts: 69
Thanks!

You'd think that crucial detail would be included in the linux manpages..?

I did figure out the errno thing eventually.
Post 28 Mar 2013, 00:57
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 7504
Location: ˛                              ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣ Posts: 6699
arafel wrote:
Hi,

I want to introduce a small project which came to life a couple of month ago.
You may get it from here (grab the latest release): http://sourceforge.net/project/showfiles.php?group_id=173983

It's a reference for Linux 2.6+ system calls. Which provides a description of (almost)all system calls found in kernel 2.6 and later branches from Assembly point of view Smile
Also it includes a set of include files for FASM and GAS with structures and symbol definitions necessary for programming with syscalls.
And also there is a number (currently only two..) of examples provided which demonstrate some syscalls usage.

The project is currently in an alpha stage. A lot of things has not been verified yet, so please take this into account Wink .

Hope someone will find it useful.


great and thanks!
Post 26 Jun 2013, 21:45
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3475
Location: Bulgaria
The lscr help pages about Linux system calls are now accessible online on: http://fresh.flatassembler.net/lscr/
Post 23 Feb 2014, 15:44
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.