Makefile: Fix linking with modern binutils
PATCH v2 1/1 Makefile: Fix linking with modern binutils
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
---
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(+)
Makefile +4 -0
@@ -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
Signature · 1 line
2.11.0
PATCH v2 1/1 Makefile: Fix linking with modern binutils
Quoted 34 lines · Joel Stanley
Since Binutils 1a9ccd70f9a7[1] u-boot will not link targets that set
CONFIG_SYS_TEXT_BASE=0with 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 valueThe issue can reproduced the bad binutils and the
rock2_defconfigtarget.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=ff45000fcb56b5b0f1a14a865d3541746d838a0aSigned-off-by Joel Stanley <[email protected]>---
v2:
- use ld-option to test for the flag instead of the version, as suggested by M?ns
- update commit message with clarification from AlanMakefile | 4 ++++ 1 file changed, 4 insertions(+)Makefile +0
-0
Makefile ALL-y += $(CONFIG_BUILD_TARGET:"%"=%) · line 802
Quoted 10 lines
Makefile +4
-0@@ -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
I had to think about this a bit and poke around. I think we need to be adjusting LDFLAGS_$(SPL_BIN) in scripts/Makefile.spl for safety here as well since if CONFIG_SPL_TEXT_BASE=0 (which seems just as possible as CONFIG_SYS_TEXT_BASE=0) we would hit the same condition. Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161226/acfa2bb4/attachment.sig>
PATCH v2 1/1 Makefile: Fix linking with modern binutils
In reply to Joel StanleyTested on current Debian unstable:
GNU ld (GNU Binutils for Debian) 2.27.90.20170109
Quoted 53 lines · Joel Stanley
Since Binutils 1a9ccd70f9a7[1] u-boot will not link targets that set
CONFIG_SYS_TEXT_BASE=0with 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 valueThe issue can reproduced the bad binutils and the
rock2_defconfigtarget.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/co
mmit/?h=next&id=ff45000fcb56b5b0f1a14a865d3541746d838a0aSigned-off-by Joel Stanley <[email protected]>---
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(+)Makefile +0
-0@@ -793,6 +793,10 @@ ALL-y += $(CONFIG_BUILD_TARGET:"%"=%)?endif
?
?LDFLAGS_u-boot += $(LDFLAGS_FINAL)Makefile +2
-0+ +# Avoid 'Not enough room for program headers' error on binutils 2.28onwards.
Makefile +2
-0+LDFLAGS_u-boot += $(call ld-option, --no-dynamic-linker) +?ifneq ($(CONFIG_SYS_TEXT_BASE),)
?LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
?endif
Signature · 2 lines
Sjoerd Simons Collabora Ltd.
PATCH v2 1/1 Makefile: Fix linking with modern binutils
Likewise tested on Fedora rawhide with: binutils-2.28-5.fc27
This patch allows our distro u-boot builds to succeed. +1
Quoted 67 lines · Sjoerd Simons
Tested on current Debian unstable:
GNU ld (GNU Binutils for Debian) 2.27.90.20170109Tested-by Sjoerd Simons <[email protected]>Quoted 48 lines · Joel Stanley
Since Binutils 1a9ccd70f9a7[1] u-boot will not link targets that set
CONFIG_SYS_TEXT_BASE=0with 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 valueThe issue can reproduced the bad binutils and the
rock2_defconfigtarget.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/co
mmit/?h=next&id=ff45000fcb56b5b0f1a14a865d3541746d838a0aSigned-off-by Joel Stanley <[email protected]>---
v2:
- use ld-option to test for the flag instead of the version, as
suggested by MÃ¥ns
- update commit message with clarification from AlanMakefile | 4 ++++ 1 file changed, 4 insertions(+)Makefile +2
-0@@ -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.28onwards.
Makefile ALL-y += $(CONFIG_BUILD_TARGET:"%"=%) · line 802
Quoted 5 lines
Makefile +2
-0+LDFLAGS_u-boot += $(call ld-option, --no-dynamic-linker) + ifneq ($(CONFIG_SYS_TEXT_BASE),) LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE) endif--
Sjoerd Simons
Collabora Ltd.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Signature · 1 line
-Jon Disnard
PATCH v2 1/1 Makefile: Fix linking with modern binutils
Quoted 5 lines · Jon
Likewise tested on Fedora rawhide with: binutils-2.28-5.fc27
This patch allows our distro u-boot builds to succeed. +1
Tested-by Jon Disnard <[email protected]>
Has anyone figure out what exactly is going on yet? It's pretty odd to me that linking at 0x0 (or not) is what's causing new binutils to throw this particular error out there. Thanks!
Quoted 81 lines
Quoted 67 lines · Sjoerd Simons
Tested on current Debian unstable:
GNU ld (GNU Binutils for Debian) 2.27.90.20170109Tested-by Sjoerd Simons <[email protected]>Quoted 48 lines · Joel Stanley
Since Binutils 1a9ccd70f9a7[1] u-boot will not link targets that set
CONFIG_SYS_TEXT_BASE=0with 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 valueThe issue can reproduced the bad binutils and the
rock2_defconfigtarget.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/co
mmit/?h=next&id=ff45000fcb56b5b0f1a14a865d3541746d838a0aSigned-off-by Joel Stanley <[email protected]>---
v2:
- use ld-option to test for the flag instead of the version, as
suggested by MÃ¥ns
- update commit message with clarification from AlanMakefile | 4 ++++ 1 file changed, 4 insertions(+)Makefile +2
-0@@ -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.28onwards.
Makefile ALL-y += $(CONFIG_BUILD_TARGET:"%"=%) · line 802
Quoted 5 lines
Makefile +2
-0+LDFLAGS_u-boot += $(call ld-option, --no-dynamic-linker) + ifneq ($(CONFIG_SYS_TEXT_BASE),) LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE) endif--
Sjoerd Simons
Collabora Ltd.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-bootSignature · 5 lines
-Jon Disnard _______________________________________________ U-Boot mailing list U-Boot at lists.denx.de https://lists.denx.de/listinfo/u-boot
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170321/7c5e7140/attachment.sig>
PATCH v2 1/1 Makefile: Fix linking with modern binutils
Quoted 11 lines · On Tue, 21 Mar 2017 11:16:50 -0400 Tom Rini <[email protected]> wrote:
Quoted 5 lines · Jon
Likewise tested on Fedora rawhide with: binutils-2.28-5.fc27
This patch allows our distro u-boot builds to succeed. +1
Tested-by Jon Disnard <[email protected]>Has anyone figure out what exactly is going on yet? It's pretty odd to me that linking at
0x0(or not) is what's causing new binutils to throw this particular error out there. Thanks!
Some discussion from binutils developers is here:
PATCH v2 1/1 Makefile: Fix linking with modern binutils
Quoted 11 lines · Nicholas Piggin
Quoted 8 lines · On Tue, 21 Mar 2017 11:16:50 -0400 Tom Rini <[email protected]> wrote:
Quoted 5 lines · Jon
Likewise tested on Fedora rawhide with: binutils-2.28-5.fc27
This patch allows our distro u-boot builds to succeed. +1
Tested-by Jon Disnard <[email protected]>
Quoted 7 lines
Quoted 3 lines
Has anyone figure out what exactly is going on yet? It's pretty odd to me that linking at
0x0(or not) is what's causing new binutils to throw this particular error out there. Thanks!Some discussion from binutils developers is here:
That in turn seems to point to
https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id=ff45000fcb56b5b0f1a14a865d3541
as an example of how to correct the problem (what U-Boot is doing), and we should make a patch similar to that it seems. Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170321/d9352647/attachment.sig>
PATCH v2 1/1 Makefile: Fix linking with modern binutils
Quoted 16 lines · Tom Rini
Quoted 15 lines · Nicholas Piggin
Quoted 11 lines · On Tue, 21 Mar 2017 11:16:50 -0400 Tom Rini <[email protected]> wrote:
Quoted 5 lines · Jon
Likewise tested on Fedora rawhide with: binutils-2.28-5.fc27
This patch allows our distro u-boot builds to succeed. +1
Tested-by Jon Disnard <[email protected]>Has anyone figure out what exactly is going on yet? It's pretty odd to me that linking at
0x0(or not) is what's causing new binutils to throw this particular error out there. Thanks!
Quoted 8 lines
Quoted 3 lines
Some discussion from binutils developers is here:
That in turn seems to point to
https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id=ff45000fcb56b5b0f1a14a865d3541
as an example of how to correct the problem (what U-Boot is doing), and we should make a patch similar to that it seems. Thanks!
That is the correct solution. Nick's patch for
https://sourceware.org/bugzilla/show_bug.cgi?id=20815 isn't going to be reverted as the ELF standard is quite clear regarding PT_PHDR. Yes, there was a bug in the patch adding more space than needed, fixed 2016-11-30 with binutils git commit e9a38e0f528, but even after that patch more space is needed than before.
Signature · 2 lines
Alan Modra Australia Development Lab, IBM