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

Marek Vasut marex at denx.de
Mon Sep 24 03:21:55 CEST 2012


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 at denx.de>
Cc: Joe Hershberger <joe.hershberger at gmail.com>
Cc: Mike Frysinger <vapier at gentoo.org>
---
 Makefile     |   21 ++++++++++++++++++---
 spl/Makefile |   14 +++++++++++++-
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index e3a27c6..592987a 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,20 @@ $(SUBDIR_EXAMPLES): $(obj)u-boot
 $(LDSCRIPT):	depend
 		$(MAKE) -C $(dir $@) $(notdir $@)
 
-$(obj)u-boot.lds: $(LDSCRIPT)
-		$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+$(obj)u-boot.lst: $(LIBBOARD) $(LIBS)
+	$(OBJDUMP) -h $(LIBBOARD) $(LIBS) | \
+	sed -n -e 's/.*\(\.u_boot_list[^ ]\+\).*$$/\1/p' | \
+	sed 's/\.[^\.]\+$$//' | \
+	sed -n ':s /^.\+$$/ { p;s/^\(.*\)\.[^\.]*$$/\1/;b s }' | \
+	sed -n 's/\./.#/g;h;s/$$/\a/p;g;s/$$/@/p;g;s/$$/~/p;' | \
+	LC_COLLATE=C sort -u | \
+	sed 's/#//g' | \
+	sed -n -e '/\a$$/ { s/\./_/g;s/\a$$/__start = .;/p; }'\
+		-e '/~$$/ { s/\./_/g;s/~$$/__end = .;/p; }'\
+		-e '/@$$/ { s/\(.*\)@$$/*(SORT(\1.*));/p }' >$@
+
+$(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/spl/Makefile b/spl/Makefile
index d4cb668..545adfe 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -148,7 +148,19 @@ $(START):	depend
 $(LIBS):	depend
 	$(MAKE) -C $(SRCTREE)$(dir $(subst $(SPLTREE),,$@))
 
-$(obj)u-boot-spl.lds: $(LDSCRIPT) depend
+$(obj)u-boot-spl.lst: $(LIBS)
+	$(OBJDUMP) -h $(LIBS) | \
+	sed -n -e 's/.*\(\.u_boot_list[^ ]\+\).*$$/\1/p' | \
+	sed 's/\.[^\.]\+$$//' | \
+	sed -n ':s /^.\+$$/ { p;s/^\(.*\)\.[^\.]*$$/\1/;b s }' | \
+	sed -n 's/\./.#/g;h;s/$$/\a/p;g;s/$$/@/p;g;s/$$/~/p;' | \
+	LC_COLLATE=C sort -u | \
+	sed 's/#//g' | \
+	sed -n -e '/\a$$/ { s/\./_/g;s/\a$$/__start = .;/p; }'\
+		-e '/~$$/ { s/\./_/g;s/~$$/__end = .;/p; }'\
+		-e '/@$$/ { s/\(.*\)@$$/*(SORT(\1.*));/p }' >$@
+
+$(obj)u-boot-spl.lds: $(LDSCRIPT) $(obj)u-boot-spl.lst depend
 	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - < $< > $@
 
 depend:	$(obj).depend
-- 
1.7.10.4



More information about the U-Boot mailing list