public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] Makefile: Fix linking with modern binutils
@ 2016-12-16  4:53 Joel Stanley
  2016-12-26 18:07 ` Tom Rini
  2017-01-12  9:19 ` Sjoerd Simons
  0 siblings, 2 replies; 8+ messages in thread
From: Joel Stanley @ 2016-12-16  4:53 UTC (permalink / raw)
  To: u-boot

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 reproduced 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 <joel@jms.id.au>
---
v2:
 - use ld-option to test for the flag instead of the version, as suggested by M?ns
 - update commit message with clarification from Alan

 Makefile | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Makefile b/Makefile
index dfed58bec661..c98a8361654a 100644
--- a/Makefile
+++ b/Makefile
@@ -793,6 +793,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
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-03-22 12:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-16  4:53 [U-Boot] [PATCH v2] Makefile: Fix linking with modern binutils Joel Stanley
2016-12-26 18:07 ` Tom Rini
2017-01-12  9:19 ` Sjoerd Simons
2017-03-21 13:59   ` Jon
2017-03-21 15:16     ` Tom Rini
2017-03-21 23:00       ` Nicholas Piggin
2017-03-21 23:13         ` Tom Rini
2017-03-22 12:53           ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox