diff mbox

[U-Boot] common: Link with GCC instead of LD

Message ID 1351701168-7293-1-git-send-email-marex@denx.de
State Deferred
Delegated to: Tom Rini
Headers show

Commit Message

Marek Vasut Oct. 31, 2012, 4:32 p.m. UTC
Flip over from linking with LD to linking with GCC. This has some
long-term benefits, like easy path to enabling LTO.

Most of this patch is about passing parameters to the linker invoked
by GCC at the linking stage. This involves prefixing most of these with
-Wl,<param> . A few more adjustments had to be made though.

The LDFLAGS had to be extended by --build-id=none to prevent generation
of the .note.gnu.build-id section, which contains unique build-id we
don't care about. Moreover -nostdlib had to be added to LDFLAGS to link
properly without pulling in GCC libs during partial link.

The LDFLAGS_FINAL had to be augmented by -Wl,-allow-multiple-definition
to prevent GCC from complaining about multiple definitions of the register
containing global data.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
---
 Makefile                                       |    4 ++--
 arch/avr32/config.mk                           |    2 +-
 arch/blackfin/config.mk                        |    4 ++--
 arch/m68k/config.mk                            |    4 ++--
 arch/m68k/cpu/mcf5445x/config.mk               |    2 +-
 arch/m68k/cpu/mcf547x_8x/config.mk             |    2 +-
 arch/mips/config.mk                            |    4 ++--
 arch/mips/cpu/mips64/config.mk                 |    4 ++--
 arch/nds32/config.mk                           |    2 +-
 arch/nios2/config.mk                           |    2 +-
 arch/powerpc/config.mk                         |    2 +-
 arch/sh/config.mk                              |    4 ++--
 arch/x86/config.mk                             |    8 ++++----
 board/ait/cam_enc_4xx/config.mk                |    2 +-
 config.mk                                      |   15 +++++++--------
 examples/standalone/Makefile                   |    4 ++--
 nand_spl/board/amcc/acadia/Makefile            |    2 +-
 nand_spl/board/amcc/bamboo/Makefile            |    2 +-
 nand_spl/board/amcc/canyonlands/Makefile       |    2 +-
 nand_spl/board/amcc/kilauea/Makefile           |    2 +-
 nand_spl/board/amcc/sequoia/Makefile           |    2 +-
 nand_spl/board/freescale/mpc8313erdb/Makefile  |    2 +-
 nand_spl/board/freescale/mpc8315erdb/Makefile  |    2 +-
 nand_spl/board/freescale/mpc8536ds/Makefile    |    2 +-
 nand_spl/board/freescale/mpc8569mds/Makefile   |    2 +-
 nand_spl/board/freescale/mpc8572ds/Makefile    |    2 +-
 nand_spl/board/freescale/mx31pdk/Makefile      |    2 +-
 nand_spl/board/freescale/p1010rdb/Makefile     |    2 +-
 nand_spl/board/freescale/p1023rds/Makefile     |    2 +-
 nand_spl/board/freescale/p1_p2_rdb/Makefile    |    2 +-
 nand_spl/board/freescale/p1_p2_rdb_pc/Makefile |    2 +-
 nand_spl/board/karo/tx25/Makefile              |    2 +-
 nand_spl/board/samsung/smdk6400/Makefile       |    2 +-
 nand_spl/board/sheldon/simpc8313/Makefile      |    2 +-
 spl/Makefile                                   |    4 ++--
 35 files changed, 52 insertions(+), 53 deletions(-)

NOTE: It should mostly work, but _PLEASE_ test it properly. I definitelly
      can not run it on most of the affected platforms. Besides, it might
      still hit some build issues, it's not properly compiler-tested. Any
      additional fixes are welcome ;-)

NOTE: I detected code size being smaller by a few bytes, but then it might
      cause breakage, so I'd be really cautious here.

Comments

Andreas Bießmann Oct. 31, 2012, 7:51 p.m. UTC | #1
Dear Marek Vasut,

On 31.10.12 17:32, Marek Vasut wrote:
> Flip over from linking with LD to linking with GCC. This has some
> long-term benefits, like easy path to enabling LTO.
> 
> Most of this patch is about passing parameters to the linker invoked
> by GCC at the linking stage. This involves prefixing most of these with
> -Wl,<param> . A few more adjustments had to be made though.
> 
> The LDFLAGS had to be extended by --build-id=none to prevent generation
> of the .note.gnu.build-id section, which contains unique build-id we
> don't care about. Moreover -nostdlib had to be added to LDFLAGS to link
> properly without pulling in GCC libs during partial link.
> 
> The LDFLAGS_FINAL had to be augmented by -Wl,-allow-multiple-definition
> to prevent GCC from complaining about multiple definitions of the register
> containing global data.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Albert Aribaud <albert.u.boot@aribaud.net>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Mike Frysinger <vapier@gentoo.org>
> Cc: Tom Rini <trini@ti.com>
> Cc: Wolfgang Denk <wd@denx.de>
> ---

> 
> NOTE: It should mostly work, but _PLEASE_ test it properly. I definitelly
>       can not run it on most of the affected platforms. Besides, it might
>       still hit some build issues, it's not properly compiler-tested. Any
>       additional fixes are welcome ;-)
> 
> NOTE: I detected code size being smaller by a few bytes, but then it might
>       cause breakage, so I'd be really cautious here.
> 

<snip>

