From owner-freebsd-hackers@FreeBSD.ORG Thu Mar 11 12:18:45 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 F201416A4CE for ; Thu, 11 Mar 2004 12:18:44 -0800 (PST) Received: from episec.com (episec.com [69.55.237.141]) by mx1.FreeBSD.org (Postfix) with SMTP id B915243D2D for ; Thu, 11 Mar 2004 12:18:44 -0800 (PST) (envelope-from edelkind-freebsd-hackers@episec.com) Received: (qmail 78510 invoked by uid 1024); 11 Mar 2004 20:18:18 -0000 Date: Thu, 11 Mar 2004 15:18:18 -0500 From: ari To: Daniela Message-ID: <20040311201818.GA75293@episec.com> Mail-Followup-To: ari , Daniela , hackers@freebsd.org References: <200403022046.22882.dgw@liwest.at> <200403022210.31451.dgw@liwest.at> <20040303162632.GC50518@episec.com> <200403032012.28601.dgw@liwest.at> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200403032012.28601.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: Thu, 11 Mar 2004 20:18:45 -0000 dgw@liwest.at said this stuff: > This code works to return 0x57: 31 c0 40 6a 57 50 cd 80 > But that needs 8 bytes! Can't it be shortened? > I noticed that some registers contain zero on program startup. Can I safely > assume they are always initialized to zero and just leave that 31 c0 out? Freebsd explicitly zeros its registers before executing a program (it then sets specific registers, such as the program counter, flags, and stack pointer). This behavior takes place in an architecture-dependent function, however, so one cannot take for granted that such a thing will occur, nor can one necessarily presume that all generic registers will be zero (indeed, on i386, ebx is set to ps_strings, which may be nonzero when executing bsdi binaries). Still, this is the case as of freebsd 4.5 (alpha, i386) and 5.1 (alpha, amd64, i386, sparc64). Those are the versions and architectures that i briefly checked. This information is in the files with pattern: //machdep.c The function in question is "exec_setregs" on freebsd 5.x, or "setregs" on freebsd 4.x. ari