[U-Boot] [PATCH 1/2] Allow board specific overwriting of library code

Mike Frysinger vapier at gentoo.org
Wed Feb 4 17:23:08 CET 2009


On Wednesday 04 February 2009 11:18:16 Michael Roth wrote:
> Michael Roth schrieb:
> > Because the whole weak-linking looks like it is somewhat broken or at
> > least very difficult to get it correctly.
>
> Small example:
>
> In board/atmel/at91sam9261ek there is:
>
> led.c:
> 	void red_LED_on(void)
> 	...
> 	void red_LED_off(void)
> 	...
>
> Makefile:
>
> 	COBJS-y += led.o
> 	...
> 	OBJS    := $(addprefix $(obj),$(COBJS-y))
> 	...
> 	$(LIB): $(obj).depend $(OBJS) $(SOBJS)
>
>
> And in lib_arm/board.c we have:
>
> 	void inline __red_LED_on (void) {}
> 	void inline red_LED_on (void) __attribute__((weak,
> alias("__red_LED_on"))); void inline __red_LED_off(void) {}
> 	void inline red_LED_off(void)        __attribute__((weak,
> alias("__red_LED_off")));
>
>
> But as you can see from u-boot.map, the result is not as expected:
>
> 	0x23f00340      0x35c lib_arm/libarm.a(board.o)
> 	0x23f00390                __red_LED_off
> 	...
> 	0x23f00390                red_LED_off
> 	...
> 	0x23f0038c                red_LED_on
> 	0x23f0038c                __red_LED_on
>
>
> No single weak symbol from lib_arm/board.c get overridden from the
> board specific led.c. Very annoying.

that's because your led.o was not pulled in for any other reason.  give it a 
reason to be pulled in and the weak overrides will work fine.  in other words, 
what you show is not the linker being broken, but your expectations being 
broken ;).
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090204/e259fc99/attachment.pgp 


More information about the U-Boot mailing list