This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [obish] More osabi comments
- From: Jim Blandy <jimb at redhat dot com>
- To: Andrew Cagney <ac131313 at redhat dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Date: 24 Oct 2003 16:46:03 -0500
- Subject: Re: [obish] More osabi comments
- References: <3F9948BA.4050201@redhat.com>
Andrew Cagney <ac131313@redhat.com> 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
<<bfd_arch_info_type>>.
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.