From: Wolfgang Denk Date: Tue, 25 Sep 2012 22:12:04 +0200 Subject: [U-Boot] [PATCH 1/3 V2] common: Add symbol handling for generic lists into Makefile In-Reply-To: <1348589520-14395-2-git-send-email-marex@denx.de> References: <1348449718-16463-1-git-send-email-marex@denx.de> <1348589520-14395-1-git-send-email-marex@denx.de> <1348589520-14395-2-git-send-email-marex@denx.de> Message-ID: <20120925201204.1712E200335@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Ein weiser Herrscher kann in einem gro?en Land mehr Gutes bewirken als in einem kleinen - ein dummer Herrscher aber auch viel mehr Un- fug. Da weise Herrscher seltener sind als dumme, war ich schon immer gegen gro?e Reiche skeptisch. - Herbert Rosendorfer