2018-05-06 21:58:06 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2017-01-16 14:04:02 +00:00
|
|
|
/*
|
|
|
|
* (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
|
2022-05-30 10:00:04 +00:00
|
|
|
/DISCARD/ : { *(__u_boot_list_2_cmd_*) }
|
2017-01-16 14:04:02 +00:00
|
|
|
#endif
|
|
|
|
|
2019-01-22 22:09:26 +00:00
|
|
|
. = IMAGE_TEXT_BASE; /* Location of bootcode in flash */
|
2017-01-16 14:04:02 +00:00
|
|
|
__text_start = .;
|
2019-12-07 04:42:00 +00:00
|
|
|
.text : {
|
|
|
|
__image_copy_start = .;
|
|
|
|
*(.text*);
|
|
|
|
}
|
2017-01-16 14:04:02 +00:00
|
|
|
|
|
|
|
. = ALIGN(4);
|
|
|
|
|
|
|
|
. = ALIGN(4);
|
2022-05-30 10:00:04 +00:00
|
|
|
__u_boot_list : {
|
|
|
|
KEEP(*(SORT(__u_boot_list*)));
|
2017-01-16 14:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
. = ALIGN(4);
|
|
|
|
.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
|
|
|
|
|
2021-03-15 04:25:44 +00:00
|
|
|
. = ALIGN(4);
|
|
|
|
|
|
|
|
.priv_data : {
|
|
|
|
__priv_data_start = .;
|
|
|
|
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.priv_data*)))
|
|
|
|
__priv_data_end = .;
|
|
|
|
}
|
|
|
|
|
2017-01-16 14:04:02 +00:00
|
|
|
. = ALIGN(4);
|
|
|
|
.data : { *(.data*) }
|
|
|
|
|
|
|
|
. = ALIGN(4);
|
|
|
|
__data_end = .;
|
|
|
|
__init_end = .;
|
2019-09-25 14:11:36 +00:00
|
|
|
. = ALIGN(4);
|
|
|
|
.binman_sym_table : {
|
|
|
|
__binman_sym_start = .;
|
|
|
|
KEEP(*(SORT(.binman_sym*)));
|
|
|
|
__binman_sym_end = .;
|
x86: Make sure the SPL image ends on a suitable boundary
The part of U-Boot that actually ends up in u-boot-nodtb.bin is not built
with any particular alignment. It ends at the start of the BSS section.
The BSS section selects its own alignment, which may larger.
This means that there can be a gap of a few bytes between the image
ending and BSS starting.
Since u-boot.bin is build by joining u-boot-nodtb.bin and u-boot.dtb (with
perhaps some padding for BSS), the expected result is not obtained. U-Boot
uses the end of BSS to find the devicetree, so this means that it cannot
be found.
Add 32-byte alignment of BSS so that the image size is correct and
appending the devicetree will place it at the end of BSS.
Example SPL output without this patch:
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000142a1 fef40000 fef40000 00001000 2**4
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1 .u_boot_list 000014a4 fef542a8 fef542a8 000152a8 2**3
CONTENTS, ALLOC, LOAD, RELOC, DATA
2 .rodata 0000599c fef55760 fef55760 00016760 2**5
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
3 .data 00000970 fef5b100 fef5b100 0001c100 2**5
CONTENTS, ALLOC, LOAD, RELOC, DATA
4 .binman_sym_table 00000020 fef5ba70 fef5ba70 0001ca70 2**2
CONTENTS, ALLOC, LOAD, DATA
5 .bss 00000060 fef5baa0 fef5baa0 00000000 2**5
ALLOC
You can see that .bss is aligned to 2**5 (32 bytes). This is because of
the mallinfo struct in dlmalloc.c:
17 .bss.current_mallinfo 00000028 00000000 00000000 000004c0 2**5
ALLOC
In this case the size of u-boot-spl-nodtb.bin is 0x1ba90. This matches up
with the _image_binary_end symbol:
fef5ba90 g .binman_sym_table 00000000 _image_binary_end
But BSS starts 16 bytes later, at 0xfef5baa0, due to the 32-byte
alignment. So we must align _image_binary_end to a 32-byte boundary. This
forces the binary size to be 0x1baa0, i.e. ending at the start of bss, as
expected.
Note that gcc reports __BIGGEST_ALIGNMENT__ of 16 on this build, even
though it generates an object file with a member that requests 32-byte
alignment.
The current_mallinfo struct is 40 bytes in size. Increasing the struct to
68 bytes (i.e. just above a 64-byte boundary) does not cause the alignment
to go above 32 bytes. So it seems that 32 bytes is the maximum alignment
at present.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: add more details in the commit message to help people understand]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2021-01-24 17:06:05 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Force 32-byte alignment so that it lines up with the start of
|
|
|
|
* bss, which may have up to 32-byte alignment. This ensures
|
|
|
|
* that the end of the .bin file matches up with
|
|
|
|
* _image_binary_end or __bss_end - see board_fdt_blob_setup().
|
|
|
|
* The alignment of BSS depends on what is in it, so can range
|
|
|
|
* from 4 to 32 bytes.
|
|
|
|
*/
|
|
|
|
. = ALIGN(32);
|
2019-09-25 14:11:36 +00:00
|
|
|
}
|
2017-01-16 14:04:02 +00:00
|
|
|
|
|
|
|
_image_binary_end = .;
|
|
|
|
|
2021-01-24 17:06:06 +00:00
|
|
|
#if CONFIG_IS_ENABLED(SEPARATE_BSS)
|
2017-01-16 14:04:02 +00:00
|
|
|
. = 0x120000;
|
2021-01-24 17:06:06 +00:00
|
|
|
#endif
|
2017-01-16 14:04:02 +00:00
|
|
|
.bss (OVERLAY) : {
|
|
|
|
__bss_start = .;
|
|
|
|
*(.bss*)
|
|
|
|
*(COM*)
|
|
|
|
. = ALIGN(4);
|
|
|
|
__bss_end = .;
|
|
|
|
}
|
|
|
|
__bss_size = __bss_end - __bss_start;
|
|
|
|
|
|
|
|
/DISCARD/ : { *(.dynstr*) }
|
|
|
|
/DISCARD/ : { *(.dynamic*) }
|
|
|
|
/DISCARD/ : { *(.plt*) }
|
|
|
|
/DISCARD/ : { *(.interp*) }
|
|
|
|
/DISCARD/ : { *(.gnu*) }
|
2021-06-18 07:09:30 +00:00
|
|
|
/DISCARD/ : { *(.note.gnu.property) }
|
2017-01-16 14:04:02 +00:00
|
|
|
|
2019-04-26 03:58:53 +00:00
|
|
|
#if defined(CONFIG_SPL_X86_16BIT_INIT) || defined(CONFIG_TPL_X86_16BIT_INIT)
|
2017-01-16 14:04:02 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
|
|
|
}
|