> diff --git a/config.mk b/config.mk
> index b7cd481..ec8cd6b 100644
> --- a/config.mk
> +++ b/config.mk
> @@ -137,9 +137,8 @@ binutils-version = $(shell $(SHELL) $(SRCTREE)/tools/binutils-version.sh $(AS))
>  #
>  AS	= $(CROSS_COMPILE)as
>  
> -# Always use GNU ld
> -LD	= $(shell if $(CROSS_COMPILE)ld.bfd -v > /dev/null 2>&1; \
> -		then echo "$(CROSS_COMPILE)ld.bfd"; else echo "$(CROSS_COMPILE)ld"; fi;)
> +# Link with GCC
> +LD	= $(CROSS_COMPILE)gcc

with this change we should also remove LD_VERSION_STRING from
$(VERSION_FILE). Currently it will call 'gcc -v' which will print
compile switches to stderr.

Compiled and runtime tested on avr32 atngw100mkii, on first sight it
seems sane.

Best regards

Andreas Bießmann
Marek Vasut Oct. 31, 2012, 8:52 p.m. UTC | #2
Dear Andreas Bießmann,

[...]

> > -# Always use GNU ld
> > -LD	= $(shell if $(CROSS_COMPILE)ld.bfd -v > /dev/null 2>&1; \
> > -		then echo "$(CROSS_COMPILE)ld.bfd"; else echo 
"$(CROSS_COMPILE)ld";
> > fi;) +# Link with GCC
> > +LD	= $(CROSS_COMPILE)gcc
> 
> with this change we should also remove LD_VERSION_STRING from
> $(VERSION_FILE). Currently it will call 'gcc -v' which will print
> compile switches to stderr.
> 
> Compiled and runtime tested on avr32 atngw100mkii, on first sight it
> seems sane.

Good catch. I added it to u-boot-testing/dm-gcclink branch already, but will 
repost after I get a bit more feedback.

Thanks!

Best regards,
Marek Vasut
Wolfgang Denk Oct. 31, 2012, 10:36 p.m. UTC | #3
Dear Marek Vasut,

In message <1351701168-7293-1-git-send-email-marex@denx.de> you wrote:
> Flip over from linking with LD to linking with GCC. This has some
> long-term benefits, like easy path to enabling LTO.

Could you please explain these supposed benefits in a bit more detail?
Please excuse my ignorance, but so far I see just added complexity,
but I don't see what it buys us.

Best regards,

Wolfgang Denk
Tom Rini Oct. 31, 2012, 10:48 p.m. UTC | #4
On Wed, Oct 31, 2012 at 11:36:18PM +0100, Wolfgang Denk wrote:

> Dear Marek Vasut,
> 
> In message <1351701168-7293-1-git-send-email-marex@denx.de> you wrote:
> > Flip over from linking with LD to linking with GCC. This has some
> > long-term benefits, like easy path to enabling LTO.
> 
> Could you please explain these supposed benefits in a bit more detail?
> Please excuse my ignorance, but so far I see just added complexity,
> but I don't see what it buys us.

Complexity is arguable.  Most projects don't call ld directly but let
gcc call ld.  Doing this brings us in line with what other projects do.
As an aside, from my time with CodeSourcery folks directly calling ld
was discouraged I swear, but I don't have some reference to back that
up.  Finally, as Marek said but didn't explain, this brings us a step
closer to being able to enable LTO (link time optimization) which may
(but we need to experiment) be beneficial in terms of size and
performance (since in short gcc re-decides things like positioning,
inlining based on the whole program state at link time).
Marek Vasut Oct. 31, 2012, 10:51 p.m. UTC | #5
Dear Wolfgang Denk,

> Dear Marek Vasut,
> 
> In message <1351701168-7293-1-git-send-email-marex@denx.de> you wrote:
> > Flip over from linking with LD to linking with GCC. This has some
> > long-term benefits, like easy path to enabling LTO.
> 
> Could you please explain these supposed benefits in a bit more detail?

Yes, thanks for the review (I really needed one from you on this)!

So, here comes the list:
1) It's cool to link with gcc, duh ;-)
2) You can enable LTO eventually -- long term plan -- which proved can shrink 
the code size a bit
3) Usage of LLVM/CLANG is now much more straightforward
4) Binutils usually lag behind the GCC development a bit, by using GCC to do the 
link, we can remedy this problem

But actually, the 2) is the most important part. LTO will hopefully help us 
optimize U-Boot for size even better than it is now. But that will still need 
much more research. So this is only a patch that shall prepare the groundwork 
for this further research.

> Please excuse my ignorance, but so far I see just added complexity,
> but I don't see what it buys us.
> 
> Best regards,
> 
> Wolfgang Denk

Best regards,
Marek Vasut
Wolfgang Denk Oct. 31, 2012, 11:28 p.m. UTC | #6
Dear Tom,

In message <20121031224825.GA24095@bill-the-cat> you wrote:
> 
> > > Flip over from linking with LD to linking with GCC. This has some
> > > long-term benefits, like easy path to enabling LTO.
> > 
> > Could you please explain these supposed benefits in a bit more detail?
> > Please excuse my ignorance, but so far I see just added complexity,
> > but I don't see what it buys us.
>
> Complexity is arguable.  Most projects don't call ld directly but let
> gcc call ld.  Doing this brings us in line with what other projects do.

