Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CDAD9C433FE for ; Wed, 23 Mar 2022 23:08:20 +0000 (UTC) Received: from localhost ([::1]:37216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXA5T-0000Lb-Qa for qemu-devel@archiver.kernel.org; Wed, 23 Mar 2022 19:08:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXA3i-0006jt-Td for qemu-devel@nongnu.org; Wed, 23 Mar 2022 19:06:30 -0400 Received: from woodpecker.gentoo.org ([140.211.166.183]:34536 helo=smtp.gentoo.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1nXA3h-0000mL-DM for qemu-devel@nongnu.org; Wed, 23 Mar 2022 19:06:30 -0400 Received: (nullmailer pid 657461 invoked by uid 1000); Wed, 23 Mar 2022 23:06:17 -0000 From: =?UTF-8?q?Andreas=20K=2E=20H=C3=BCttel?= To: qemu-devel@nongnu.org Subject: [PATCH v4 1/2] qemu-binfmt-conf.sh: allow elf EI_ABIVERSION=1 for mips Date: Thu, 24 Mar 2022 00:05:58 +0100 Message-Id: <20220323230559.656291-2-dilfridge@gentoo.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220323230559.656291-1-dilfridge@gentoo.org> References: <20220323230559.656291-1-dilfridge@gentoo.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: none client-ip=140.211.166.183; envelope-from=huettel@www.akhuettel.de; helo=smtp.gentoo.org X-Spam_score_int: -56 X-Spam_score: -5.7 X-Spam_bar: ----- X-Spam_report: (-5.7 / 5.0 requ) BAYES_00=-1.9, FORGED_SPF_HELO=1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, richard.henderson@linaro.org, laurent@vivier.eu, =?UTF-8?q?Andreas=20K=2E=20H=C3=BCttel?= , philippe.mathieu.daude@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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' -- 2.34.1