[U-Boot] [PATCH 3/3] post/lib_powerpc/multi.c: fix stack overflow error

Wolfgang Denk wd at denx.de
Fri Dec 23 20:10:59 CET 2011


Dear Anatolij Gustschin,

In message <20111223170640.18cfe56f at wker> you wrote:
> 
> > The code and comment disagreed: the comment claimed that r6...r31
> > were copied, and consequently the arrays for "src" and "dst" were
> > declared with 26 entries, but the actual code ("lmw r5,0(r3)" and
> > "stmw r5,0(r4)") copied _27_ words (r5 through r31), which resulted
> > in false "POST cpu Error at multi test" messages.
> 
> Great! Thanks for fixing this bug!

Thanks for testing and reporting it!

> But I wonder why didn't we see it with U-Boot built using older
> GCC versions.

Yes, I was surprised,too, and suspected a compiler problem instead...

> Since only 26 words will be compared after the test, the issue
> only shows up if the destination buffer is placed at lower
> addresses on the stack than the source buffer. In this case the
> first word in the source buffer is overwritten. GCC 4.6.1 generated
> code which changed the order of src[] and dst[] on the stack and
> the hidden bug showed up.

This matches my own analysis.  Actually the code generated by gcc
4.5.1 and 4.6.1 looks _really_ different in a lot of places; it seems
a lot has been changed in GCC again.

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
Few people do business well who do nothing else.
                                       -- Philip Earl of Chesterfield


More information about the U-Boot mailing list