diff mbox

[U-Boot,1/3,V2] common: Add symbol handling for generic lists into Makefile

Message ID 1348589520-14395-2-git-send-email-marex@denx.de
State Changes Requested
Delegated to: Wolfgang Denk
Headers show

Commit Message

Marek Vasut Sept. 25, 2012, 4:11 p.m. UTC
This patch adds essential components for generation of the contents of
the linker section that is used by the linker-generated array. All of
the contents is held in a separate file, u-boot.lst, which is generated
at runtime just before U-Boot is linked.

The purpose of this code is to especially generate the appropriate
boundary symbols around each subsection in the section carrying the
linker-generated arrays. Obviously, the interim linker code for actual
placement of the variables into the section is generated too. The
generated file, u-boot.lst, is included into u-boot.lds via the linker
INCLUDE directive in u-boot.lds .

Adjustments are made in the Makefile and spl/Makefile so that the
u-boot.lds and u-boot-spl.lds depend on their respective .lst files.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Joe Hershberger <joe.hershberger@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
---
 Makefile                                       |   10 ++--
 config.mk                                      |    2 +
 helper.mk                                      |   62 ++++++++++++++++++++++++
 nand_spl/board/freescale/mpc8536ds/Makefile    |    6 ++-
 nand_spl/board/freescale/mpc8569mds/Makefile   |    6 ++-
 nand_spl/board/freescale/mpc8572ds/Makefile    |    6 ++-
 nand_spl/board/freescale/mx31pdk/Makefile      |    6 ++-
 nand_spl/board/freescale/p1010rdb/Makefile     |    6 ++-
 nand_spl/board/freescale/p1023rds/Makefile     |    6 ++-
 nand_spl/board/freescale/p1_p2_rdb/Makefile    |    6 ++-
 nand_spl/board/freescale/p1_p2_rdb_pc/Makefile |    6 ++-
 nand_spl/board/karo/tx25/Makefile              |    6 ++-
 spl/Makefile                                   |    3 +-
 13 files changed, 109 insertions(+), 22 deletions(-)
 create mode 100644 helper.mk

V2: - Move all the regex goo that generates u-boot.lst into helper.mk
    - Implant the eval call idea from Joe
    - Fix the nand spl boards where the builds failed.
    - Continue my documentation quest
      (no, I'm not planning to become a writer ;-) )

Comments

Wolfgang Denk Sept. 25, 2012, 8:12 p.m. UTC | #1
Dear Marek Vasut,

In message <1348589520-14395-2-git-send-email-marex@denx.de> you wrote:
> This patch adds essential components for generation of the contents of
> the linker section that is used by the linker-generated array. All of
> the contents is held in a separate file, u-boot.lst, which is generated
> at runtime just before U-Boot is linked.
...
> --- a/Makefile
> +++ b/Makefile
> @@ -510,7 +510,10 @@ else
>  GEN_UBOOT = \
>  		UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
>  		sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
> -		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__OBJS) \
> +		UNDEF_LST=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
> +		sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_list_.*\)/-u\1/p'|sort|uniq`;\
> +		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
> +			$$UNDEF_SYM $$UNDEF_LST $(__OBJS) \

I dislike the exact duplication of the commands here.

Would it not make sense to provide some function / script to do that?


> +$(eval $(call make_u_boot_list, $(obj)u-boot.lst, $(LIBBOARD) $(LIBS)))
> +$(obj)u-boot.lds: $(LDSCRIPT) $(obj)u-boot.lst
> +		$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@

I think this needs a comment to explain what sort of magic you are
invoking here.

...
> --- /dev/null
> +++ b/helper.mk
...
> +	$(OBJDUMP) -h $(2) | \
> +	sed -n -e 's/.*\(\.u_boot_list[^ ]\+\).*$$$$/\1/p' | \
> +	sed 's/\.[^\.]\+$$$$//' | \
> +	sed -n ':s /^.\+$$$$/ { p;s/^\(.*\)\.[^\.]*$$$$/\1/;b s }' | \
> +	sed -n 'h;s/$$$$/\a/p;g;s/$$$$/@/p;g;s/$$$$/~/p;' | \
...

