From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 2 13:16:31 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6B8BF16A4CE for ; Tue, 2 Mar 2004 13:16:31 -0800 (PST) Received: from lilzmailso01.liwest.at (lilzmailso01.liwest.at [212.33.55.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2290D43D2D for ; Tue, 2 Mar 2004 13:16:31 -0800 (PST) (envelope-from dgw@liwest.at) Received: from cm58-27.liwest.at ([212.33.58.27]) by lilzmailso01.liwest.at with esmtp (Exim 4.24) id 1AyHFd-0003gI-Hh; Tue, 02 Mar 2004 22:16:29 +0100 From: Daniela To: ari Date: Tue, 2 Mar 2004 22:10:31 +0000 User-Agent: KMail/1.5.3 References: <200403022046.22882.dgw@liwest.at> <20040302201554.GA50518@episec.com> In-Reply-To: <20040302201554.GA50518@episec.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200403022210.31451.dgw@liwest.at> cc: hackers@freebsd.org Subject: Re: Strange behaviour in assembly language program X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Mar 2004 21:16:31 -0000 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?