public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/64800] New: Bad opcode produced for coldfire mcf5307 processor
@ 2015-01-26 14:18 angelo70 at gmail dot com
  2015-01-26 14:47 ` [Bug c/64800] " schwab@linux-m68k.org
  2015-01-26 17:21 ` angelo70 at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: angelo70 at gmail dot com @ 2015-01-26 14:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64800

            Bug ID: 64800
           Summary: Bad opcode produced for coldfire mcf5307 processor
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: angelo70 at gmail dot com

Dear all,

i am compiling a simple bare-metal binary with 

https://www.kernel.org/pub/tools/crosstool/files/bin/i686/4.6.3/i686-gcc-4.6.3-nolibc_m68k-linux.tar.gz


$ make -f makefile.release
/opt/toolchains/m68k/gcc-4.6.3-nolibc/m68k-linux/bin/m68k-linux-gcc -m5307 -g
-O2 -fno-builtin -I include -c -o obj/boot.o src/boot.S
/opt/toolchains/m68k/gcc-4.6.3-nolibc/m68k-linux/bin/m68k-linux-gcc -m5307 -g
-O2 -fno-builtin -I include -c -o obj/vt100.o src/vt100.c
/opt/toolchains/m68k/gcc-4.6.3-nolibc/m68k-linux/bin/m68k-linux-gcc -m5307 -g
-O2 -fno-builtin -I include -c -o obj/timing.o src/timing.c
/opt/toolchains/m68k/gcc-4.6.3-nolibc/m68k-linux/bin/m68k-linux-gcc -m5307 -g
-O2 -fno-builtin -I include -c -o obj/flash.o src/flash.c
/opt/toolchains/m68k/gcc-4.6.3-nolibc/m68k-linux/bin/m68k-linux-gcc -m5307 -g
-O2 -fno-builtin -I include -c -o obj/memory.o src/memory.c
/opt/toolchains/m68k/gcc-4.6.3-nolibc/m68k-linux/bin/m68k-linux-gcc -m5307 -g
-O2 -fno-builtin -I include -c -o obj/main.o src/main.c
/opt/toolchains/m68k/gcc-4.6.3-nolibc/m68k-linux/bin/m68k-linux-gcc -m5307 -g
-O2 -fno-builtin -I include -c -o obj/serial.o src/serial.c
/opt/toolchains/m68k/gcc-4.6.3-nolibc/m68k-linux/bin/m68k-linux-ld -T ram.ld -M
-o bin/cf4k.elf obj/boot.o obj/vt100.o obj/timing.o obj/flash.o obj/memory.o
obj/main.o obj/serial.o > bin/cf4k.map
/opt/toolchains/m68k/gcc-4.6.3-nolibc/m68k-linux/bin/m68k-linux-objcopy -O
binary bin/cf4k.elf bin/cf4k

The resulting opcodes seems not correct for mcf5307 (coldfire).
Wrong code is of course not running on the target board. 

See this "meminit" func disass:

Dump of assembler code for function meminit:
   0x20000758 <+0>:     linkw %fp,#-12
   0x2000075c <+4>:     moveml %a2-%a4,%sp@
   0x20000760 <+8>:     movel #262144,%sp@-
   0x20000766 <+14>:    lea 0x200004fc <delay>,%a3
   0x2000076c <+20>:    moveal #268435720,%a2
   0x20000772 <+26>:    moveaw #4,%a4
   0x20000776 <+30>:    jsr %a3@
   0x20000778 <+32>:    movew #-32218,%d0
   0x2000077c <+36>:    movew %d0,0x10000100
   0x20000782 <+42>:    movel #16711681,%d0
   0x20000788 <+48>:    movel #13060,%a2@
   0x2000078e <+54>:    movel %d0,0x1000010c
=> 0x20000794 <+60>:    movel #13068,%a2@
   0x2000079a <+66>:    movel #-1095901459,%a4@
   0x200007a0 <+72>:    movel #45828,%a2@
   0x200007a6 <+78>:    pea 0x68a
   0x200007aa <+82>:    jsr %a3@
   0x200007ac <+84>:    movel #-1095901459,%a4@
   0x200007b2 <+90>:    movel #45828,%a2@
   0x200007b8 <+96>:    movel #262144,%sp@-
   0x200007be <+102>:   jsr %a3@
   0x200007c0 <+104>:   movel #-1095901459,%d0
   0x200007c6 <+110>:   lea %sp@(12),%sp
   0x200007ca <+114>:   movel #45892,%a2@
   0x200007d0 <+120>:   movel %d0,0xc00
   0x200007d4 <+124>:   moveq #4,%d0
   0x200007d6 <+126>:   swap %d0
   0x200007d8 <+128>:   .short 0x4cfe     <<<<<<<<<<<<<<<
   0x200007da <+130>:   moveb %d0,%d6     <<<<<<<<<<<<<<<
   0x200007dc <+132>:   .short 0xfff4     <<<<<<<<<<<<<<<
   0x200007de <+134>:   unlk %fp
   0x200007e0 <+136>:   movel %d0,0x10000114
   0x200007e6 <+142>:   clrl 0x10000110
   0x200007ec <+148>:   rts

