From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30399 invoked by alias); 24 Oct 2003 21:46:33 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 30392 invoked from network); 24 Oct 2003 21:46:32 -0000 Received: from unknown (HELO zenia.home) (12.223.225.216) by sources.redhat.com with SMTP; 24 Oct 2003 21:46:32 -0000 Received: by zenia.home (Postfix, from userid 5433) id 873B420766; Fri, 24 Oct 2003 16:46:03 -0500 (EST) To: Andrew Cagney Cc: gdb-patches@sources.redhat.com Subject: Re: [obish] More osabi comments References: <3F9948BA.4050201@redhat.com> From: Jim Blandy Date: Fri, 24 Oct 2003 21:46:00 -0000 In-Reply-To: <3F9948BA.4050201@redhat.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-10/txt/msg00755.txt.bz2 Andrew Cagney writes: > More comments the better ... > > Recent discussions to do with rs6000 compatibility left me wondering > how come "amd64 can run code for i386" wasn't getting a hit. The > attached comment explains why the test (both old and new) works for > the 32-bit vs 64-bit case. > > I also changed "atom" to the more common OO term "singleton". For what it's worth, I got "atom" from bfd/archures.c: SECTION Architectures BFD keeps one atom in a BFD describing the architecture of the data attached to the BFD: a pointer to a <>. There's something to be said for using the same terminology used in the code that defines the data structures one is discussing. Perhaps a corresponding patch for BFD would be good, too. > + /* NOTE: cagney/2003-10-23: The code for "a can_run_code_for b" > + is implemented using BFD's compatible method (a->compatible > + (b) == a -- the lowest common denominator between a and b is > + a). That method's definition of compatible may not be as you > + expect. For instance, while "amd64 can run code for i386" > + (or more generally "64-bit ISA can run code for the 32-bit > + ISA"). Fortunatly, BFD doesn't normally consider 32-bit and > + 64-bit "compatible" so won't get a match. */ (Incomplete sentence in there.) This comment implies that can_run_code_for (A, B) might return zero when A actually can run code for B. That's not so. The example you give is, I think, incorrect. The x86_64 64-bit ISA is not a superset with the IA-32 ISA: the 64-bit ISA takes over the one-byte opcodes for INC and DEC, 0x40 -- 0x4f, for use as its new REX prefix codes. So one can't include i386 code in an x86-64 64-bit mode code segment. One must mark the code segment as being in 'compatibility mode' to execute IA-32 code. For details, see: http://www.amd.com/products/cpg/64bit/pdf/x86-64_overview.pdf So, can_run_code_for (&bfd_x86_64_arch, &bfd_i386_arch) == 0, just as it should.