Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Mar 2001 17:23:13 +0200 (EET)
From:      diman <diman@asd-g.com>
To:        "Nickolay A. Kritsky" <nkritsky@internethelp.ru>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: FreeBSD asm problem
Message-ID:  <Pine.BSF.4.21.0103131720510.430-100000@portal.none.ua>
In-Reply-To: <00b701c0abca$624b7630$0600a8c0@ibmka.internethelp.ru>

next in thread | previous in thread | raw e-mail | index | archive | help

--------ex.S------------
#include <sys/syscall.h>
.globl	main
main:	popl	%eax			/* cick ret */
	popl	%eax			/* cick argc */
	movl	(%esp),%eax		/* eax=av */
	movl	$fname, %ebx		/* ebx=fname */
	movl	%ebx,(%eax)		/* av[0]=fname */
	pushl	%ebx			/* needs to be on the stack too */
	movl	$SYS_execve,%eax	/* execve */
	call	syscall
	movl	$SYS_exit,%eax		/* exit */
	call	syscall
syscall:
	int	$0x80
	ret
fname:	.asciz	"/bin/sh"


On Tue, 13 Mar 2001, Nickolay A. Kritsky wrote:

> Hi all!
> It seems to me that you guys are my last hope, but if  i am asking in the
> wrong place - sorry.
> 
> I wrote my first asm program for FreeBSD:
> 
> section    .code
> global _start
> _start:
>     push dword envp
>     push dword argvp
>     push dword fname
>     mov eax,59  ; execve
>     int 80h
>     hlt   ; i should never get here
> 
> section .data
> fname db '/bin/sh',0
> envp dd 0
> argvp dd 0
> ;End of program
> 
> after compiling and linking i run it and got SIGBUS error
> when run under gdb i can see that int 80h returns with eax=2 (ENOENT? does
> it mean file not found?)
> 
> I have a feeling that i have missed something very important.
> 
> Thank you.
> NKritsky - SysAdmin InternetHelp.Ru
> http://www.internethelp.ru
> e-mail: nkritsky@internethelp.ru
> 
> 
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-hackers" in the body of the message
> 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0103131720510.430-100000>