Why exactly do you need 4 invocations of sed here?  Seems just like a
waste of processes to me.

>  LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
> +LSTSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lst

BTW:  what exactly is "LST" supposed to mean?

> +$(eval $(call make_u_boot_list, $(LSTSCRIPT), $(__OBJS)))
> +$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT) $(LSTSCRIPT)
> +	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@

Comment needed.


Best regards,

Wolfgang Denk
Marek Vasut Sept. 25, 2012, 8:22 p.m. UTC | #2
Dear Wolfgang Denk,

> Dear Marek Vasut,
> 
> In message <1348589520-14395-2-git-send-email-marex@denx.de> you wrote:
> > This patch adds essential components for generation of the contents of
> > the linker section that is used by the linker-generated array. All of
> > the contents is held in a separate file, u-boot.lst, which is generated
> > at runtime just before U-Boot is linked.
> 
> ...
> 
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -510,7 +510,10 @@ else
> > 
> >  GEN_UBOOT = \
> >  
> >  		UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
> >  		sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|
uniq`;\
> > 
> > -		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM 
$(__OBJS)
> > \ +		UNDEF_LST=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
> > +		sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_list_.*\)/-u\1/p'|sort|
uniq`;\
> > +		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
> > +			$$UNDEF_SYM $$UNDEF_LST $(__OBJS) \
> 
> I dislike the exact duplication of the commands here.

These shall begone once the cmd stuff is flipped over to these generic lists.

> Would it not make sense to provide some function / script to do that?

How do you like helper.mk ? %^) But see above, I think it'll grow pointless 
soon.

> > +$(eval $(call make_u_boot_list, $(obj)u-boot.lst, $(LIBBOARD) $(LIBS)))
> > +$(obj)u-boot.lds: $(LDSCRIPT) $(obj)u-boot.lst
> > +		$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< 
>$@
> 
> I think this needs a comment to explain what sort of magic you are
> invoking here.
> 
> ...
> 
> > --- /dev/null
> > +++ b/helper.mk
> 
> ...
> 
> > +	$(OBJDUMP) -h $(2) | \
> > +	sed -n -e 's/.*\(\.u_boot_list[^ ]\+\).*$$$$/\1/p' | \
> > +	sed 's/\.[^\.]\+$$$$//' | \
> > +	sed -n ':s /^.\+$$$$/ { p;s/^\(.*\)\.[^\.]*$$$$/\1/;b s }' | \
> > +	sed -n 'h;s/$$$$/\a/p;g;s/$$$$/@/p;g;s/$$$$/~/p;' | \
> 
> ...
> 
> Why exactly do you need 4 invocations of sed here?  Seems just like a
> waste of processes to me.
> 
> >  LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
> > 
> > +LSTSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lst
> 
> BTW:  what exactly is "LST" supposed to mean?

LIST ... that's from Supaplex, there was this levels.lst file IIRC ;-)

> > +$(eval $(call make_u_boot_list, $(LSTSCRIPT), $(__OBJS)))
> > +$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT) $(LSTSCRIPT)
> > +	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
> 
> Comment needed.

The eval call ... ?

> 
> Best regards,
> 
> Wolfgang Denk

Best regards,
Marek Vasut
diff mbox

Patch

diff --git a/Makefile b/Makefile
index e3a27c6..864432e 100644
--- a/Makefile
+++ b/Makefile
@@ -510,7 +510,10 @@  else
 GEN_UBOOT = \
 		UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
 		sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
-		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__OBJS) \
+		UNDEF_LST=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
+		sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_list_.*\)/-u\1/p'|sort|uniq`;\
+		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
+			$$UNDEF_SYM $$UNDEF_LST $(__OBJS) \
 			--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
 			-Map u-boot.map -o u-boot
 endif
@@ -543,8 +546,9 @@  $(SUBDIR_EXAMPLES): $(obj)u-boot
 $(LDSCRIPT):	depend
 		$(MAKE) -C $(dir $@) $(notdir $@)
 
