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

Wolfgang Denk wd at denx.de
Tue Jun 15 22:28:13 CEST 2010


Dear Peter Tyser,

In message <1276632905.32134.1535.camel at petert> you wrote:
>
> 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

Correct. If you check for example the "timer" example program (build
for some 8xx system, say TQM860L) you can see that it's sufficient to
have a forward declaration for a static function before the real code
that the C compiler will place the code for this function in front,
whichis probably not what you want here.

> 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

This alone is sufficient to "fix" for example the aforementioned
"timer" example program.

Without:

	...
	00040428 T strcmp
	000400e8 T timer
	00040000 t timer_handler
	00040318 T tstc
	00040398 T udelay
	...

With:

	...
	00040428 T strcmp
	00040000 T timer
	000402b8 t timer_handler
	00040318 T tstc
	00040398 T udelay
	...

>  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

I'm not sure if this is needed.

> 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.

I think the "timer" code is sufficient to show the problem, and that
your fix helps.  If Timur confirms it's working for his secret code
too we should apply this.

Thanks a lot!

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
Is a computer language with goto's totally Wirth-less?


More information about the U-Boot mailing list