scripts/qemu-binfmt-conf.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
With the command line flag -mplt and a recent toolchain, ELF binaries
generated by gcc can obtain EI_ABIVERSION=1, 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. Also other
values are technically possible. qemu executes these binaries just
fine, so relax the mask for the EI_ABIVERSION byte at offset 0x08.
In addition, extend magic string to distinguish mips o32 and n32 ABI.
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: ace3d65459
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: WANG Xuerui <xen0n@gentoo.org>
Cc: Laurent Vivier <laurent@vivier.eu>
Cc: WANG Xuerui <xen0n@gentoo.org>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Alex Bennee <alex.bennee@linaro.org>
Cc: Philippe Mathieu-Daudé <philippe.mathieu.daude@gmail.com>
Closes: https://gitlab.com/qemu-project/qemu/-/issues/843
---
v5: Fully relax mask for EI_ABIVERSION for all of mips; squash patches
since they touch the same lines
v4: Unchanged repost of v3
v3: Add the magic extension to distinguish n32 and o32
v2: Add the same EI_ABIVERSION fix for little endian as for big endian
v1: Initial version, only handling EI_ABIVERSION=1 on BE
scripts/qemu-binfmt-conf.sh | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh
index e9bfeb94d3..9cb723f443 100755
--- a/scripts/qemu-binfmt-conf.sh
+++ b/scripts/qemu-binfmt-conf.sh
@@ -60,28 +60,28 @@ 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_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\x00\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\xff\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\x00\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\x00\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\x00\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'
-mips64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
+mips64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
mips64_family=mips
mips64el_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-mips64el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
+mips64el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
mips64el_family=mips
sh4_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00'
--
2.34.1
On 28/3/22 22:49, Andreas K. Hüttel wrote: > With the command line flag -mplt and a recent toolchain, ELF binaries > generated by gcc can obtain EI_ABIVERSION=1, 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. Also other > values are technically possible. qemu executes these binaries just > fine, so relax the mask for the EI_ABIVERSION byte at offset 0x08. > > In addition, extend magic string to distinguish mips o32 and n32 ABI. > 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: ace3d65459 > Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org> > Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > Reviewed-by: WANG Xuerui <xen0n@gentoo.org> v5 changes are too different from v4 to keep these R-b tags IMO. LGTM but I'd like Xuerui to double-check the R-b stands, and an Acked-by from Laurent would make me feel safer ;) > Cc: Laurent Vivier <laurent@vivier.eu> > Cc: WANG Xuerui <xen0n@gentoo.org> > Cc: Richard Henderson <richard.henderson@linaro.org> > Cc: Alex Bennee <alex.bennee@linaro.org> > Cc: Philippe Mathieu-Daudé <philippe.mathieu.daude@gmail.com> > Closes: https://gitlab.com/qemu-project/qemu/-/issues/843 > --- > > v5: Fully relax mask for EI_ABIVERSION for all of mips; squash patches > since they touch the same lines > v4: Unchanged repost of v3 > v3: Add the magic extension to distinguish n32 and o32 > v2: Add the same EI_ABIVERSION fix for little endian as for big endian > v1: Initial version, only handling EI_ABIVERSION=1 on BE > > scripts/qemu-binfmt-conf.sh | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) > > diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh > index e9bfeb94d3..9cb723f443 100755 > --- a/scripts/qemu-binfmt-conf.sh > +++ b/scripts/qemu-binfmt-conf.sh > @@ -60,28 +60,28 @@ 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_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\x00\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\xff\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\x00\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\x00\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\x00\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' > -mips64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' > +mips64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' > mips64_family=mips > > mips64el_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00' > -mips64el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' > +mips64el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' > mips64el_family=mips > > sh4_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00'
Le 29/03/2022 à 01:39, Philippe Mathieu-Daudé a écrit : > On 28/3/22 22:49, Andreas K. Hüttel wrote: >> With the command line flag -mplt and a recent toolchain, ELF binaries >> generated by gcc can obtain EI_ABIVERSION=1, 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. Also other >> values are technically possible. qemu executes these binaries just >> fine, so relax the mask for the EI_ABIVERSION byte at offset 0x08. >> >> In addition, extend magic string to distinguish mips o32 and n32 ABI. >> 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: ace3d65459 >> Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org> >> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> >> Reviewed-by: WANG Xuerui <xen0n@gentoo.org> > > v5 changes are too different from v4 to keep these R-b tags IMO. > > LGTM but I'd like Xuerui to double-check the R-b stands, > and an Acked-by from Laurent would make me feel safer ;) Sorry, I didn't see your email before. It's more mips than linux-user, so there is no problem for me. Thanks, Laurent
On 3/29/22 07:39, Philippe Mathieu-Daudé wrote: > On 28/3/22 22:49, Andreas K. Hüttel wrote: >> With the command line flag -mplt and a recent toolchain, ELF binaries >> generated by gcc can obtain EI_ABIVERSION=1, 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. Also other >> values are technically possible. qemu executes these binaries just >> fine, so relax the mask for the EI_ABIVERSION byte at offset 0x08. >> >> In addition, extend magic string to distinguish mips o32 and n32 ABI. >> 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: ace3d65459 >> Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org> >> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> >> Reviewed-by: WANG Xuerui <xen0n@gentoo.org> > > v5 changes are too different from v4 to keep these R-b tags IMO. > > LGTM but I'd like Xuerui to double-check the R-b stands, > and an Acked-by from Laurent would make me feel safer ;) This is just a squash of v4 patches, but I manually double-checked the definitions against elf.h for that extra confidence, and they looked good. The R-b tags still stand :) -- WANG Xuerui xen0n@gentoo.org Gentoo Linux developer PGP: 7C52 19E3 26A0 7311 3EA3 8806 C01F 7214 BC93 1414
On 29/3/22 04:05, WANG Xuerui wrote: > On 3/29/22 07:39, Philippe Mathieu-Daudé wrote: >> On 28/3/22 22:49, Andreas K. Hüttel wrote: >>> With the command line flag -mplt and a recent toolchain, ELF binaries >>> generated by gcc can obtain EI_ABIVERSION=1, 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. Also other >>> values are technically possible. qemu executes these binaries just >>> fine, so relax the mask for the EI_ABIVERSION byte at offset 0x08. >>> >>> In addition, extend magic string to distinguish mips o32 and n32 ABI. >>> 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: ace3d65459 >>> Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org> >>> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> >>> Reviewed-by: WANG Xuerui <xen0n@gentoo.org> >> >> v5 changes are too different from v4 to keep these R-b tags IMO. >> >> LGTM but I'd like Xuerui to double-check the R-b stands, >> and an Acked-by from Laurent would make me feel safer ;) > > This is just a squash of v4 patches, but I manually double-checked the > definitions against elf.h for that extra confidence, and they looked > good. The R-b tags still stand :) Thanks for double-checking your R-b! Patch (already) queued to mips-fixes. Regards, Phil.
© 2016 - 2025 Red Hat, Inc.