arm-none-eabi-ld.bfd: u-boot: error: PHDR segment not covered by LOAD segment
编译u-boot在最后链接时遇到上述错误,一般认为是编译器版本不匹配导致。但是尝试切换了好几个编译器版本还是有这个问题。网上搜索到如下链接:
error: PHDR segment not covered by LOAD segment
This isn’t a binutils bug, unless you believe that “PHDR segment not covered by LOAD segment” should not cause a link error. I think the ELF standard is quite clear: “PT_PHDR … may occur only if the program header table is part of the memory image of the program”
binutils-2.30, 2.31, 2.32 and 2.33 all generate a PHDR that isn’t loaded by any LOAD segment, but the code checking for that problem was ineffective. This needs fixing in the linker script used by the project, or since it seems like the binary being generated is never meant to run directly on a glibc system, by linking with --no-dynamic-linker
大概意思是说这个错误提示是符合ELF标准的,如果要忽略这个错误,需要修改连接脚本或者在链接时增加“–no-dynamic-linker”参数。对u-boot顶层目录的Makefile做如下修改后链接通过:
724 LDFLAGS_u-boot += $(LDFLAGS_FINAL)
725 LDFLAGS_u-boot += $(call ld-option, --no-dynamic-linker)
726 ifneq ($(CONFIG_SYS_TEXT_BASE),)
727 LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
728 endif