-$(obj)u-boot.lds: $(LDSCRIPT)
-		$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+$(eval $(call make_u_boot_list, $(obj)u-boot.lst, $(LIBBOARD) $(LIBS)))
+$(obj)u-boot.lds: $(LDSCRIPT) $(obj)u-boot.lst
+		$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
 
 nand_spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) depend
 		$(MAKE) -C nand_spl/board/$(BOARDDIR) all
diff --git a/config.mk b/config.mk
index c3822a2..d2ed5bf 100644
--- a/config.mk
+++ b/config.mk
@@ -23,6 +23,8 @@ 
 
 #########################################################################
 
+include $(TOPDIR)/helper.mk
+
 ifeq ($(CURDIR),$(SRCTREE))
 dir :=
 else
diff --git a/helper.mk b/helper.mk
new file mode 100644
index 0000000..e9177ff
--- /dev/null
+++ b/helper.mk
@@ -0,0 +1,62 @@ 
+#
+# Copyright (C) 2012 Marek Vasut <marex@denx.de>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+#########################################################################
+
+##
+# make_u_boot_list - Generate contents of u_boot_list section
+# 1:		The name of the resulting file (usually u-boot.lst)
+# 2:		Files to analyze for possible u_boot_list entries
+#
+# This function generates the contents of the u_boot_list section,
+# including all the border symbols for it's subsections. The operation
+# of this function is as follows, numbering goes per lines:
+#
+# 1) Dump the ELF header sections from all files supplied via $(2)
+# 2) Filter out all other stuff that does not belong into .u_boot_list
+#    section. Also, fix up the lines so that the resulting output is
+#    is in format ".u_boot_list.*".
+# 3) Remove the last .something$, since that only contains the name
+#    of the variable to be put into a subsection. This name is irelevant
+#    for generation of border symbols, thus of no interest, remove it.
+# 4) Take each line and for every dot "." in that line, print the whole
+#    line until that dot "." . This is important so that we have all
+#    parent border symbols generated as well.
+# 5) Load every line and firstly append "\a" at the end and print the
+#    line. Next, append "@" at the end and print the line. Finally,
+#    append "~" at the end of line. This will make sense in conjunction
+#    with 6) and 7).
+# 6) Sort the lines. It is imperative to use LC_COLLATE=C here because
+#    with this, the "\a" symbol is first and "~" symbol is last. Any
+#    other symbols fall inbetween. Symbols like "@", which marks the
+#    end of current line (representing current section) and ".", which
+#    means the line continues and thus represents subsection.
+# 7) With such ordering, all lines ending with "\a" will float at the
+#    begining of all lines with the same prefix. Thus it is easy to
+#    replace "\a" with __start and make it the __start border symbol.
+#    Very similarly for "~", which will be always at the bottom and so
+#    can be replaced by "__end" and made into the __end border symbol.
+#    Finally, every line ending with "@" symbol will be transformed
+#    into " *(SORT(${line}*)); " format, which in the linker parlance
+#    will allow it to trap all symbols relevant to the subsection.
+#
+define make_u_boot_list
+$(1): $(2)
+	$(OBJDUMP) -h $(2) | \
+	sed -n -e 's/.*\(\.u_boot_list[^ ]\+\).*$$$$/\1/p' | \
+	sed 's/\.[^\.]\+$$$$//' | \
+	sed -n ':s /^.\+$$$$/ { p;s/^\(.*\)\.[^\.]*$$$$/\1/;b s }' | \
+	sed -n 'h;s/$$$$/\a/p;g;s/$$$$/@/p;g;s/$$$$/~/p;' | \
+	LC_COLLATE=C sort -u | \
+	sed -n -e '/\a$$$$/ { s/\./_/g;s/\a$$$$/__start = .;/p; }'\
+		-e '/~$$$$/ { s/\./_/g;s/~$$$$/__end = .;/p; }'\
+		-e '/@$$$$/ { s/\(.*\)@$$$$/*(SORT(\1.*));/p }' > $(1)
+endef
diff --git a/nand_spl/board/freescale/mpc8536ds/Makefile b/nand_spl/board/freescale/mpc8536ds/Makefile
index 43da3df..fb6bcd6 100644
--- a/nand_spl/board/freescale/mpc8536ds/Makefile
+++ b/nand_spl/board/freescale/mpc8536ds/Makefile
@@ -32,6 +32,7 @@  include $(TOPDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
+LSTSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lst
 LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
@@ -61,8 +62,9 @@  $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot-nand_spl.lds
 		-Map $(nandobj)u-boot-spl.map \
 		-o $(nandobj)u-boot-spl
 
-$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+$(eval $(call make_u_boot_list, $(LSTSCRIPT), $(__OBJS)))
+$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT) $(LSTSCRIPT)
+	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
 
 # create symbolic links for common files
 