The question is if there are good reasons for these other projects
doing it this way - I tend to belive most projects just don't care
that much about specific linker options - on the other hand, for bare
metal code like U-Boot it is essential to know _exactly_ how the
linker is being run.  Depending here on the GCC framework which may
meddle with options in subtle ways that are not always perfectly
understood is something that needs thorough consideration.

> As an aside, from my time with CodeSourcery folks directly calling ld
> was discouraged I swear, but I don't have some reference to back that

I agree with this for "normal programs", i. e. standard conformng code
in a standard C environment, where correct use of the appropriate GCC
runtime environment and standard libraries is essential.  But none of
this applies to U-Boot.

> up.  Finally, as Marek said but didn't explain, this brings us a step
> closer to being able to enable LTO (link time optimization) which may
> (but we need to experiment) be beneficial in terms of size and
> performance (since in short gcc re-decides things like positioning,
> inlining based on the whole program state at link time).

I do understand this argument.  But unless I've seen this working in a
real test case I don't feel conficent to acept this.  Changing "things
like positioning" etc. is something we usually do now want to allow
here - instead, we want to have absolute control over such things.

Until I see any such things implemented (and working), this patch
falls for me in the group of "unused code" - and given the added
complexity (which is definitely non-trivial) it takes me a lot of
discipline not to NAK this right away.

Best regards,

Wolfgang Denk
Wolfgang Denk Oct. 31, 2012, 11:32 p.m. UTC | #7
Dear Marek,

In message <201210312351.35977.marex@denx.de> you wrote:
> 
> > Could you please explain these supposed benefits in a bit more detail?
> 
> Yes, thanks for the review (I really needed one from you on this)!
> 
> So, here comes the list:
> 1) It's cool to link with gcc, duh ;-)

Is it - and why exactly?

> 2) You can enable LTO eventually -- long term plan -- which proved can shrink 
> the code size a bit

Do you have a workign example?  You know, we don;t like adding dead
code...

> 3) Usage of LLVM/CLANG is now much more straightforward

Please elucidate?

> 4) Binutils usually lag behind the GCC development a bit, by using GCC to do the 
> link, we can remedy this problem

Grrrrghhhg.  I lost you here.  By not calling ld directly (where we
know exactly what we are doing), but through a (somewhat unknown) GCC
framework, we can magicly adjust any (claimed - by you) version
differences?   I cannot parse this.

> But actually, the 2) is the most important part. LTO will hopefully help us 
> optimize U-Boot for size even better than it is now. But that will still need 
> much more research. So this is only a patch that shall prepare the groundwork 
> for this further research.

As is, it's just unused or dead code that adds a lot of complexity and
buys nothing.  Please submit as part of a patch series that makes
successfull (and tested) use of LTO.


Best regards,

Wolfgang Denk
Tom Rini Oct. 31, 2012, 11:39 p.m. UTC | #8
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/31/12 16:28, Wolfgang Denk wrote:
> Dear Tom,
> 
> In message <20121031224825.GA24095@bill-the-cat> you wrote:
>> 
>>>> Flip over from linking with LD to linking with GCC. This has 
>>>> some long-term benefits, like easy path to enabling LTO.
>>> 
>>> Could you please explain these supposed benefits in a bit more 
>>> detail? Please excuse my ignorance, but so far I see just
>>> added complexity, but I don't see what it buys us.
>> 
>> Complexity is arguable.  Most projects don't call ld directly
>> but let gcc call ld.  Doing this brings us in line with what
>> other projects do.
> 
> The question is if there are good reasons for these other projects
>  doing it this way - I tend to belive most projects just don't care
>  that much about specific linker options - on the other hand, for 
> bare metal code like U-Boot it is essential to know _exactly_ how 
> the linker is being run.  Depending here on the GCC framework
> which may meddle with options in subtle ways that are not always 
> perfectly understood is something that needs thorough 
> consideration.

Right.  The flip side to this is that the Linux kernel also uses gcc
to link, depends on gcc doing what it's told and telling the linker
what we want and has a tad more clout than we do when problems arise.
 If we switch and we find a problem, it's likely the kernel can or
does fail as well, which can be useful in getting people to address bugs.

[snip]
>> up.  Finally, as Marek said but didn't explain, this brings us a 
>> step closer to being able to enable LTO (link time optimization) 
>> which may (but we need to experiment) be beneficial in terms of 
>> size and performance (since in short gcc re-decides things like 
>> positioning, inlining based on the whole program state at link 
>> time).
> 
> I do understand this argument.  But unless I've seen this working 
> in a real test case I don't feel conficent to acept this.
> Changing "things like positioning" etc. is something we usually do
> now want to allow here - instead, we want to have absolute control
> over such things.
> 
> Until I see any such things implemented (and working), this patch 
> falls for me in the group of "unused code" - and given the added 
> complexity (which is definitely non-trivial) it takes me a lot of 
> discipline not to NAK this right away.

I appreciate your restraint here.  And, I agree that we don't need to
bring this in until we've investigated LTO and found it brings
benefits to the project.  It could indeed mess up and not obey the
times we've re-ordered code segments out of necessity rather than
space optimization.  But it might also let us stop playing those games
and get better results with all of the text together.

