Skip to contentSkip to conversation

qemu-binfmt-conf.sh: allow elf EI_ABIVERSION=1 for mips

PATCH Superseded Andreas K. Hüttel 2 participants 9 messages Mar 3, 2022 – Mar 23, 2022 exec and binfmt

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-binfmt-conf.sh: allow elf EI_ABIVERSION=1 for mips

With the command line flag -mplt and a recent toolchain, ELF binaries generated by gcc can obtain EI_ABIVERSION=1, see below, which makes, e.g., gcc three-stage bootstrap in a mips-unknown-linux-gnu qemu-user chroot fail since the binfmt-misc magic does not match anymore.

qemu executes these binaries just fine, so relax the mask slightly.

CHOST=mips-unknown-linux-gnu
CFLAGS="-O2 -march=mips32 -mabi=32 -mplt -pipe"
gcc-11.2, binutils-2.37, glibc-2.34

|  /*
| - * ELF dump of './prev-gcc/build/gengenrtl'
| - *     29608 (0x73A8) bytes
| + * ELF dump of './gcc/build/gengenrtl'
| + *     54532 (0xD504) bytes
|   */
|
|  Elf32_Dyn dumpedelf_dyn_0[];
|  struct {
|         Elf32_Ehdr ehdr;
|         Elf32_Phdr phdrs[12];
| -       Elf32_Shdr shdrs[33];
| +       Elf32_Shdr shdrs[44];
|         Elf32_Dyn *dyns;
|  } dumpedelf_0 = {
|
|  .ehdr = {
|         .e_ident = { /* (EI_NIDENT bytes) */
|                 /* [0] EI_MAG:        */ 0x7F,'E','L','F',
|                 /* [4] EI_CLASS:      */ 1 , /* (ELFCLASS32) */
|                 /* [5] EI_DATA:       */ 2 , /* (ELFDATA2MSB) */
|                 /* [6] EI_VERSION:    */ 1 , /* (EV_CURRENT) */
|                 /* [7] EI_OSABI:      */ 0 , /* (ELFOSABI_NONE) */
| -               /* [8] EI_ABIVERSION: */ 0 ,
| +               /* [8] EI_ABIVERSION: */ 1 ,
|                 /* [9-15] EI_PAD:     */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|         },
|         .e_type      = 2          , /* (ET_EXEC) */
|         .e_machine   = 8          , /* (EM_MIPS) */
|         .e_version   = 1          , /* (EV_CURRENT) */
| (...)
---
 scripts/qemu-binfmt-conf.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/qemu-binfmt-conf.sh +1 -1
index e9bfeb94d3..2ac2226f26 100755
@@ -61,7 +61,7 @@ m68k_family=m68k
 # FIXME: We could use the other endianness on a MIPS host.
 
 mips_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
+mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
 mips_family=mips
 
 mipsel_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/1 qemu-binfmt-conf.sh: allow elf EI_ABIVERSION=1 for mips

With the command line flag -mplt and a recent toolchain, ELF binaries generated by gcc can obtain EI_ABIVERSION=1, see below, which makes, e.g., gcc three-stage bootstrap in a mips-unknown-linux-gnu qemu-user chroot fail since the binfmt-misc magic does not match anymore.

qemu executes these binaries just fine, so relax the mask slightly.

CHOST=mips-unknown-linux-gnu (and also mipsel-unknown-linux-gnu) CFLAGS="-O2 -march=mips32 -mabi=32 -mplt -pipe" gcc-11.2, binutils-2.37, glibc-2.34

|  /*
| - * ELF dump of './prev-gcc/build/gengenrtl'
| - *     29608 (0x73A8) bytes
| + * ELF dump of './gcc/build/gengenrtl'
| + *     54532 (0xD504) bytes
|   */
|
|  Elf32_Dyn dumpedelf_dyn_0[];
|  struct {
|         Elf32_Ehdr ehdr;
|         Elf32_Phdr phdrs[12];
| -       Elf32_Shdr shdrs[33];
| +       Elf32_Shdr shdrs[44];
|         Elf32_Dyn *dyns;
|  } dumpedelf_0 = {
|
|  .ehdr = {
|         .e_ident = { /* (EI_NIDENT bytes) */
|                 /* [0] EI_MAG:        */ 0x7F,'E','L','F',
|                 /* [4] EI_CLASS:      */ 1 , /* (ELFCLASS32) */
|                 /* [5] EI_DATA:       */ 2 , /* (ELFDATA2MSB) */
|                 /* [6] EI_VERSION:    */ 1 , /* (EV_CURRENT) */
|                 /* [7] EI_OSABI:      */ 0 , /* (ELFOSABI_NONE) */
| -               /* [8] EI_ABIVERSION: */ 0 ,
| +               /* [8] EI_ABIVERSION: */ 1 ,
|                 /* [9-15] EI_PAD:     */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|         },
|         .e_type      = 2          , /* (ET_EXEC) */
|         .e_machine   = 8          , /* (EM_MIPS) */
|         .e_version   = 1          , /* (EV_CURRENT) */
| (...)

---

v2: Add the same fix for little endian as for big endian

 scripts/qemu-binfmt-conf.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/qemu-binfmt-conf.sh +2 -2
index e9bfeb94d3..fc2f856800 100755
@@ -61,11 +61,11 @@ m68k_family=m68k
 # FIXME: We could use the other endianness on a MIPS host.
 
 mips_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
+mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
 mips_family=mips
 
 mipsel_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
+mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
 mipsel_family=mips
 
 mipsn32_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
Signature · 1 line
2.34.1
#2 lore raw

Cc'ing Laurent:

$ ./scripts/get_maintainer.pl -f scripts/qemu-binfmt-conf.sh
Laurent Vivier <[email protected]> (maintainer:Linux user)
[email protected] (open list:All patches CC here)
Quoted 69 lines · Andreas K. Hüttel

With the command line flag -mplt and a recent toolchain, ELF binaries generated by gcc can obtain EI_ABIVERSION=1, see below, which makes, e.g., gcc three-stage bootstrap in a mips-unknown-linux-gnu qemu-user chroot fail since the binfmt-misc magic does not match anymore.

qemu executes these binaries just fine, so relax the mask slightly.

CHOST=mips-unknown-linux-gnu (and also mipsel-unknown-linux-gnu) CFLAGS="-O2 -march=mips32 -mabi=32 -mplt -pipe" gcc-11.2, binutils-2.37, glibc-2.34

|  /*
| - * ELF dump of './prev-gcc/build/gengenrtl'
| - *     29608 (0x73A8) bytes
| + * ELF dump of './gcc/build/gengenrtl'
| + *     54532 (0xD504) bytes
|   */
|
|  Elf32_Dyn dumpedelf_dyn_0[];
|  struct {
|         Elf32_Ehdr ehdr;
|         Elf32_Phdr phdrs[12];
| -       Elf32_Shdr shdrs[33];
| +       Elf32_Shdr shdrs[44];
|         Elf32_Dyn *dyns;
|  } dumpedelf_0 = {
|
|  .ehdr = {
|         .e_ident = { /* (EI_NIDENT bytes) */
|                 /* [0] EI_MAG:        */ 0x7F,'E','L','F',
|                 /* [4] EI_CLASS:      */ 1 , /* (ELFCLASS32) */
|                 /* [5] EI_DATA:       */ 2 , /* (ELFDATA2MSB) */
|                 /* [6] EI_VERSION:    */ 1 , /* (EV_CURRENT) */
|                 /* [7] EI_OSABI:      */ 0 , /* (ELFOSABI_NONE) */
| -               /* [8] EI_ABIVERSION: */ 0 ,
| +               /* [8] EI_ABIVERSION: */ 1 ,
|                 /* [9-15] EI_PAD:     */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|         },
|         .e_type      = 2          , /* (ET_EXEC) */
|         .e_machine   = 8          , /* (EM_MIPS) */
|         .e_version   = 1          , /* (EV_CURRENT) */
| (...)

---

v2: Add the same fix for little endian as for big endian

  scripts/qemu-binfmt-conf.sh | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
scripts/qemu-binfmt-conf.sh +2 -2
index e9bfeb94d3..fc2f856800 100755
@@ -61,11 +61,11 @@ m68k_family=m68k
  # FIXME: We could use the other endianness on a MIPS host.
 
  mips_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
+mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  mips_family=mips
 
  mipsel_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
+mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
  mipsel_family=mips
 
  mipsn32_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
#3 lore raw

(Cc'ing Richard)

Quoted 57 lines · Philippe Mathieu-Daudé

Cc'ing Laurent:

$ ./scripts/get_maintainer.pl -f scripts/qemu-binfmt-conf.sh
Laurent Vivier <[email protected]> (maintainer:Linux user)
[email protected] (open list:All patches CC here)
Quoted 50 lines · Andreas K. Hüttel

With the command line flag -mplt and a recent toolchain, ELF binaries generated by gcc can obtain EI_ABIVERSION=1, see below, which makes, e.g., gcc three-stage bootstrap in a mips-unknown-linux-gnu qemu-user chroot fail since the binfmt-misc magic does not match anymore.

qemu executes these binaries just fine, so relax the mask slightly.

CHOST=mips-unknown-linux-gnu (and also mipsel-unknown-linux-gnu) CFLAGS="-O2 -march=mips32 -mabi=32 -mplt -pipe" gcc-11.2, binutils-2.37, glibc-2.34

|  /*
| - * ELF dump of './prev-gcc/build/gengenrtl'
| - *     29608 (0x73A8) bytes
| + * ELF dump of './gcc/build/gengenrtl'
| + *     54532 (0xD504) bytes
|   */
|
|  Elf32_Dyn dumpedelf_dyn_0[];
|  struct {
|         Elf32_Ehdr ehdr;
|         Elf32_Phdr phdrs[12];
| -       Elf32_Shdr shdrs[33];
| +       Elf32_Shdr shdrs[44];
|         Elf32_Dyn *dyns;
|  } dumpedelf_0 = {
|
|  .ehdr = {
|         .e_ident = { /* (EI_NIDENT bytes) */
|                 /* [0] EI_MAG:        */ 0x7F,'E','L','F',
|                 /* [4] EI_CLASS:      */ 1 , /* (ELFCLASS32) */
|                 /* [5] EI_DATA:       */ 2 , /* (ELFDATA2MSB) */
|                 /* [6] EI_VERSION:    */ 1 , /* (EV_CURRENT) */
|                 /* [7] EI_OSABI:      */ 0 , /* (ELFOSABI_NONE) */
| -               /* [8] EI_ABIVERSION: */ 0 ,
| +               /* [8] EI_ABIVERSION: */ 1 ,
|                 /* [9-15] EI_PAD:     */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|         },
|         .e_type      = 2          , /* (ET_EXEC) */
|         .e_machine   = 8          , /* (EM_MIPS) */
|         .e_version   = 1          , /* (EV_CURRENT) */
| (...)

---

v2: Add the same fix for little endian as for big endian

  scripts/qemu-binfmt-conf.sh | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 26 lines
Quoted 25 lines
scripts/qemu-binfmt-conf.sh +0 -0
index e9bfeb94d3..fc2f856800 100755
@@ -61,11 +61,11 @@ m68k_family=m68k
   # FIXME: We could use the other endianness on a MIPS host.
 

mips_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'

scripts/qemu-binfmt-conf.sh +1 -1
-mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' 
 
+mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' 

  mips_family=mips

mipsel_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'

scripts/qemu-binfmt-conf.sh +1 -1
-mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' 
 
+mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' 

  mipsel_family=mips

mipsn32_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'

#4 lore raw

qemu-binfmt-conf.sh: mips improvements

In reply to Andreas K. Hüttel

Two patches; the first one has been under review before, the second builds on it and extends the binfmt-misc magic to differentiate between o32 and n32 binaries (see also issue 843).

#5 lore raw

PATCH v3 1/2 qemu-binfmt-conf.sh: allow elf EI_ABIVERSION=1 for mips

With the command line flag -mplt and a recent toolchain, ELF binaries generated by gcc can obtain EI_ABIVERSION=1, see below, which makes, e.g., gcc three-stage bootstrap in a mips-unknown-linux-gnu qemu-user chroot fail since the binfmt-misc magic does not match anymore.

qemu executes these binaries just fine, so relax the mask slightly.

CHOST=mips-unknown-linux-gnu (and also mipsel-unknown-linux-gnu) CFLAGS="-O2 -march=mips32 -mabi=32 -mplt -pipe" gcc-11.2, binutils-2.37, glibc-2.34

|  /*
| - * ELF dump of './prev-gcc/build/gengenrtl'
| - *     29608 (0x73A8) bytes
| + * ELF dump of './gcc/build/gengenrtl'
| + *     54532 (0xD504) bytes
|   */
|
|  Elf32_Dyn dumpedelf_dyn_0[];
|  struct {
|         Elf32_Ehdr ehdr;
|         Elf32_Phdr phdrs[12];
| -       Elf32_Shdr shdrs[33];
| +       Elf32_Shdr shdrs[44];
|         Elf32_Dyn *dyns;
|  } dumpedelf_0 = {
|
|  .ehdr = {
|         .e_ident = { /* (EI_NIDENT bytes) */
|                 /* [0] EI_MAG:        */ 0x7F,'E','L','F',
|                 /* [4] EI_CLASS:      */ 1 , /* (ELFCLASS32) */
|                 /* [5] EI_DATA:       */ 2 , /* (ELFDATA2MSB) */
|                 /* [6] EI_VERSION:    */ 1 , /* (EV_CURRENT) */
|                 /* [7] EI_OSABI:      */ 0 , /* (ELFOSABI_NONE) */
| -               /* [8] EI_ABIVERSION: */ 0 ,
| +               /* [8] EI_ABIVERSION: */ 1 ,
|                 /* [9-15] EI_PAD:     */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|         },
|         .e_type      = 2          , /* (ET_EXEC) */
|         .e_machine   = 8          , /* (EM_MIPS) */
|         .e_version   = 1          , /* (EV_CURRENT) */
| (...)
---
 scripts/qemu-binfmt-conf.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/qemu-binfmt-conf.sh +2 -2
index e9bfeb94d3..fc2f856800 100755
@@ -61,11 +61,11 @@ m68k_family=m68k
 # FIXME: We could use the other endianness on a MIPS host.
 
 mips_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
+mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
 mips_family=mips
 
 mipsel_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
+mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
 mipsel_family=mips
 
 mipsn32_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
Signature · 1 line
2.34.1
Reviewed-by on v3 1/2
#6 lore raw
Quoted 56 lines · Andreas K. Hüttel

With the command line flag -mplt and a recent toolchain, ELF binaries generated by gcc can obtain EI_ABIVERSION=1, see below, which makes, e.g., gcc three-stage bootstrap in a mips-unknown-linux-gnu qemu-user chroot fail since the binfmt-misc magic does not match anymore.

qemu executes these binaries just fine, so relax the mask slightly.

CHOST=mips-unknown-linux-gnu (and also mipsel-unknown-linux-gnu) CFLAGS="-O2 -march=mips32 -mabi=32 -mplt -pipe" gcc-11.2, binutils-2.37, glibc-2.34

|  /*
| - * ELF dump of './prev-gcc/build/gengenrtl'
| - *     29608 (0x73A8) bytes
| + * ELF dump of './gcc/build/gengenrtl'
| + *     54532 (0xD504) bytes
|   */
|
|  Elf32_Dyn dumpedelf_dyn_0[];
|  struct {
|         Elf32_Ehdr ehdr;
|         Elf32_Phdr phdrs[12];
| -       Elf32_Shdr shdrs[33];
| +       Elf32_Shdr shdrs[44];
|         Elf32_Dyn *dyns;
|  } dumpedelf_0 = {
|
|  .ehdr = {
|         .e_ident = { /* (EI_NIDENT bytes) */
|                 /* [0] EI_MAG:        */ 0x7F,'E','L','F',
|                 /* [4] EI_CLASS:      */ 1 , /* (ELFCLASS32) */
|                 /* [5] EI_DATA:       */ 2 , /* (ELFDATA2MSB) */
|                 /* [6] EI_VERSION:    */ 1 , /* (EV_CURRENT) */
|                 /* [7] EI_OSABI:      */ 0 , /* (ELFOSABI_NONE) */
| -               /* [8] EI_ABIVERSION: */ 0 ,
| +               /* [8] EI_ABIVERSION: */ 1 ,
|                 /* [9-15] EI_PAD:     */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|         },
|         .e_type      = 2          , /* (ET_EXEC) */
|         .e_machine   = 8          , /* (EM_MIPS) */
|         .e_version   = 1          , /* (EV_CURRENT) */
| (...)
---
  scripts/qemu-binfmt-conf.sh | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
scripts/qemu-binfmt-conf.sh +0 -0
index e9bfeb94d3..fc2f856800 100755
@@ -61,11 +61,11 @@ m68k_family=m68k
  # FIXME: We could use the other endianness on a MIPS host.
 
  mips_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'

scripts/qemu-binfmt-conf.sh m68k_family=m68k · line 71

Quoted 10 lines
scripts/qemu-binfmt-conf.sh +2 -2
-mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
+mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
  mips_family=mips
 
  mipsel_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
+mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
  mipsel_family=mips
 
  mipsn32_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'

It seems this series got lost because you posted iterations as reply to v1, so v2/v3 ended burried in the thread. Could you repost as v4 in a new thread?

Laurent, what do you think about getting this patch for 7.0?

Thanks,

Phil.

#7 lore raw

PATCH v3 2/2 qemu-binfmt-conf.sh: Extend magic to distinguish mips o32 and n32 ABI

In reply to Andreas K. Hüttel

This information is given by the EF_MIPS_ABI2 (0x20) bit in the e_flags field of the ELF header (a 4-byte value at offset 0x24 for the here applicable ELFCLASS32).

See-also: https://www.mail-archive.com/[email protected]/msg732572.html

---
 scripts/qemu-binfmt-conf.sh | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
scripts/qemu-binfmt-conf.sh +8 -8
index fc2f856800..5f44346166 100755
@@ -60,20 +60,20 @@ m68k_family=m68k
 
 # FIXME: We could use the other endianness on a MIPS host.
 
-mips_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
+mips_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20'
 mips_family=mips
 
-mipsel_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
+mipsel_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00'
 mipsel_family=mips
 
-mipsn32_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-mipsn32_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
+mipsn32_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20'
+mipsn32_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20'
 mipsn32_family=mips
 
-mipsn32el_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-mipsn32el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
+mipsn32el_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00'
+mipsn32el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00'
 mipsn32el_family=mips
 
 mips64_magic='\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
Signature · 1 line
2.34.1
#8 lore raw

Re: [PATCH v3 2/2] qemu-binfmt-conf.sh: Extend magic to distinguish mips o32 and n32 ABI

Quoted 5 lines · Andreas K. Hüttel

This information is given by the EF_MIPS_ABI2 (0x20) bit in the e_flags field of the ELF header (a 4-byte value at offset 0x24 for the here applicable ELFCLASS32).

See-also: https://www.mail-archive.com/[email protected]/msg732572.html

This is commit ace3d65459 ("linux-user: detect mismatched ELF ABI in qemu-mips[n32][el]").

Quoted 38 lines
---
  scripts/qemu-binfmt-conf.sh | 16 ++++++++--------
  1 file changed, 8 insertions(+), 8 deletions(-)
scripts/qemu-binfmt-conf.sh +8 -8
index fc2f856800..5f44346166 100755
@@ -60,20 +60,20 @@ m68k_family=m68k
 
  # FIXME: We could use the other endianness on a MIPS host.
 
-mips_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
+mips_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20'
  mips_family=mips
 
-mipsel_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
+mipsel_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00'
  mipsel_family=mips
 
-mipsn32_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-mipsn32_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
+mipsn32_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20'
+mipsn32_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20'
  mipsn32_family=mips
 
-mipsn32el_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-mipsn32el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
+mipsn32el_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00'
+mipsn32el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00'
  mipsn32el_family=mips
 
  mips64_magic='\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'