diff --git a/nand_spl/board/freescale/mpc8569mds/Makefile b/nand_spl/board/freescale/mpc8569mds/Makefile
index 43da3df..fb6bcd6 100644
--- a/nand_spl/board/freescale/mpc8569mds/Makefile
+++ b/nand_spl/board/freescale/mpc8569mds/Makefile
@@ -32,6 +32,7 @@  include $(TOPDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
+LSTSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lst
 LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
@@ -61,8 +62,9 @@  $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot-nand_spl.lds
 		-Map $(nandobj)u-boot-spl.map \
 		-o $(nandobj)u-boot-spl
 
-$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+$(eval $(call make_u_boot_list, $(LSTSCRIPT), $(__OBJS)))
+$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT) $(LSTSCRIPT)
+	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
 
 # create symbolic links for common files
 
diff --git a/nand_spl/board/freescale/mpc8572ds/Makefile b/nand_spl/board/freescale/mpc8572ds/Makefile
index 43da3df..fb6bcd6 100644
--- a/nand_spl/board/freescale/mpc8572ds/Makefile
+++ b/nand_spl/board/freescale/mpc8572ds/Makefile
@@ -32,6 +32,7 @@  include $(TOPDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
+LSTSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lst
 LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
@@ -61,8 +62,9 @@  $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot-nand_spl.lds
 		-Map $(nandobj)u-boot-spl.map \
 		-o $(nandobj)u-boot-spl
 
-$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+$(eval $(call make_u_boot_list, $(LSTSCRIPT), $(__OBJS)))
+$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT) $(LSTSCRIPT)
+	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
 
 # create symbolic links for common files
 
