qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philippe.mathieu.daude@gmail.com>
To: laurent@vivier.eu, "Andreas K. Hüttel" <dilfridge@gentoo.org>,
	qemu-devel@nongnu.org
Cc: alex.bennee@linaro.org, richard.henderson@linaro.org
Subject: Re: [PATCH-for-7.0 v3 1/2] qemu-binfmt-conf.sh: allow elf EI_ABIVERSION=1 for mips
Date: Wed, 23 Mar 2022 12:00:31 +0100	[thread overview]
Message-ID: <2a40e9f8-dc2a-070c-216a-4a830ea0dd65@gmail.com> (raw)
In-Reply-To: <20220314213355.2477-2-dilfridge@gentoo.org>

On 14/3/22 22:33, 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, 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) */
> | (...)
> 
> Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
> ---
>   scripts/qemu-binfmt-conf.sh | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh
> index e9bfeb94d3..fc2f856800 100755
> --- a/scripts/qemu-binfmt-conf.sh
> +++ b/scripts/qemu-binfmt-conf.sh
> @@ -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'

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?

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

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

Thanks,

Phil.


  reply	other threads:[~2022-03-23 11:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03 10:17 [PATCH] qemu-binfmt-conf.sh: allow elf EI_ABIVERSION=1 for mips Andreas K. Hüttel
2022-03-05  0:06 ` [PATCH v2] " Andreas K. Hüttel
2022-03-05  0:18   ` Philippe Mathieu-Daudé
2022-03-06 23:54     ` Philippe Mathieu-Daudé
2022-03-14 21:33   ` qemu-binfmt-conf.sh: mips improvements Andreas K. Hüttel
2022-03-14 21:33     ` [PATCH v3 1/2] qemu-binfmt-conf.sh: allow elf EI_ABIVERSION=1 for mips Andreas K. Hüttel
2022-03-23 11:00       ` Philippe Mathieu-Daudé [this message]
2022-03-14 21:33     ` [PATCH v3 2/2] qemu-binfmt-conf.sh: Extend magic to distinguish mips o32 and n32 ABI Andreas K. Hüttel
2022-03-22 10:35       ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a40e9f8-dc2a-070c-216a-4a830ea0dd65@gmail.com \
    --to=philippe.mathieu.daude@gmail.com \
    --cc=alex.bennee@linaro.org \
    --cc=dilfridge@gentoo.org \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).