Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Mar 2004 15:18:18 -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:  <20040311201818.GA75293@episec.com>
In-Reply-To: <200403032012.28601.dgw@liwest.at>
References:  <200403022046.22882.dgw@liwest.at> <200403022210.31451.dgw@liwest.at> <20040303162632.GC50518@episec.com> <200403032012.28601.dgw@liwest.at>

next in thread | previous in thread | raw e-mail | index | archive | help
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:

	<arch>/<arch>/machdep.c

The function in question is "exec_setregs" on freebsd 5.x, or "setregs"
on freebsd 4.x.

ari



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