From patchwork Sun Apr 9 18:33:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 97056 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp1084264qgd; Sun, 9 Apr 2017 11:34:14 -0700 (PDT) X-Received: by 10.28.51.140 with SMTP id z134mr7339393wmz.55.1491762854046; Sun, 09 Apr 2017 11:34:14 -0700 (PDT) Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 88si12048214wrr.155.2017.04.09.11.34.13; Sun, 09 Apr 2017 11:34:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 580D1C21D30; Sun, 9 Apr 2017 18:34:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 79CCEC21C30; Sun, 9 Apr 2017 18:34:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7D1B3C21C30; Sun, 9 Apr 2017 18:34:08 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id E96FEC21C2D for ; Sun, 9 Apr 2017 18:34:07 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 77772AC1D; Sun, 9 Apr 2017 18:34:07 +0000 (UTC) From: =?utf-8?q?Andreas_F=C3=A4rber?= To: u-boot@lists.denx.de Date: Sun, 9 Apr 2017 20:33:58 +0200 Message-Id: <20170409183358.5167-1-afaerber@suse.de> X-Mailer: git-send-email 2.10.2 MIME-Version: 1.0 Cc: Tom Rini , =?utf-8?q?Andreas_F=C3=A4rber?= Subject: [U-Boot] [PATCH v3] Makefile: Fix linking with modern binutils X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Joel Stanley Since Binutils 1a9ccd70f9a7[1] u-boot will not link targets that set CONFIG_SYS_TEXT_BASE=0 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=binutils-gdb.git;a=commit;h=1a9ccd70f9a7 [2] https://git.kernel.org/cgit/linux/kernel/git/powerpc/linux.git/commit/?h=next&id=ff45000fcb56b5b0f1a14a865d3541746d838a0a Signed-off-by: Joel Stanley [AF: Apply to LDFLAGS_$(SPL_BIN) as well, suggested by Tom Rini] Signed-off-by: Andreas Färber --- 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 += $(CONFIG_BUILD_TARGET:"%"=%) endif LDFLAGS_u-boot += $(LDFLAGS_FINAL) + +# Avoid 'Not enough room for program headers' error on binutils 2.28 onwards. +LDFLAGS_u-boot += $(call ld-option, --no-dynamic-linker) + ifneq ($(CONFIG_SYS_TEXT_BASE),) LDFLAGS_u-boot += -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 FORCE $(call if_changed,objcopy) LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL) + +# Avoid 'Not enough room for program headers' error on binutils 2.28 onwards. +LDFLAGS_$(SPL_BIN) += $(call ld-option, --no-dynamic-linker) + ifneq ($(CONFIG_SPL_TEXT_BASE),) LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE) endif