[U-Boot] [BUG] Cannot build qemu-x86_64_defconfig

Simon Glass sjg at chromium.org
Tue May 22 23:29:44 UTC 2018


Hi Heinrich,

On 22 May 2018 at 13:29, Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
> Hello Simon,
>
> when I compile qemu-x86_64_defconfig on Debian the spl is close to 4GB
> large.
>
> These files shed some light:
>
> spl/u-boot-spl.lds
> ------------------
> OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
> OUTPUT_ARCH(i386)
> ENTRY(_start)
> SECTIONS
> {
>  . = 0xfffd0000;
>  __text_start = .;
>  .text : { *(.text*); }
>  . = ALIGN(4);
>  . = ALIGN(4);
>  .u_boot_list : {
>   KEEP(*(SORT(.u_boot_list*)));
>  }
>  . = ALIGN(4);
>  .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
>  . = ALIGN(4);
>  .data : { *(.data*) }
>  . = ALIGN(4);
>  __data_end = .;
>  __init_end = .;
>         _image_binary_end = .;
>  . = 0x120000;
>  .bss (OVERLAY) : {
>   __bss_start = .;
>   *(.bss*)
>   *(COM*)
>   . = ALIGN(4);
>   __bss_end = .;
>  }
>
>
> spl/u-boot-spl.map
> --------------------------
> Linker script and memory map
>
>                 0x00000000fffd0000                . = 0xfffd0000
>                 0x00000000fffd0000                __text_start = .
>
> .text           0x00000000fffd0000     0xa0a8
> ....
>                 0x00000000fffdc8b0                _image_binary_end = .
>                 0x0000000000120000                . = 0x120000
>
> .got            0x0000000000120000        0x4
>  .got           0x0000000000120000        0x4 arch/x86/cpu/start.o
>
>
>
>
> Two things are strange here:
>
> Why is SPL using 64bit addresses while the linker script is meant for 32bit?
>
> Why is CONFIG_SPL_TEXT_BASE defined in .config if it is ignored?
>
> These are some of the commands executed:
>
>   gcc -Wp,-MD,spl/net/.tftp.o.d  -nostdinc -isystem
> /usr/lib/gcc/x86_64-linux-gnu/7/include -Iinclude   -I./arch/x86/include
> -include ./include/linux/kconfig.h -D__KERNEL__ -D__UBOOT__
> -DCONFIG_SPL_BUILD -Wall -Wstrict-prototypes -Wno-format-security
> -fno-builtin -ffreestanding -fshort-wchar -Os -fno-stack-protector
> -fno-delete-null-pointer-checks -g -fstack-usage -Wno-format-nonliteral
> -Werror=date-time -ffunction-sections -fdata-sections -fno-strict-aliasing
> -fomit-frame-pointer -fno-toplevel-reorder -fno-dwarf2-cfi-asm -march=i386
> -m32 -mregparm=3 -D__I386__ -ffunction-sections -fvisibility=hidden -pipe
> -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(tftp)"
> -D"KBUILD_MODNAME=KBUILD_STR(tftp)" -c -o spl/net/tftp.o net/tftp.c
>    ld.bfd   -Bsymbolic -Bsymbolic-functions -m elf_i386 --emit-relocs -r -o
> spl/net/built-in.o spl/net/checksum.o spl/net/arp.o spl/net/bootp.o
> spl/net/eth-uclass.o spl/net/eth_common.o spl/net/net.o spl/net/ping.o
> spl/net/tftp.o
>   gcc -E -Wp,-MD,spl/.u-boot-spl.lds.d -D__KERNEL__ -D__UBOOT__
> -DCONFIG_SPL_BUILD  -fno-strict-aliasing -fomit-frame-pointer
> -fno-toplevel-reorder -fno-dwarf2-cfi-asm -march=i386 -m32 -mregparm=3
> -D__I386__  -ffunction-sections -fvisibility=hidden -pipe -Iinclude
> -I./arch/x86/include -include ./include/linux/kconfig.h  -nostdinc -isystem
> /usr/lib/gcc/x86_64-linux-gnu/7/include -DRESET_SEG_START=0xffff0000
> -DRESET_SEG_SIZE=0x10000 -DRESET_VEC_LOC=0xfffffff0 -DSTART_16=0xfffff800
> -DRESET_BASE="CONFIG_SYS_TEXT_BASE + (CONFIG_SYS_MONITOR_LEN -
> RESET_SEG_SIZE)" -include ./include/u-boot/u-boot.lds.h -include
> ./include/config.h -DCPUDIR=arch/x86/cpu  -ansi -D__ASSEMBLY__ -x
> assembler-with-cpp -P -o spl/u-boot-spl.lds arch/x86/cpu/u-boot-spl.lds
>   (cd spl && ld.bfd   -Bsymbolic -Bsymbolic-functions -m elf_i386
> --emit-relocs -T u-boot-spl.lds  --gc-sections  -Bstatic --gc-sections
> --no-dynamic-linker -Ttext 0xfffd0000 arch/x86/cpu/start.o
> arch/x86/cpu/start16.o arch/x86/cpu/resetvec.o --start-group
> arch/x86/cpu/built-in.o arch/x86/lib/built-in.o
> board/emulation/qemu-x86/built-in.o common/spl/built-in.o
> common/init/built-in.o common/built-in.o cmd/built-in.o env/built-in.o
> lib/built-in.o drivers/built-in.o dts/built-in.o fs/built-in.o
> net/built-in.o  --end-group  arch/x86/lib/lib.a -Map u-boot-spl.map -o
> u-boot-spl)
>   objcopy   -O binary -R .start16 -R .resetvec spl/u-boot-spl
> spl/u-boot-spl-nodtb.bin
>   cp dts/dt-spl.dtb spl/u-boot-spl.dtb
>
>
> Observe: ld.bfd -Ttext 0xfffd0000
> This value is from include/configs/qemu-x86.h
>
> On the other side we have spl/u-boot-spl.lds with
> . = 0x120000;
>
> This results in the size close to 4GB of the generated SPL image.
>
> The change below relsolves the problem on qemu-x86_64_defconfig but I am not
> sure why the value 0x1200000 was introduced first hand in your patch
> 3c2dd537c772 ("x86: Add a link script for SPL")

Looks wrong to me.

It is the offset from the start of the SPI flash, but it should in
fact be a memory address. So I think you need to change it so that the
address is 0x1200000 from the beginning of SPI flash. which starts at
2^32 - <size of spi flash>

>
> diff --git a/arch/x86/cpu/u-boot-spl.lds b/arch/x86/cpu/u-boot-spl.lds
> index 8a38d58f123..75be5cf5db8 100644
> --- a/arch/x86/cpu/u-boot-spl.lds
> +++ b/arch/x86/cpu/u-boot-spl.lds
> @@ -39,7 +39,7 @@ SECTIONS
>
>          _image_binary_end = .;
>
> -       . = 0x120000;
> +       . = 0xffff0000;
>         .bss (OVERLAY) : {
>                 __bss_start = .;
>                 *(.bss*)
>
> Could you, please, help to resolve the issue.

Your patch looks better, but do make sure that things end up in the
right place. SPL needs its own place in the image.

Regards,
Simon


More information about the U-Boot mailing list