While, with a toolchain from CodeSourcery, 

 /opt/toolchains/m68k/Sourcery_CodeBench_Lite_for_ColdFire_ELF/bin/m68k-elf-gcc
--version
m68k-elf-gcc (Sourcery CodeBench Lite 2011.09-21) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


i get

=> 0x20000758 <+0>:     linkw %fp,#-12
   0x2000075c <+4>:     moveml %a2-%a4,%sp@
   0x20000760 <+8>:     movel #262144,%sp@-
   0x20000766 <+14>:    lea 0x200004f8 <delay>,%a3
   0x2000076c <+20>:    moveal #268435720,%a2
   0x20000772 <+26>:    moveaw #4,%a4
   0x20000776 <+30>:    jsr %a3@
   0x20000778 <+32>:    movew #-32218,%d0
   0x2000077c <+36>:    movew %d0,0x10000100
   0x20000782 <+42>:    movel #16711681,%d0
   0x20000788 <+48>:    movel #13060,%a2@
   0x2000078e <+54>:    movel %d0,0x1000010c
   0x20000794 <+60>:    movel #13068,%a2@
   0x2000079a <+66>:    movel #-1095901459,%a4@
   0x200007a0 <+72>:    movel #45828,%a2@
   0x200007a6 <+78>:    pea 0x68a
   0x200007aa <+82>:    jsr %a3@
   0x200007ac <+84>:    movel #-1095901459,%a4@
   0x200007b2 <+90>:    movel #45828,%a2@
   0x200007b8 <+96>:    movel #262144,%sp@-
   0x200007be <+102>:   jsr %a3@
   0x200007c0 <+104>:   movel #-1095901459,%d0
   0x200007c6 <+110>:   lea %sp@(12),%sp
   0x200007ca <+114>:   movel #45892,%a2@
   0x200007d0 <+120>:   movel %d0,0xc00
   0x200007d4 <+124>:   moveq #4,%d0
   0x200007d6 <+126>:   swap %d0
   0x200007d8 <+128>:   moveml %fp@(-12),%a2-%a4
   0x200007de <+134>:   unlk %fp
   0x200007e0 <+136>:   movel %d0,0x10000114
   0x200007e6 <+142>:   clrl 0x10000110
   0x200007ec <+148>:   rts

A correct code, that runs on target cpu.



Best regards,
Angelo


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/64800] Bad opcode produced for coldfire mcf5307 processor
  2015-01-26 14:18 [Bug c/64800] New: Bad opcode produced for coldfire mcf5307 processor angelo70 at gmail dot com
@ 2015-01-26 14:47 ` schwab@linux-m68k.org
  2015-01-26 17:21 ` angelo70 at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: schwab@linux-m68k.org @ 2015-01-26 14:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64800

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
Looks like this is a bug in your assembler, which generates 0x4cfe instead of
0x4cee for moveml %fp@(-12),%a2-%a4.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/64800] Bad opcode produced for coldfire mcf5307 processor
  2015-01-26 14:18 [Bug c/64800] New: Bad opcode produced for coldfire mcf5307 processor angelo70 at gmail dot com
  2015-01-26 14:47 ` [Bug c/64800] " schwab@linux-m68k.org
@ 2015-01-26 17:21 ` angelo70 at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: angelo70 at gmail dot com @ 2015-01-26 17:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64800

--- Comment #2 from angelo <angelo70 at gmail dot com> ---

You mean the issue is into m68k-linux-as or what ?

The function i disassembled is inside memory.c. So i am calling m68k-linux-gcc,
wich generate object code and finally opcodes.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-26 17:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-26 14:18 [Bug c/64800] New: Bad opcode produced for coldfire mcf5307 processor angelo70 at gmail dot com
2015-01-26 14:47 ` [Bug c/64800] " schwab@linux-m68k.org
2015-01-26 17:21 ` angelo70 at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).