diff --git a/nand_spl/board/freescale/mx31pdk/Makefile b/nand_spl/board/freescale/mx31pdk/Makefile
index 87784d2..62a7adf 100644
--- a/nand_spl/board/freescale/mx31pdk/Makefile
+++ b/nand_spl/board/freescale/mx31pdk/Makefile
@@ -6,6 +6,7 @@  include $(TOPDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
+LSTSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lst
 LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
@@ -36,8 +37,9 @@  $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot.lds
 		-Map $(nandobj)u-boot-spl.map \
 		-o $@
 
-$(nandobj)u-boot.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+$(eval $(call make_u_boot_list, $(LSTSCRIPT), $(__OBJS)))
+$(nandobj)u-boot.lds: $(LDSCRIPT) $(LSTSCRIPT)
+	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
 
 #########################################################################
 
diff --git a/nand_spl/board/freescale/p1010rdb/Makefile b/nand_spl/board/freescale/p1010rdb/Makefile
index 8d240ea..5d49ec9 100644
--- a/nand_spl/board/freescale/p1010rdb/Makefile
+++ b/nand_spl/board/freescale/p1010rdb/Makefile
@@ -32,6 +32,7 @@  include $(TOPDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
+LSTSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lst
 LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
@@ -61,8 +62,9 @@  $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot-nand_spl.lds
 		-Map $(nandobj)u-boot-spl.map \
 		-o $(nandobj)u-boot-spl
 
-$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+$(eval $(call make_u_boot_list, $(LSTSCRIPT), $(__OBJS)))
+$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT) $(LSTSCRIPT)
+	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
 
 # create symbolic links for common files
 
diff --git a/nand_spl/board/freescale/p1023rds/Makefile b/nand_spl/board/freescale/p1023rds/Makefile
index 168e868..37fda4a 100644
--- a/nand_spl/board/freescale/p1023rds/Makefile
+++ b/nand_spl/board/freescale/p1023rds/Makefile
@@ -27,6 +27,7 @@  include $(TOPDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
+LSTSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lst
 LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
@@ -56,8 +57,9 @@  $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot-nand_spl.lds
 		-Map $(nandobj)u-boot-spl.map \
 		-o $(nandobj)u-boot-spl
 
-$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+$(eval $(call make_u_boot_list, $(LSTSCRIPT), $(__OBJS)))
+$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT) $(LSTSCRIPT)
+	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
 
 # create symbolic links for common files
 
diff --git a/nand_spl/board/freescale/p1_p2_rdb/Makefile b/nand_spl/board/freescale/p1_p2_rdb/Makefile
index 43da3df..fb6bcd6 100644
--- a/nand_spl/board/freescale/p1_p2_rdb/Makefile
+++ b/nand_spl/board/freescale/p1_p2_rdb/Makefile
@@ -32,6 +32,7 @@  include $(TOPDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
+LSTSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lst
 LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
@@ -61,8 +62,9 @@  $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot-nand_spl.lds
 		-Map $(nandobj)u-boot-spl.map \
 		-o $(nandobj)u-boot-spl
 
-$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+$(eval $(call make_u_boot_list, $(LSTSCRIPT), $(__OBJS)))
+$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT) $(LSTSCRIPT)
+	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
 
 # create symbolic links for common files
 
diff --git a/nand_spl/board/freescale/p1_p2_rdb_pc/Makefile b/nand_spl/board/freescale/p1_p2_rdb_pc/Makefile
index 475cc49..f9effd2 100644
--- a/nand_spl/board/freescale/p1_p2_rdb_pc/Makefile
+++ b/nand_spl/board/freescale/p1_p2_rdb_pc/Makefile
@@ -32,6 +32,7 @@  include $(TOPDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
+LSTSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lst
 LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_NAND_SPL
@@ -61,8 +62,9 @@  $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot-nand_spl.lds
 		-Map $(nandobj)u-boot-spl.map \
 		-o $(nandobj)u-boot-spl
 
-$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+$(eval $(call make_u_boot_list, $(LSTSCRIPT), $(__OBJS)))
+$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT) $(LSTSCRIPT)
+	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
 
 # create symbolic links for common files
 
diff --git a/nand_spl/board/karo/tx25/Makefile b/nand_spl/board/karo/tx25/Makefile
index 0336346..2ac1b7c 100644
--- a/nand_spl/board/karo/tx25/Makefile
+++ b/nand_spl/board/karo/tx25/Makefile
@@ -27,6 +27,7 @@  include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
+LSTSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lst
 LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
 AFLAGS	+= -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
@@ -57,8 +58,9 @@  $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot.lds
 		-Map $(nandobj)u-boot-spl.map \
 		-o $@
 
-$(nandobj)u-boot.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+$(eval $(call make_u_boot_list, $(LSTSCRIPT), $(__OBJS)))
+$(nandobj)u-boot.lds: $(LDSCRIPT) $(LSTSCRIPT)
+	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
 
 #########################################################################
 
diff --git a/spl/Makefile b/spl/Makefile
index d4cb668..f3e74b9 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -148,7 +148,8 @@  $(START):	depend
 $(LIBS):	depend
 	$(MAKE) -C $(SRCTREE)$(dir $(subst $(SPLTREE),,$@))
 
-$(obj)u-boot-spl.lds: $(LDSCRIPT) depend
+$(eval $(call make_u_boot_list, $(obj)u-boot.lst, $(LIBS)))
+$(obj)u-boot-spl.lds: $(LDSCRIPT) $(obj)u-boot.lst depend
 	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - < $< > $@
 
 depend:	$(obj).depend