From a8dc33253472328f2af04973575f26e9106db1c3 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 21 Dec 2011 08:53:02 -0800
Subject: [PATCH] config: Always use GNU ld

This patch makes sure that we always use the GNU ld. u-boot uses certain
construct e.g. OVERLAY which are not implemented in gold therefore it
always needs GNU ld for linking. It works well if default linker in
toolchain is GNU ld but in some cases we can have gold to be the
default linker and also ship GNU ld but not as default in such cases
its called $(PREFIX)ld.bfd, with this patch we make sure that if
$(PREFIX)ld.bfd exists than we use that for our ld. This way it
does not matter what the default ld is.

Upstream-status: Pending

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 config.mk |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/config.mk b/config.mk
index ddaa477..139dfa0 100644
--- a/config.mk
+++ b/config.mk
@@ -126,11 +126,13 @@ cc-option = $(strip $(if $(findstring $1,$(CC_OPTIONS)),$1,\
 		$(if $(call cc-option-sys,$1),$1,$2)))
 endif
 
+exists_bfd_ld = $(shell if $(CROSS_COMPILE)ld.bfd -v > /dev/null 2>&1; \
+		then echo "$(1)"; else echo "$(2)"; fi; )
 #
 # Include the make variables (CC, etc...)
 #
 AS	= $(CROSS_COMPILE)as
-LD	= $(CROSS_COMPILE)ld
+LD	= $(call exists_bfd_ld, "$(CROSS_COMPILE)ld.bfd", "$(CROSS_COMPILE)ld")
 CC	= $(CROSS_COMPILE)gcc
 CPP	= $(CC) -E
 AR	= $(CROSS_COMPILE)ar
-- 
1.7.9.1