- -- 
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQIcBAEBAgAGBQJQkbalAAoJENk4IS6UOR1WdMIP/RjcFHw0kvi17TJRvNq8sPzb
kEODknbkE/tw8GFa0QA3+Cp4AsmadDPA/KM4jfOypR3lpWey5oI25I5RRdnHvXbT
Cagp8Oyg9rqjD+VS8iVYIFMGy3/ivvwXzgysQlqhF/KFx07kcu+g2EG9rgZEP3cA
rNdZKG5NT1aq8iiu28Il1vY/nnYtDFBi1undhOzVi9pOlt5k9Vc3VhHB+3ZIzzrf
9ptvo1ORObQ1M3BISA7dZfYdITUElbqDQKLbqldUbWbBN/gaOsNvGWaAtCjOgoXo
O70mqe7Tqjl8p7S55jCBrZPuxNOHOs5HSOt/Q+o164RFXspvXV5fL9dX7HWE3wtL
y4asCLS3rmLkuY14dn7eXP3Mg4ZumtJST06SWfYYsAqD8EfFWfdye1gMpLUMwrKR
kWsmflyQbaXqAMhxdbhHeYPA3Spmwm0Ebgf8MjvZTpzWjyvKKsNm8Cgszr5n9Crz
YLIYFqG1NIopZ3SewsWckOkGbC9RatpfydDhbZ/F+u/oGu1jbWOLyuvUkTN75E/r
YPN5CZ7EOSVCuKz5NeUwuTdnVQqPxO1Hq3mtvxfbRIPDlEQ4XO5PdKqj+iwjqTyy
+0NYXyFSSf5ulPY7YeAHEj12kTBLvDD2QMgK0AHgMJ42N1ir4PQJrfP4DwZKxUdm
NHX2XryIFZs+C4hCiCgq
=q/MN
-----END PGP SIGNATURE-----
Marek Vasut Oct. 31, 2012, 11:45 p.m. UTC | #9
Dear Wolfgang Denk,

> Dear Marek,
> 
> In message <201210312351.35977.marex@denx.de> you wrote:
> > > Could you please explain these supposed benefits in a bit more detail?
> > 
> > Yes, thanks for the review (I really needed one from you on this)!
> > 
> > So, here comes the list:
> > 1) It's cool to link with gcc, duh ;-)
> 
> Is it - and why exactly?

It's all the rage now (better ignore this point) ;-)

> > 2) You can enable LTO eventually -- long term plan -- which proved can
> > shrink the code size a bit
> 
> Do you have a workign example?  You know, we don;t like adding dead
> code...

We've been digging with Albert, but nothing we can release just yet. This is a 
groundwork patch.

> > 3) Usage of LLVM/CLANG is now much more straightforward
> 
> Please elucidate?

Now you can simply replace gcc with clang and that _should_ work. Sure, I expect 
more work will be needed here, but this patch gives you all the ground to do 
that.

> > 4) Binutils usually lag behind the GCC development a bit, by using GCC to
> > do the link, we can remedy this problem
> 
> Grrrrghhhg.  I lost you here.  By not calling ld directly (where we
> know exactly what we are doing), but through a (somewhat unknown) GCC
> framework, we can magicly adjust any (claimed - by you) version
> differences?   I cannot parse this.

GCC can do all the optimization magic (LTO ...) and then just let linker do the 
linking.

> > But actually, the 2) is the most important part. LTO will hopefully help
> > us optimize U-Boot for size even better than it is now. But that will
> > still need much more research. So this is only a patch that shall
> > prepare the groundwork for this further research.
> 
> As is, it's just unused or dead code that adds a lot of complexity and
> buys nothing.  Please submit as part of a patch series that makes
> successfull (and tested) use of LTO.

No, I won't, I don't have that part ready yet.

Besides, the sandbox target already uses gcc linking. Shall we also convert it 
to use LD instead then ?

Best regards,
Marek Vasut
Wolfgang Denk Nov. 1, 2012, midnight UTC | #10
Dear Marek,

In message <201211010045.40817.marex@denx.de> you wrote:
> 
> > > 2) You can enable LTO eventually -- long term plan -- which proved can
> > > shrink the code size a bit
> > 
> > Do you have a workign example?  You know, we don;t like adding dead
> > code...
> 
> We've been digging with Albert, but nothing we can release just yet. This is a 
> groundwork patch.

Dead code, which will not be added, then.

> > > 3) Usage of LLVM/CLANG is now much more straightforward
> > 
> > Please elucidate?
> 
> Now you can simply replace gcc with clang and that _should_ work. Sure, I expect 
> more work will be needed here, but this patch gives you all the ground to do 
> that.

I. e. it's all speculation only?  Such doesn't by much...

> > > 4) Binutils usually lag behind the GCC development a bit, by using GCC to
> > > do the link, we can remedy this problem
> > 
> > Grrrrghhhg.  I lost you here.  By not calling ld directly (where we
> > know exactly what we are doing), but through a (somewhat unknown) GCC
> > framework, we can magicly adjust any (claimed - by you) version
> > differences?   I cannot parse this.
> 
> GCC can do all the optimization magic (LTO ...) and then just let linker do the 
> linking.

You were talking about "Binutils usually lag behind the GCC
development".  Now I would like you to explain how "by using GCC to do
the link, we can remedy this problem".

You fail to provide any such explanation.

> > > But actually, the 2) is the most important part. LTO will hopefully help
> > > us optimize U-Boot for size even better than it is now. But that will
> > > still need much more research. So this is only a patch that shall
> > > prepare the groundwork for this further research.
> > 
> > As is, it's just unused or dead code that adds a lot of complexity and
> > buys nothing.  Please submit as part of a patch series that makes
> > successfull (and tested) use of LTO.
> 
> No, I won't, I don't have that part ready yet.

