u-boot/arch/x86/cpu/u-boot.lds
Bin Meng 6fbe06a6ce x86: Discard .note.gnu.property sections
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>
2021-06-23 17:21:14 +08:00

126 lines
2 KiB
Text

/* SPDX-License-Identifier: GPL-2.0+ */
/*
* (C) Copyright 2002
* Daniel Engström, Omicron Ceti AB, daniel@omicron.se.
*/
#include <config.h>
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(_start)
SECTIONS
{
#ifndef CONFIG_CMDLINE
/DISCARD/ : { *(.u_boot_list_2_cmd_*) }
#endif
. = CONFIG_SYS_TEXT_BASE; /* Location of bootcode in flash */
__text_start = .;
.text.start : { *(.text.start); }
.__efi_runtime_start : {
*(.__efi_runtime_start)
}
.efi_runtime : {
*(.text.efi_runtime*)
*(.rodata.efi_runtime*)
*(.data.efi_runtime*)
}
.__efi_runtime_stop : {
*(.__efi_runtime_stop)
}
.text : { *(.text*); }
. = ALIGN(4);
. = ALIGN(4);
.u_boot_list : {
KEEP(*(SORT(.u_boot_list*)));
}
. = ALIGN(4);
.rodata : {
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
KEEP(*(.rodata.efi.init));
}
. = ALIGN(4);
.data : { *(.data*) }
. = ALIGN(4);
.hash : { *(.hash*) }
. = ALIGN(4);
.got : { *(.got*) }
. = ALIGN(4);
.efi_runtime_rel_start :
{
*(.__efi_runtime_rel_start)
}
.efi_runtime_rel : {
*(.rel*.efi_runtime)
*(.rel*.efi_runtime.*)
}
.efi_runtime_rel_stop :
{
*(.__efi_runtime_rel_stop)
}
. = ALIGN(4);
__data_end = .;
__init_end = .;
. = ALIGN(4);
.dynsym : { *(.dynsym*) }
. = ALIGN(4);
__rel_dyn_start = .;
.rel.dyn : {
*(.rel*)
}
__rel_dyn_end = .;
. = ALIGN(4);
_end = .;
.bss __rel_dyn_start (OVERLAY) : {
__bss_start = .;
*(.bss*)
*(COM*)
. = ALIGN(4);
__bss_end = .;
}
/DISCARD/ : { *(.dynstr*) }
/DISCARD/ : { *(.dynamic*) }
/DISCARD/ : { *(.plt*) }
/DISCARD/ : { *(.interp*) }
/DISCARD/ : { *(.gnu*) }
/DISCARD/ : { *(.note.gnu.property) }
#ifdef CONFIG_X86_16BIT_INIT
/*
* The following expressions place the 16-bit Real-Mode code and
* Reset Vector at the end of the Flash ROM
*/
. = START_16 - RESET_SEG_START;
.start16 : AT (START_16) {
KEEP(*(.start16));
}
. = RESET_VEC_LOC - RESET_SEG_START;
.resetvec : AT (RESET_VEC_LOC) {
KEEP(*(.resetvec));
}
#endif
}