Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Mar 2004 22:10:31 +0000
From:      Daniela <dgw@liwest.at>
To:        ari <edelkind-freebsd-hackers@episec.com>
Cc:        hackers@freebsd.org
Subject:   Re: Strange behaviour in assembly language program
Message-ID:  <200403022210.31451.dgw@liwest.at>
In-Reply-To: <20040302201554.GA50518@episec.com>
References:  <200403022046.22882.dgw@liwest.at> <20040302201554.GA50518@episec.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday 02 March 2004 20:15, ari wrote:
> 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.
>
> .text
> .global _start
> _start:
>         pushl   $8
>         pushl   $0
>         movl    $1, %eax
>         int     $0x80

With this suggestion, it always returns 0 instead of 1.
Shouldn't pushl place 4 bytes on the stack? It translates into the instruction 
0x6A (pushes only one byte).
BTW, when I assemble it with as(1), there is always an extra instruction after 
my code, and it's a different one each time (and it's always one that 
effectively does nothing). Who ordered that? Is it because of alignment 
constraints in the ELF file?




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403022210.31451.dgw>