[U-Boot] Allow board specific overwriting of library code

Hello,
recently there were some discussion how to support board specfic lowlevel_init code on the at91 plattform. For example in Nov 2008 there was a discussion about CONFIG_USER_LOWLEVEL_INIT or so and recently there was a patch proposal from Jean-Christophe to provide a cmd_link_o_target macro that creates a combinend object file instead an archive.
The combined object file was needed because weak linking somehow doesn't work with archive files. Very annoying.
I had large problems with weak linking regarding coloured LED support on my board, too. I came to the conclusion that weak linking across archives are somehow broken. However I was not able to create a small test case to trigger this behavior (bug?) in gcc/bintuils.
Ok, so here my proposal that is generic and allows any library code to get overwritten by board specific functions without defining any weak symbols in the library code. It is based purely on sequence of object files presented to 'ld'.
Please take a look and tell me your opinion.
I have patches to support a new board in my queue but I need any possibility to provide a board specific lowlevel_init. Which solution is selected plays no role to me.
Michael Roth

Enables to overwrite any library code by defining EXTRABOARDOBJS in the board specific config.mk. Those listed object files get linked directly into the u-boot binary right after the start objects and before any archives.
Signed-off-by: Michael Roth mroth@nessie.de --- Makefile | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile index 802a704..87975a1 100644 --- a/Makefile +++ b/Makefile @@ -273,6 +273,8 @@ LIBS := $(addprefix $(obj),$(LIBS)) LIBBOARD = board/$(BOARDDIR)/lib$(BOARD).a LIBBOARD := $(addprefix $(obj),$(LIBBOARD))
+EXTRABOARDOBJS := $(addprefix $(obj)board/$(BOARDDIR)/,$(EXTRABOARDOBJS)) + # Add GCC lib PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
@@ -294,7 +296,7 @@ ONENAND_IPL = onenand_ipl U_BOOT_ONENAND = $(obj)u-boot-onenand.bin endif
-__OBJS := $(subst $(obj),,$(OBJS)) +__OBJS := $(subst $(obj),,$(OBJS)) $(subst $(obj),,$(EXTRABOARDOBJS)) __LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD))
######################################################################### @@ -338,7 +340,8 @@ $(obj)u-boot.sha1: $(obj)u-boot.bin $(obj)u-boot.dis: $(obj)u-boot $(OBJDUMP) -d $< > $@
-$(obj)u-boot: depend $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) +$(obj)u-boot: depend $(SUBDIRS) $(OBJS) $(EXTRABOARDOBJS) \ + $(LIBBOARD) $(LIBS) $(LDSCRIPT) UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \ sed -n -e 's/.*($(SYM_PREFIX)__u_boot_cmd_.*)/-u\1/p'|sort|uniq`;\ cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \ @@ -348,6 +351,11 @@ $(obj)u-boot: depend $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(OBJS): depend $(obj)include/autoconf.mk $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))
+$(EXTRABOARDOBJS): depend $(obj)include/autoconf.mk + $(MAKE) -C $(dir $(subst $(obj),,$@)) \ + $(if $(REMOTE_BUILD), \ + $(EXTRABOARDOBJS),$(notdir $(EXTRABOARDOBJS))) + $(LIBS): depend $(obj)include/autoconf.mk $(SUBDIRS) $(MAKE) -C $(dir $(subst $(obj),,$@))
participants (1)
-
Michael Roth