Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C17FC48BE8 for ; Fri, 18 Jun 2021 07:09:19 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 451BB6100A for ; Fri, 18 Jun 2021 07:09:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 451BB6100A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AA51980488; Fri, 18 Jun 2021 09:09:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GDEzurLN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EB05E80772; Fri, 18 Jun 2021 09:09:13 +0200 (CEST) Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C1A5880377 for ; Fri, 18 Jun 2021 09:09:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bmeng.cn@gmail.com Received: by mail-ej1-x632.google.com with SMTP id l1so14258458ejb.6 for ; Fri, 18 Jun 2021 00:09:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=d4TK4po4wlb1eofviAXv8apqPi8MXcPYJcGTUmFWLMs=; b=GDEzurLNv6b1ekzA4tNPgUanahIr3jB0510RUkXytrQZ2yPQSSuB4VXyRFb3ji92n5 KwpUlNv6s6BL0kPY3cmgJo8K8mssBMbcP3bP0nrEHF88EDGazk5CMlcr1LnUaOE/bUvz JYey6yg1Qr/1JJi1yeSmvtwnqsO21frpb3knnOp+nvT4h8cyKd+p6Yfeu/PWp0gkWUBd s7/XeBW0y/9/6Xup5cfdUIYXLU+n4bmdXtSXbNg/A5KaAX7VUKd9r6paQ4meW43l49Tl qVlRsWSSo+ZJkN45+p90/YIDCdbfHPF0W7FpiYdzew2eDhX312zmUpB38nDl/AyYnPhj SM/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=d4TK4po4wlb1eofviAXv8apqPi8MXcPYJcGTUmFWLMs=; b=myMNa5swnAg2gaoW+89h17VXXN5uUj36u7WaWIXmiBpObDmFDjCu9wFYJXPRKxEii/ lyHkAUikM+hyHYkAVpQDlaVDbGR86Q2cG3W+UCyeecRr3h4YlS8U8nNDNUxMaqquDz2x pVWuUJHPGQ4oFBPd/8Ez2/YuNdLjxurrnReVXI9rYaXPHbm3Tn50Ix1n4GyvOeFQYV6T QWRRGIlcNHxBy3IjAMVmdkXvLds28o+RZrJRWucYxDsDN1eIJboWoVG1VGUBB3xvdo4L qSQkqwnktP7Q0HntKq+TwcTCLQjMvTsCr1v2+ZtdWXy08mZCNru97pDdL9vpwm4krKzO 6AYw== X-Gm-Message-State: AOAM530ZL7csN1k8V9jn7eslElcgyMlR0HuNfsVBQ7m2gpMkhK3ipc69 LiYi5yzEoPZKqWINzfYlzcg= X-Google-Smtp-Source: ABdhPJyZKxvboRkpBEz4vRhL94rzw7mqCPNC/Mz2BRjor6bc5WEvzoYpQfykKsr1JvE0Mn0VMNn8Aw== X-Received: by 2002:a17:906:6d51:: with SMTP id a17mr9512702ejt.543.1624000150336; Fri, 18 Jun 2021 00:09:10 -0700 (PDT) Received: from pek-vx-bsp2.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id gv10sm642315ejc.46.2021.06.18.00.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 00:09:09 -0700 (PDT) From: Bin Meng To: Simon Glass , Tom Rini , U-Boot Mailing List Subject: [PATCH v2] x86: Discard .note.gnu.property sections Date: Fri, 18 Jun 2021 15:09:30 +0800 Message-Id: <20210618070930.591188-1-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean When switching to kernel.org x86_64 gcc 11.1.0 toolchain, u-boot.rom built from qemu-x86_defconfig no longer boots anymore. Investigation shows that U-Boot fails at a very early stage during the boot process, in fdtdec_prepare_fdt() where fdt_check_header() complains that there is not a valid device tree found at gd->fdt_blob which points to _end. Now _end points to an allocated section .note.gnu.property which of course is wrong. This issue is however not seen when using the default Ubuntu 20.04 gnu toolchain (gcc 9.3.0 with binutils 2.34). Further investigation shows that it is caused by a behavior change of binutils v2.36 which is part of the kernel.org gcc 11.1.0 toolchain, via the following commit: 939b95c77bf2 ("Linux/x86: Configure gas with --enable-x86-used-note by default") In fact, there was already a regression bug report [1] for binutils two months ago, but the binutils folks did not think it is a bug :( To resolve this, there are several options: * pass -Wa,-mx86-used-note=no to gas * pass -R .note.gnu.property to objcopy * discard the section in the linker script Linux kernel uses the discard way [2], so let's do the same for U-Boot. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=27753 [2] commit 4caffe6a28d3 ("x86/vdso: Discard .note.gnu.property sections in vDSO") Signed-off-by: Bin Meng Reviewed-by: Tom Rini --- Changes in v2: - add the same change to u-boot-spl.lds and u-boot-64.lds arch/x86/cpu/u-boot-64.lds | 1 + arch/x86/cpu/u-boot-spl.lds | 1 + arch/x86/cpu/u-boot.lds | 1 + 3 files changed, 3 insertions(+) diff --git a/arch/x86/cpu/u-boot-64.lds b/arch/x86/cpu/u-boot-64.lds index 98c7f8e9c5..ee0812aefb 100644 --- a/arch/x86/cpu/u-boot-64.lds +++ b/arch/x86/cpu/u-boot-64.lds @@ -107,4 +107,5 @@ SECTIONS /DISCARD/ : { *(.plt*) } /DISCARD/ : { *(.interp*) } /DISCARD/ : { *(.gnu*) } + /DISCARD/ : { *(.note.gnu.property) } } diff --git a/arch/x86/cpu/u-boot-spl.lds b/arch/x86/cpu/u-boot-spl.lds index 4a655bf9b5..346f60bdac 100644 --- a/arch/x86/cpu/u-boot-spl.lds +++ b/arch/x86/cpu/u-boot-spl.lds @@ -82,6 +82,7 @@ SECTIONS /DISCARD/ : { *(.plt*) } /DISCARD/ : { *(.interp*) } /DISCARD/ : { *(.gnu*) } + /DISCARD/ : { *(.note.gnu.property) } #if defined(CONFIG_SPL_X86_16BIT_INIT) || defined(CONFIG_TPL_X86_16BIT_INIT) /* diff --git a/arch/x86/cpu/u-boot.lds b/arch/x86/cpu/u-boot.lds index a283c290ee..22fde01e74 100644 --- a/arch/x86/cpu/u-boot.lds +++ b/arch/x86/cpu/u-boot.lds @@ -105,6 +105,7 @@ SECTIONS /DISCARD/ : { *(.plt*) } /DISCARD/ : { *(.interp*) } /DISCARD/ : { *(.gnu*) } + /DISCARD/ : { *(.note.gnu.property) } #ifdef CONFIG_X86_16BIT_INIT /* -- 2.25.1