[U-Boot] [PATCH] examples/standalone: Remove relocation compile flags for PowerPC

Peter Tyser ptyser at xes-inc.com
Tue Jun 15 22:15:05 CEST 2010


On Tue, 2010-06-15 at 14:45 -0500, Timur Tabi wrote:
> Peter Tyser wrote:
> > Was commenting out the 'ifeq' above necessary?  It shouldn't be, so my
> > first question would be why it was needed.
> 
> Probably because I was using an older U-Boot.  When I switch to the latest
> code, it compiles fine.
> 
> However, my entry point is not at 40000:
> 
> $ nm -n examples/standalone/flash_wp
> 00040000 t command_exit
> 000400c4 t is_locked
> 00040184 T flash_wp
> 000403d0 T dummy
> 
> 'flash_wp' should be at 40000.  command_exit and is_locked are two functions
> in my code.  command_exit, however, is not the first function, it's the third.

I think by default its not possible to guarantee function order in gcc's
output if a file contains multiple functions.  We could create a basic
linker script...  I think we could also do it with some gcc/ld-foo like:

--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -78,6 +78,7 @@ CPPFLAGS += -I..
 # inconsistent.
 ifeq ($(ARCH),powerpc)
 CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS))
+CFLAGS += -fno-toplevel-reorder
 endif
 
 all:   $(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF)
@@ -88,7 +89,7 @@ $(LIB):       $(obj).depend $(LIBOBJS)
 
 $(ELF):
 $(obj)%:       $(obj)%.o $(LIB)
-               $(LD) -g -Ttext $(STANDALONE_LOAD_ADDR) \
+               $(LD) -g -Ttext $(STANDALONE_LOAD_ADDR) -sort-common \
                        -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
                        -L$(gcclibdir) -lgcc
 
Could you try the above change with your flash_wp test case?  Or make
the flash_wp app public?  It should put the first function at the base
of the image in theory.

Best,
Peter



More information about the U-Boot mailing list