All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] x86: Discard .note.gnu.property sections
@ 2021-06-18  7:09 Bin Meng
  2021-06-21  2:23 ` Bin Meng
  0 siblings, 1 reply; 2+ messages in thread
From: Bin Meng @ 2021-06-18  7:09 UTC (permalink / raw)
  To: Simon Glass, Tom Rini, U-Boot Mailing List

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 <bmeng.cn@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

---

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] x86: Discard .note.gnu.property sections
  2021-06-18  7:09 [PATCH v2] x86: Discard .note.gnu.property sections Bin Meng
@ 2021-06-21  2:23 ` Bin Meng
  0 siblings, 0 replies; 2+ messages in thread
From: Bin Meng @ 2021-06-21  2:23 UTC (permalink / raw)
  To: Simon Glass, Tom Rini, U-Boot Mailing List

On Fri, Jun 18, 2021 at 3:09 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> 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 <bmeng.cn@gmail.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
>
> ---
>
> 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(+)
>

applied to u-boot-x86, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-21  2:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18  7:09 [PATCH v2] x86: Discard .note.gnu.property sections Bin Meng
2021-06-21  2:23 ` Bin Meng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.