From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 9 Apr 2017 20:33:58 +0200 Subject: [U-Boot] [PATCH v3] Makefile: Fix linking with modern binutils Message-ID: <20170409183358.5167-1-afaerber@suse.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de From: Joel Stanley Since Binutils 1a9ccd70f9a7[1] u-boot will not link targets that set CONFIG_SYS_TEXT_BASE=3D0 with the following error: LD u-boot arm-linux-gnueabi-ld.bfd: u-boot: Not enough room for program headers, try linking with -N arm-linux-gnueabi-ld.bfd: final link failed: Bad value The issue can be reproduced with the bad binutils and the rock2_defconfig target. This issue was also encountered by the powerpc kernel[2], with the fix being to pass --no-dynamic-linker for linkers newer than 2.26 when this flag was introduced. The option tells ld that the PIE or shared lib does not need loaded program headers. Ubuntu Zesty's Binutils 2.27.51.20161202 hits this error. [1] https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;a=3Dcommit;h= =3D1a9ccd70f9a7 [2] https://git.kernel.org/cgit/linux/kernel/git/powerpc/linux.git/commit/?= h=3Dnext&id=3Dff45000fcb56b5b0f1a14a865d3541746d838a0a Signed-off-by: Joel Stanley [AF: Apply to LDFLAGS_$(SPL_BIN) as well, suggested by Tom Rini] Signed-off-by: Andreas F=C3=A4rber --- Makefile | 4 ++++ scripts/Makefile.spl | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Makefile b/Makefile index ca7d60d..09b597d 100644 --- a/Makefile +++ b/Makefile @@ -805,6 +805,10 @@ ALL-y +=3D $(CONFIG_BUILD_TARGET:"%"=3D%) endif =20 LDFLAGS_u-boot +=3D $(LDFLAGS_FINAL) + +# Avoid 'Not enough room for program headers' error on binutils 2.28 onwar= ds. +LDFLAGS_u-boot +=3D $(call ld-option, --no-dynamic-linker) + ifneq ($(CONFIG_SYS_TEXT_BASE),) LDFLAGS_u-boot +=3D -Ttext $(CONFIG_SYS_TEXT_BASE) endif diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index 760acee..eb24292 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -291,6 +291,10 @@ $(obj)/u-boot-x86-16bit-spl.bin: $(obj)/u-boot-spl FOR= CE $(call if_changed,objcopy) =20 LDFLAGS_$(SPL_BIN) +=3D -T u-boot-spl.lds $(LDFLAGS_FINAL) + +# Avoid 'Not enough room for program headers' error on binutils 2.28 onwar= ds. +LDFLAGS_$(SPL_BIN) +=3D $(call ld-option, --no-dynamic-linker) + ifneq ($(CONFIG_SPL_TEXT_BASE),) LDFLAGS_$(SPL_BIN) +=3D -Ttext $(CONFIG_SPL_TEXT_BASE) endif --=20 2.10.2