Hi,

I've run into a piece of code on ppc405 that does the wrong thing when a
function is automatically inlined.  I don't really do ppc asm so I
haven't been able to isolate what exactly the problem is, but the code
blatantly takes the wrong branch.

The toolchain I'm using is a cross compiler from x86 to ppc.  The target
is a 405gp.  I built this gcc-3.4.5/binutils-2.15/glibc-2.3.6 compiler
using crosstools-0.42

Reading specs from 
/home/mort/src/targa/powerpc-linux/gcc-3.4.5-glibc-2.3.6/powerpc-405-linux-gnu/bin/../lib/gcc/powerpc-405-linux-gnu/3.4.5/specs
Configured with: 
/home/mort/src/crosstool-0.42/build/powerpc-405-linux-gnu/gcc-3.4.5-glibc-2.3.6/gcc-3.4.5/configure
 --target=powerpc-405-linux-gnu --host=i686-host_pc-linux-gnu 
--prefix=/opt/targa/local/powerpc-linux/gcc-3.4.5-glibc-2.3.6/powerpc-405-linux-gnu
 --with-cpu=405 --enable-cxx-flags=-mcpu=405 
--with-headers=/opt/targa/local/powerpc-linux/gcc-3.4.5-glibc-2.3.6/powerpc-405-linux-gnu/powerpc-405-linux-gnu/include
 
--with-local-prefix=/opt/targa/local/powerpc-linux/gcc-3.4.5-glibc-2.3.6/powerpc-405-linux-gnu/powerpc-405-linux-gnu
 --disable-nls --enable-threads=posix --enable-symvers=gnu 
--enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 
--enable-long-long
Thread model: posix
gcc version 3.4.5

The problem I'm having is when running the CPU post test on u-boot
1.1.4.  Specifically, in the branch tests.  While doing the first branch
conditional test the computer incorrectly takes the "if (link)" branch
in u-boot/post/cpu/b.c::cpu_post_test_bc()

--- a/post/cpu/b.c
+++ b/post/cpu/b.c
@@ -84,10 +84,14 @@ static int cpu_post_test_bc (ulong cmd, 
     }
     if (ret == 0)
     {
-       if (link)
+        printf("link = %d\n", link);
+        if (link)
            ret = lr == (ulong) code + 24 ? 0 : -1;
        else
            ret = lr == 0 ? 0 : -1;
+       if (ret)
+               printf("ret = %d, link = %lx, code = %p, lr = %lx\n",
+                      ret, link, code, lr);
     }
 
     return ret;

---

Running with this small change, I get:

POST cpu link = 0
ret = -1, link = 0, code = 03fa5ab8, lr = 0

It looks clear to me that link == 0, so the test worked fine.

However, if I take away the "static" from the cpu_post_test_bc()
declaration then everything works fine.  Everything also works fine if I
leave the static, but also add the 'noinline' function attribute.

I've posted "objdump -dS" output for post/cpu/b.o with and without
cpu_post_test_bc() declared as static at:

http://www.bork.org/~mort/ppcstatic/

Any hints appreciated.  Let me know if any other info is required.
mh

-- 
Martin Hicks || [EMAIL PROTECTED] || PGP/GnuPG: 0x4C7F2BEE

Attachment: signature.asc
Description: Digital signature

Reply via email to