Date: Tue, 2 Mar 2004 15:15:54 -0500 From: ari <edelkind-freebsd-hackers@episec.com> To: Daniela <dgw@liwest.at> Cc: hackers@freebsd.org Subject: Re: Strange behaviour in assembly language program Message-ID: <20040302201554.GA50518@episec.com> In-Reply-To: <200403022046.22882.dgw@liwest.at> References: <200403022046.22882.dgw@liwest.at>
next in thread | previous in thread | raw e-mail | index | archive | help
dgw@liwest.at said this stuff:
> Finally I came up with the simplest ASM program that reproduces the error.
> Here it is:
>
> .text
> .global _start
> _start:
> pushl $0
> movl $1, %eax
> int $0x80
>
> I looked everywhere (Developer's handbook, Google, ...) to find the solution,
> but all resources I consulted tell me this is the right way to do it.
> This program, however, always exits with 1 regardless of the value I push.
The kernel expects the interrupt to take place from within a function.
Try:
.text
.global _start
_start:
pushl $8
movl $1, %eax
call doint
doint: int $0x80
Or, if you really want the program as simple as possible, you can push
0, eax, garbage, anything onto the stack in place of the return address:
.text
.global _start
_start:
pushl $8
pushl $0
movl $1, %eax
int $0x80
ari
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040302201554.GA50518>
