From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:37777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QJ4Jw-00062E-SU for qemu-devel@nongnu.org; Sun, 08 May 2011 09:46:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QJ4Jv-0000J3-Tf for qemu-devel@nongnu.org; Sun, 08 May 2011 09:46:52 -0400 Received: from mail-qy0-f173.google.com ([209.85.216.173]:54906) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QJ4Jv-0000Iv-Rb for qemu-devel@nongnu.org; Sun, 08 May 2011 09:46:51 -0400 Received: by qyk36 with SMTP id 36so523620qyk.4 for ; Sun, 08 May 2011 06:46:51 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <413381.49201.qm@web38404.mail.mud.yahoo.com> References: <19735.38079.qm@web38403.mail.mud.yahoo.com> <413381.49201.qm@web38404.mail.mud.yahoo.com> From: Blue Swirl Date: Sun, 8 May 2011 16:46:31 +0300 Message-ID: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] Binary translation (of code) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Tarmo Pikaro Cc: qemu-devel@nongnu.org On Sun, May 8, 2011 at 4:05 PM, Tarmo Pikaro wrote: > >> In general, this is not possible. Consider for example self-modifying >> or otherwise dynamically created code, or just code that examines >> itself. > >> In some specific trivial cases it could work, and QEMU could be made >> to abort if translation would be needed. > > I think self-modifying=C2=A0code is kinda rare case - it's made typically= for > protection againt=C2=A0hackers , and=C2=A0typically on pc side. Nintendo= =C2=A0roms probably > don't use this kind of > protection. It doesn't have to be protection, for example GCC generates trampolines to stack when using nested functions. > Anyway - I think even to self-modifying code could be some tricks like > dynamically generated code. It would be possible to save the original executable (for read references or write references to code that change already generated code) and invoke translator when we detect untranslated instructions. This would amount to a full QEMU plus some kind of startup cache. > I would be probably intrest to re-compile only modules, like .dll - but t= his > would > > require to analyze=C2=A0when and how .dll being loaded. This is kinda sel= f-modifying > code as well ? (OS loads .DLL) In general, a program can load anything and start executing them or even modify previously non-executable region to become executable.