[Top] [All Lists]

Re: [patch] linux: RFC: elf_check_arch() rework

To: "Maciej W. Rozycki" <>
Subject: Re: [patch] linux: RFC: elf_check_arch() rework
From: Carsten Langgaard <>
Date: Thu, 25 Jul 2002 15:29:12 +0200
References: <>
"Maciej W. Rozycki" wrote:

> On Wed, 24 Jul 2002, Carsten Langgaard wrote:
> > We at MIPS are in the process of making an ABI spec for all this, which
> > is the intention that should be used by the tool-vendors.  So please
> > don't change the ELF header defines.
>  It'd be better the spec matched the real world...

Shouldn't it be the other way around, the real world should follow the spec
The whole ELF header definition is just one big mess, because we are lacking
a proper ABI spec.
That's what has motivated us, to begin making this ABI spec.

We have defined the e_flags this way:

/* ELF header e_flags defines. MIPS architecture level. */
#define EF_MIPS_ARCH_1      0x00000000  /* -mips1 code.  */
#define EF_MIPS_ARCH_2      0x10000000  /* -mips2 code.  */
#define EF_MIPS_ARCH_3      0x20000000  /* -mips3 code.  */
#define EF_MIPS_ARCH_4      0x30000000  /* -mips4 code.  */
#define EF_MIPS_ARCH_5      0x40000000  /* -mips5 code.  */
#define EF_MIPS_ARCH_32     0x60000000  /* MIPS32 code.  */
#define EF_MIPS_ARCH_64     0x70000000  /* MIPS64 code.  */
#define EF_MIPS_ARCH_32R2   0x80000000  /* MIPS32 code.  */
#define EF_MIPS_ARCH_64R2   0x90000000  /* MIPS64 code.  */

The missing value 0x50000000, is because IRIX has defined a EF_MIPS_ARCH_6
and Algorithmics has a E_MIPS_ARCH_ALGOR_32, which has this value.
If you look at the elf.h file in glibc, the you will see, it has the same
values as the kernel.

So I would prefer we fix that in binutils, I guess it not a problem as long
as you don't have a toolchain that can generate MIPS32 or MIPS64 code.

> > I don't see that is wrong with checking the ISA level, I rather have an
> > error telling me that I can't execute a certain ISA level than
> > eventually getting a reserved instruction or something worse like
> > something unpredictable.
>  Well, -ENOEXEC in not any more useful than SIGILL -- with the latter you
> have at least an idea what happened.  The ISA check is not implemented for
> any Linux port, so there no suitable hook in binfmt_*.c files.  You might
> propose an implementation if that's particularly important for you.

I would like a message telling me that I can't run this ISA level on the
Imagined what would happen, if you execute mips3 code and execute ld/sd
instructions on a mips32 kernel (but on a 64-bit processor), the kernel only
save half the register and then everything could happen.

> > You are obviously right about the elf_check_arch in the 64-bit part of
> > the kernel is broken.  It's probably just be copied from the 32-bit part
> > without changes, like a lot of the code in the 64-bit kernel is.
>  Possibly, but it still makes me wonder why it wasn't adjusted at the time
> binfmt_elf32.c was created...
>   Maciej
> --
> +  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
> +--------------------------------------------------------------+
> +        e-mail:, PGP key available        +

_    _ ____  ___   Carsten Langgaard
|\  /|||___)(___   MIPS Denmark        Direct: +45 4486 5527
| \/ |||    ____)  Lautrupvang 4B      Switch: +45 4486 5555
  TECHNOLOGIES     2750 Ballerup       Fax...: +45 4486 5556

<Prev in Thread] Current Thread [Next in Thread>