This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: arch/mach selection guidelines ?


"Galit Heller" <Galit.Heller@nsc.com> writes:

> We are now creating gcc and binutils ports for National Semiconductor's
> CR16C, CR16CPlus and CRX processors. These processors are members of
> NS's CompactRISC family.
> 
> We have currently got one ELF machine identifier for the CompactRISC
> family - EM_CR, which is used in the CR16C binutils port code.
> 
> The differences between the other CompactRISC processors and the CR16C
> vary - some have a slightly different microarchitecture, e.g.
> the CR16CPlus can access greater memory area, and some have a very
> different instruction set, e.g. the CRX.
> 
> The question is twofold:
> 
> 1. What are the guidelines for requesting a new separate ELF machine code
>    for a processor ?

I believe that the address for this remains registry@sco.com.

> 2. What are the guidelines for distinction between architecture and machine,
>    i.e. how to decide whether to define two processors as two machs of the
>    same archs or as two different archs ?

Good question.  In ELF, whether a particular binary can be run on a
particular host is normally determined by the e_machine field and the
e_flags field.  Some targets also add a .note section/PT_NOTE
segment.

There isn't any reliable historical method here.  I think all the
32-bit x86 variants are handled via EM_386 (there is an EM_486, but I
think that was given up as a bad idea).  On the other hand I see
EM_68K and EM_COLDFIRE.

In general I think if the instruction set is similar, or if one CPU is
generally a superset of the other, stick with the same EM_ number.
Otherwise, request a different EM_ number.

>  It seems that in the ELF specification the terms machine and architecture
>  are used interchangeably: the e_machine designates the architecture.
>  However, in bfd there is a distinction between architecture and machine.
>  What is the exact distinction and the relationship beween the bfd terms
>  and the ELF terms, if any ?

The ELF terms are driven by the need for the program loader to
determine whether the program can be run on the host.

The BFD terms can be thought of as driven by the disassembler.  The
architecture selects a disassembler.  The machine number adjusts the
disassembler output.

Also, the linker should warn when you link together incompatible
object files.  In BFD, this is driven by the architecture and machine
number.  A different architecture implies that the files may not be
linked together.  A different machine number is handled in a
backend-specific manner--some machine combinations are rejected, some
cause the output file to be promoted to the superset machine number.
For example, see bfd_arm_merge_machines() in bfd/cpu-arm.c.

A different ELF EM_ number would normally indicate a different BFD
architecture--but not always, as EM_68K and EM_COLDFIRE both imply
bfd_arch_m68k (actually BFD doesn't appear to use EM_COLDFIRE, but, if
it did, it would use bfd_arch_m68k).

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]