Then please _re_submit when you have the rest that actually needs any
such changes.

> Besides, the sandbox target already uses gcc linking. Shall we also convert it 
> to use LD instead then ?

Note that sandbox is actually very different, in such as it really
tried to implement a standard onforming C program, running in a
standard C execution environment.  This is totally different from the
bare metal code we have on any real hardware.

Best regards,

Wolfgang Denk
Marek Vasut Nov. 1, 2012, 12:06 a.m. UTC | #11
Dear Wolfgang Denk,

> Dear Marek,
> 
> In message <201211010045.40817.marex@denx.de> you wrote:
> > > > 2) You can enable LTO eventually -- long term plan -- which proved
> > > > can shrink the code size a bit
> > > 
> > > Do you have a workign example?  You know, we don;t like adding dead
> > > code...
> > 
> > We've been digging with Albert, but nothing we can release just yet. This
> > is a groundwork patch.
> 
> Dead code, which will not be added, then.
[...]

Ok, let's end the discussion here then. Patch is NAK'ed and I'll resubmit it 
when I have something with LTO.

Best regards,
Marek Vasut
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 2fe1490..d6b3433 100644
--- a/Makefile
+++ b/Makefile
@@ -539,8 +539,8 @@  GEN_UBOOT = \
 		sed  -n -e 's/.*\($(SYM_PREFIX)_u_boot_list_.*\)/-u\1/p'|sort|uniq`;\
 		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
 			$$UNDEF_LST $(__OBJS) \
-			--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
-			-Map u-boot.map -o u-boot
+			-Wl,--start-group $(__LIBS) -Wl,--end-group \
+			$(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
 endif
 
 $(obj)u-boot:	depend \
diff --git a/arch/avr32/config.mk b/arch/avr32/config.mk
index a751a3d..151f232 100644
--- a/arch/avr32/config.mk
+++ b/arch/avr32/config.mk
@@ -28,4 +28,4 @@  CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000
 PLATFORM_RELFLAGS	+= -ffixed-r5 -fPIC -mno-init-got -mrelax
 PLATFORM_RELFLAGS	+= -ffunction-sections -fdata-sections
 
-LDFLAGS_u-boot		= --gc-sections --relax
+LDFLAGS_u-boot		= -Wl,--gc-sections -Wl,--relax
diff --git a/arch/blackfin/config.mk b/arch/blackfin/config.mk
index 3595aa2..cbfba5f 100644
--- a/arch/blackfin/config.mk
+++ b/arch/blackfin/config.mk
@@ -37,8 +37,8 @@  CONFIG_BFIN_BOOT_MODE := $(strip $(subst ",,$(CONFIG_BFIN_BOOT_MODE)))
 PLATFORM_RELFLAGS += -ffixed-P3 -fomit-frame-pointer -mno-fdpic
 PLATFORM_CPPFLAGS += -DCONFIG_BLACKFIN
 
-LDFLAGS_FINAL += --gc-sections
-LDFLAGS += -m elf32bfin
+LDFLAGS_FINAL += -Wl,--gc-sections
+LDFLAGS += -Wl,-m elf32bfin
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
 
 PLATFORM_RELFLAGS += -mcpu=$(CONFIG_BFIN_CPU)
diff --git a/arch/m68k/config.mk b/arch/m68k/config.mk
index 11ba334..2e5adb9 100644
--- a/arch/m68k/config.mk
+++ b/arch/m68k/config.mk
@@ -26,6 +26,6 @@  CROSS_COMPILE ?= m68k-elf-
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x20000
 
 PLATFORM_CPPFLAGS += -DCONFIG_M68K -D__M68K__
-PLATFORM_LDFLAGS  += -n
+PLATFORM_LDFLAGS  += -Wl,-n
 PLATFORM_RELFLAGS              += -ffunction-sections -fdata-sections
-LDFLAGS_FINAL                  += --gc-sections
+LDFLAGS_FINAL                  += -Wl,--gc-sections
diff --git a/arch/m68k/cpu/mcf5445x/config.mk b/arch/m68k/cpu/mcf5445x/config.mk
index 0c48783..bd216a9 100644
--- a/arch/m68k/cpu/mcf5445x/config.mk
+++ b/arch/m68k/cpu/mcf5445x/config.mk
@@ -38,6 +38,6 @@  endif
 
 ifneq (,$(findstring -linux-,$(shell $(CC) --version)))
 ifneq (,$(findstring GOT,$(shell $(LD) --help)))
-PLATFORM_LDFLAGS += --got=single
+PLATFORM_LDFLAGS += -Wl,--got=single
 endif
 endif
diff --git a/arch/m68k/cpu/mcf547x_8x/config.mk b/arch/m68k/cpu/mcf547x_8x/config.mk
index 02fce5d..00907d3 100644
--- a/arch/m68k/cpu/mcf547x_8x/config.mk
+++ b/arch/m68k/cpu/mcf547x_8x/config.mk
@@ -28,6 +28,6 @@  PLATFORM_CPPFLAGS += -mcpu=5485 -fPIC
 
 ifneq (,$(findstring -linux-,$(shell $(CC) --version)))
 ifneq (,$(findstring GOT,$(shell $(LD) --help)))
-PLATFORM_LDFLAGS += --got=single
+PLATFORM_LDFLAGS += -Wl,--got=single
 endif
 endif
diff --git a/arch/mips/config.mk b/arch/mips/config.mk
index de9140b..c21d313 100644
--- a/arch/mips/config.mk
+++ b/arch/mips/config.mk
@@ -63,6 +63,6 @@  PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__
 #
 PLATFORM_CPPFLAGS		+= -G 0 -mabicalls -fpic $(ENDIANNESS)
 PLATFORM_CPPFLAGS		+= -msoft-float
-PLATFORM_LDFLAGS		+= -G 0 -static -n -nostdlib $(ENDIANNESS)
+PLATFORM_LDFLAGS		+= -G 0 -static -Wl,-n $(ENDIANNESS)
 PLATFORM_RELFLAGS		+= -ffunction-sections -fdata-sections
-LDFLAGS_FINAL			+= --gc-sections
+LDFLAGS_FINAL			+= -Wl,--gc-sections
diff --git a/arch/mips/cpu/mips64/config.mk b/arch/mips/cpu/mips64/config.mk
index ebc1ceb..d9fbf27 100644
--- a/arch/mips/cpu/mips64/config.mk
+++ b/arch/mips/cpu/mips64/config.mk
@@ -32,9 +32,9 @@  MIPSFLAGS = -march=mips64
 PLATFORM_CPPFLAGS += $(MIPSFLAGS)
 PLATFORM_CPPFLAGS += -mabi=64 -DCONFIG_64BIT
 ifdef CONFIG_SYS_BIG_ENDIAN
-PLATFORM_LDFLAGS  += -m elf64btsmip
+PLATFORM_LDFLAGS  += -Wl,-m elf64btsmip
 else
-PLATFORM_LDFLAGS  += -m elf64ltsmip
+PLATFORM_LDFLAGS  += -Wl,-m elf64ltsmip
 endif
 
 CONFIG_STANDALONE_LOAD_ADDR ?= 0xffffffff80200000 -T mips64.lds
diff --git a/arch/nds32/config.mk b/arch/nds32/config.mk
index c589829..eccd2e6 100644
--- a/arch/nds32/config.mk
+++ b/arch/nds32/config.mk
@@ -32,4 +32,4 @@  PLATFORM_RELFLAGS	+= -fno-strict-aliasing -fno-common -mrelax
 PLATFORM_RELFLAGS	+= -gdwarf-2
 PLATFORM_CPPFLAGS	+= -DCONFIG_NDS32 -D__nds32__ -G0 -ffixed-10 -fpie
 
-LDFLAGS_u-boot		= --gc-sections --relax
+LDFLAGS_u-boot		= -Wl,--gc-sections -Wl,--relax
diff --git a/arch/nios2/config.mk b/arch/nios2/config.mk
index 7b03ed8..9f9f6ac 100644
--- a/arch/nios2/config.mk
+++ b/arch/nios2/config.mk
@@ -29,5 +29,5 @@  CONFIG_STANDALONE_LOAD_ADDR ?= 0x02000000
 PLATFORM_CPPFLAGS += -DCONFIG_NIOS2 -D__NIOS2__
 PLATFORM_CPPFLAGS += -G0
 
-LDFLAGS_FINAL += --gc-sections
+LDFLAGS_FINAL += -Wl,--gc-sections
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
diff --git a/arch/powerpc/config.mk b/arch/powerpc/config.mk
index a307154..87e4934 100644
--- a/arch/powerpc/config.mk
+++ b/arch/powerpc/config.mk
@@ -24,7 +24,7 @@ 
 CROSS_COMPILE ?= ppc_8xx-
 
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
-LDFLAGS_FINAL += --gc-sections
+LDFLAGS_FINAL += -Wl,--gc-sections
 PLATFORM_RELFLAGS += -fpic -mrelocatable -ffunction-sections -fdata-sections
 PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__
 PLATFORM_LDFLAGS  += -n
diff --git a/arch/sh/config.mk b/arch/sh/config.mk
index 07ff8b9..3451223 100644
--- a/arch/sh/config.mk
+++ b/arch/sh/config.mk
@@ -29,5 +29,5 @@  CONFIG_STANDALONE_LOAD_ADDR += -EB
 endif
 
 PLATFORM_CPPFLAGS += -DCONFIG_SH -D__SH__
-PLATFORM_LDFLAGS += -e $(CONFIG_SYS_TEXT_BASE) --defsym reloc_dst=$(CONFIG_SYS_TEXT_BASE)
-LDFLAGS_FINAL = --gc-sections
+PLATFORM_LDFLAGS += -Wl,-e $(CONFIG_SYS_TEXT_BASE) -Wl,--defsym reloc_dst=$(CONFIG_SYS_TEXT_BASE)
+LDFLAGS_FINAL = -Wl,--gc-sections
diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index 23cacff..b3b07cc 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -38,11 +38,11 @@  PLATFORM_CPPFLAGS += -DREALMODE_BASE=0x7c0
 
 PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
 
-PLATFORM_LDFLAGS += --emit-relocs -Bsymbolic -Bsymbolic-functions
+PLATFORM_LDFLAGS += -Wl,--emit-relocs -Wl,-Bsymbolic -Wl,-Bsymbolic-functions
 
-LDFLAGS_FINAL += --gc-sections -pie
-LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3
-LDFLAGS_FINAL += --wrap=__moddi3 --wrap=__umoddi3
+LDFLAGS_FINAL += -Wl,--gc-sections -pie
+LDFLAGS_FINAL += -Wl,--wrap=__divdi3 -Wl,--wrap=__udivdi3
+LDFLAGS_FINAL += -Wl,--wrap=__moddi3 -Wl,--wrap=__umoddi3
 
 NORMAL_LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
 PREFIXED_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/$(shell basename $(NORMAL_LIBGCC))
diff --git a/board/ait/cam_enc_4xx/config.mk b/board/ait/cam_enc_4xx/config.mk
index 744b927..0792c84 100644
--- a/board/ait/cam_enc_4xx/config.mk
+++ b/board/ait/cam_enc_4xx/config.mk
@@ -18,5 +18,5 @@  else
 # the following error message:
 # arm-linux-ld: u-boot-spl: Not enough room for program headers, try linking
 # with -N
-LDFLAGS_u-boot-spl += -n
+LDFLAGS_u-boot-spl += -Wl,-n
 endif
diff --git a/config.mk b/config.mk
index b7cd481..ec8cd6b 100644
--- a/config.mk
+++ b/config.mk
@@ -137,9 +137,8 @@  binutils-version = $(shell $(SHELL) $(SRCTREE)/tools/binutils-version.sh $(AS))
 #
 AS	= $(CROSS_COMPILE)as
 
-# Always use GNU ld
-LD	= $(shell if $(CROSS_COMPILE)ld.bfd -v > /dev/null 2>&1; \
-		then echo "$(CROSS_COMPILE)ld.bfd"; else echo "$(CROSS_COMPILE)ld"; fi;)
+# Link with GCC
+LD	= $(CROSS_COMPILE)gcc
 
 CC	= $(CROSS_COMPILE)gcc
 CPP	= $(CC) -E
@@ -202,7 +201,7 @@  CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)		\
 # Enable garbage collection of un-used sections for SPL
 ifeq ($(CONFIG_SPL_BUILD),y)
 CPPFLAGS += -ffunction-sections -fdata-sections
-LDFLAGS_FINAL += --gc-sections
+LDFLAGS_FINAL += -Wl,--gc-sections -Wl,--build-id=none
 endif
 
 ifneq ($(CONFIG_SYS_TEXT_BASE),)
@@ -265,17 +264,17 @@  endif
 
 AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
 
-LDFLAGS += $(PLATFORM_LDFLAGS)
-LDFLAGS_FINAL += -Bstatic
+LDFLAGS += $(PLATFORM_LDFLAGS) -Wl,--build-id=none -nostdlib
+LDFLAGS_FINAL += -Wl,-Bstatic -Wl,-allow-multiple-definition
 
 LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
 ifneq ($(CONFIG_SYS_TEXT_BASE),)
-LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
+LDFLAGS_u-boot += -Wl,-Ttext -Wl,$(CONFIG_SYS_TEXT_BASE)
 endif
 
 LDFLAGS_u-boot-spl += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)
 ifneq ($(CONFIG_SPL_TEXT_BASE),)
-LDFLAGS_u-boot-spl += -Ttext $(CONFIG_SPL_TEXT_BASE)
+LDFLAGS_u-boot-spl += -Wl,-Ttext -Wl,$(CONFIG_SPL_TEXT_BASE)
 endif
 
 # Linus' kernel sanity checking tool
diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
index baaa2fb..eaf8bb3 100644
--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -96,8 +96,8 @@  $(LIB):	$(obj).depend $(LIBOBJS)
 
 $(ELF):
 $(obj)%:	$(obj)%.o $(LIB)
-		$(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
-			-o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
+		$(LD) $(LDFLAGS) -g -Wl,-Ttext -Wl,$(CONFIG_STANDALONE_LOAD_ADDR) \
+			-o $@ -Wl,-e -Wl,$(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
 			-L$(gcclibdir) -lgcc
 
 $(SREC):
diff --git a/nand_spl/board/amcc/acadia/Makefile b/nand_spl/board/amcc/acadia/Makefile
index 84cb8ab..6a75e34 100644
--- a/nand_spl/board/amcc/acadia/Makefile
+++ b/nand_spl/board/amcc/acadia/Makefile
@@ -27,7 +27,7 @@  include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/amcc/bamboo/Makefile b/nand_spl/board/amcc/bamboo/Makefile
index 6430219..5fa1a3b 100644
--- a/nand_spl/board/amcc/bamboo/Makefile
+++ b/nand_spl/board/amcc/bamboo/Makefile
@@ -27,7 +27,7 @@  include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/amcc/canyonlands/Makefile b/nand_spl/board/amcc/canyonlands/Makefile
index 509a46e..4e2eae4 100644
--- a/nand_spl/board/amcc/canyonlands/Makefile
+++ b/nand_spl/board/amcc/canyonlands/Makefile
@@ -27,7 +27,7 @@  include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/amcc/kilauea/Makefile b/nand_spl/board/amcc/kilauea/Makefile
index 104b7e2..55900ed 100644
--- a/nand_spl/board/amcc/kilauea/Makefile
+++ b/nand_spl/board/amcc/kilauea/Makefile
@@ -27,7 +27,7 @@  include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/amcc/sequoia/Makefile b/nand_spl/board/amcc/sequoia/Makefile
index 54e8a12..dc41c1f 100644
--- a/nand_spl/board/amcc/sequoia/Makefile
+++ b/nand_spl/board/amcc/sequoia/Makefile
@@ -27,7 +27,7 @@  include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/freescale/mpc8313erdb/Makefile b/nand_spl/board/freescale/mpc8313erdb/Makefile
index cff2a43..9fe4472 100644
--- a/nand_spl/board/freescale/mpc8313erdb/Makefile
+++ b/nand_spl/board/freescale/mpc8313erdb/Makefile
@@ -30,7 +30,7 @@  include $(TOPDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 	   $(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/freescale/mpc8315erdb/Makefile b/nand_spl/board/freescale/mpc8315erdb/Makefile
index cff2a43..9fe4472 100644
--- a/nand_spl/board/freescale/mpc8315erdb/Makefile
+++ b/nand_spl/board/freescale/mpc8315erdb/Makefile
@@ -30,7 +30,7 @@  include $(TOPDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 	   $(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/freescale/mpc8536ds/Makefile b/nand_spl/board/freescale/mpc8536ds/Makefile
index e5388d8..6d91269 100644
--- a/nand_spl/board/freescale/mpc8536ds/Makefile
+++ b/nand_spl/board/freescale/mpc8536ds/Makefile
@@ -33,7 +33,7 @@  nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/freescale/mpc8569mds/Makefile b/nand_spl/board/freescale/mpc8569mds/Makefile
index e5388d8..6d91269 100644
--- a/nand_spl/board/freescale/mpc8569mds/Makefile
+++ b/nand_spl/board/freescale/mpc8569mds/Makefile
@@ -33,7 +33,7 @@  nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/freescale/mpc8572ds/Makefile b/nand_spl/board/freescale/mpc8572ds/Makefile
index e5388d8..6d91269 100644
--- a/nand_spl/board/freescale/mpc8572ds/Makefile
+++ b/nand_spl/board/freescale/mpc8572ds/Makefile
@@ -33,7 +33,7 @@  nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/freescale/mx31pdk/Makefile b/nand_spl/board/freescale/mx31pdk/Makefile
index 43e72c4..1213cf2 100644
--- a/nand_spl/board/freescale/mx31pdk/Makefile
+++ b/nand_spl/board/freescale/mx31pdk/Makefile
@@ -7,7 +7,7 @@  nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/freescale/p1010rdb/Makefile b/nand_spl/board/freescale/p1010rdb/Makefile
index f270faa..8dfaf0c 100644
--- a/nand_spl/board/freescale/p1010rdb/Makefile
+++ b/nand_spl/board/freescale/p1010rdb/Makefile
@@ -33,7 +33,7 @@  nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/freescale/p1023rds/Makefile b/nand_spl/board/freescale/p1023rds/Makefile
index b288284..39b2588 100644
--- a/nand_spl/board/freescale/p1023rds/Makefile
+++ b/nand_spl/board/freescale/p1023rds/Makefile
@@ -28,7 +28,7 @@  nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/freescale/p1_p2_rdb/Makefile b/nand_spl/board/freescale/p1_p2_rdb/Makefile
index e5388d8..6d91269 100644
--- a/nand_spl/board/freescale/p1_p2_rdb/Makefile
+++ b/nand_spl/board/freescale/p1_p2_rdb/Makefile
@@ -33,7 +33,7 @@  nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/freescale/p1_p2_rdb_pc/Makefile b/nand_spl/board/freescale/p1_p2_rdb_pc/Makefile
index 7146d16..b3514ac 100644
--- a/nand_spl/board/freescale/p1_p2_rdb_pc/Makefile
+++ b/nand_spl/board/freescale/p1_p2_rdb_pc/Makefile
@@ -33,7 +33,7 @@  nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/karo/tx25/Makefile b/nand_spl/board/karo/tx25/Makefile
index becf7fa..628bfee 100644
--- a/nand_spl/board/karo/tx25/Makefile
+++ b/nand_spl/board/karo/tx25/Makefile
@@ -28,7 +28,7 @@  nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
 LSTSCRIPT= $(nandobj)/board/$(BOARDDIR)/u-boot.lst
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
diff --git a/nand_spl/board/samsung/smdk6400/Makefile b/nand_spl/board/samsung/smdk6400/Makefile
index c9e75ba..75b7b0f 100644
--- a/nand_spl/board/samsung/smdk6400/Makefile
+++ b/nand_spl/board/samsung/smdk6400/Makefile
@@ -32,7 +32,7 @@  include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 		$(LDFLAGS_FINAL) -gc-sections
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL -ffunction-sections
diff --git a/nand_spl/board/sheldon/simpc8313/Makefile b/nand_spl/board/sheldon/simpc8313/Makefile
index 2a3ddac..a73fa87 100644
--- a/nand_spl/board/sheldon/simpc8313/Makefile
+++ b/nand_spl/board/sheldon/simpc8313/Makefile
@@ -30,7 +30,7 @@  include $(TOPDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
-LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
+LDFLAGS := -T $(nandobj)u-boot.lds -Wl,-Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 	   $(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_NAND_SPL
diff --git a/spl/Makefile b/spl/Makefile
index 3195390..6d9b4ae 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -139,8 +139,8 @@  $(obj)u-boot-spl.bin:	$(obj)u-boot-spl
 
 GEN_UBOOT = \
 	cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $(__START) \
-		--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
-		-Map u-boot-spl.map -o u-boot-spl
+		-Wl,--start-group -Wl,$(__LIBS) -Wl,--end-group -Wl,$(PLATFORM_LIBS) \
+		-Wl,-Map=u-boot-spl.map -o u-boot-spl
 
 $(obj)u-boot-spl:	depend $(START) $(LIBS) $(obj)u-boot-spl.lds
 	$(GEN_UBOOT)