Invalid code generated with gcc-4.2 for target m68k-rtems.

Kirspel, Kevin kevin.kirspel at
Mon Jun 25 17:18:26 UTC 2007

I have downloaded the coldfire-4.2 source code and I have cross-compiled it
for the m68k-rtems target (for use with mcf5329EVB).  Everything builds and
installs fine.  After the tools are installed I compiled my OS.  The
compilation of the OS completes with no errors.  When I run the OS using
GDB, the program fails in the newlib memset() function.  The PC register at
the time of failure is at 0x400149ea.  I disassembled the application (using
m68k-rtems-objdump) and got the following output for memset():


400149cc <memset>:

400149cc:         4e56 0000         linkw %fp,#0

400149d0:         2f03                  movel %d3,%sp at -

400149d2:         2f02                  movel %d2,%sp at -

400149d4:         262e 0008         movel %fp@(8),%d3

400149d8:         226e 0010         moveal %fp@(16),%a1

400149dc:         2203                 movel %d3,%d1

400149de:         4282                 clrl %d2

400149e0:         142e 000f          moveb %fp@(15),%d2

400149e4:         7003                 moveq #3,%d0

400149e6:         b089                 cmpl %a1,%d0

400149e8:         6406                 bccs 400149f0 <memset+0x24>

400149ea:         e8c3                 0164303

400149ec:         0782                 bclr %d3,%d2

400149ee:         6712                 beqs 40014a02 <memset+0x36>

400149f0:          4a89                 tstl %a1

400149f2:          6758                 beqs 40014a4c <memset+0x80>

400149f4:          1002                 moveb %d2,%d0

400149f6:          2041                 moveal %d1,%a0

400149f8:          d3c1                 addal %d1,%a1

400149fa:          10c0                 moveb %d0,%a0 at +

400149fc:          b3c8                 cmpal %a0,%a1

400149fe:          66fa                  bnes 400149fa <memset+0x2e>

40014a00:         604a                 bras 40014a4c <memset+0x80>

40014a02:         2043                 moveal %d3,%a0

40014a04:         2002                 movel %d2,%d0


The instruction at 0x400149ea seems to be bogus.  Is this a gcc/newlib
compilation issue or a build environment issue?  I performed the following
steps during the build process:


1.	unarchived binutils.
2.	built binutils with the following configure statement: configure
--target=m68k-rtems --prefix=/usr/local.
3.	installed binutils.
4.	unarchived gcc and newlib.
5.	created symbolic link for newlib within gcc.
6.	built gcc with the following configure statement: configure
--target=m68k-rtems --with-gnu-as --with-gnu-ld --with-newlib --verbose
--enable-threads --enable-languages="c,c++" --prefix=/usr/local.
7.	installed gcc.
8.	unarchived OS.
9.	built OS with the following configure statement: configure
--target=m68k-rtems --disable-posix --disable-itron --disable-networking
--disable-cxx --enable-rtemsbsp=mcf5329EVB --prefix=/usr/local.
10.	Did objdump on hello world sample application to see disassembly.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the coldfire-gnu-discuss mailing list