This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
GCC-3.4.0 on FRV architecture BUG report
- From: "zhanrk-gcc" <zhanrk-gcc at 163 dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 14 May 2004 18:24:24 +0800 (CST)
- Subject: GCC-3.4.0 on FRV architecture BUG report
GCC-3.4.0 BUG report
=======================
-- by zhanrk, 2004-5-14
It seems that the compiler gcc-3.4.0 on FRV architecture is buggy.
The following is my bug report:
1. GNU Toolchain packages list
*) binutils: binutils-2.14.tar.gz
*) gcc: gcc-core-3.4.0-20040416.tar.gz
2. my c codes
=============
filename: stdio.c
/*****************************************************************************/
void flush_input(void)
{
if (console)
console->flush_input();
}
void flush_output(void)
{
if (console)
console->flush_output();
}
/**
* putc - put a char to the console by non-raw mode
*
* NOTE: If we are printing '\n', we will append '\r'.
*/
void putc(const char ch)
{
if (console) {
console->putc(ch);
/* if print '\n', also print '\r' */
if (ch == '\n')
console->putc('\r');
}
} /* end of putc(...) */
/**
* puts - print a string to the console by non-raw mode
*/
void puts(const char *s)
{
if (console && s)
console->puts(s);
} /* end of puts(...) */
......
......
static char printbuffer[CONSOLE_BUFFER_SIZE] = {'\0', };
void printf(const char *fmt, ...)
{
va_list args;
u16 i;
memset(printbuffer, 0, CONSOLE_BUFFER_SIZE);
va_start(args, fmt);
/* For this to work, printbuffer must be larger than
* anything we ever want to print.
*/
i = vsprintf(printbuffer, fmt, args);
va_end(args);
/* Print the string */
puts(printbuffer);
} /* end of printf(...) */
/************************************************************************************************/
3. Compiling results
================
I use the following options to compile the source file "stdio.c":
frv-elf-gcc -nostdinc -I $(TOPDIR)/include -Wall -fomit-frame-pointer -fno-builtin \
-mcpu=fr400 -mno-vliw-branch stdio.c -o stdio.o
I use frv-elf-objdump to deassemble the object file "stdio.o", and get the following assembly result:
03a00470 <mb93403_serial_putc>:
3a00470: 82 40 1f e8 addi sp,-24,sp
3a00474: 85 48 10 08 sti fp,@(sp,8)
3a00478: 84 40 10 08 addi sp,8,fp
3a0047c: 88 0d 01 c5 movsg lr,gr5
3a00480: 8b 48 20 08 sti gr5,@(fp,8)
3a00484: 91 40 2f ff stbi gr8,@(fp,-1)
3a00488: 88 41 08 0c addi gr16,-2036,gr4
3a0048c: 88 08 41 00 ld @(gr4,gr0),gr4
3a00490: 88 40 40 28 addi gr4,40,gr4
3a00494: 88 08 41 00 ld @(gr4,gr0),gr4
3a00498: 88 a8 40 18 srli gr4,24,gr4
3a0049c: 89 40 2f fe stbi gr4,@(fp,-2)
3a004a0: 88 d4 2f fe ldubi @(fp,-2),gr4
3a004a4: 88 b0 40 06 srai gr4,6,gr4
3a004a8: 88 90 40 01 xori gr4,1,gr4
3a004ac: 88 80 40 01 andi gr4,1,gr4
3a004b0: 80 54 40 00 subicc gr4,0,gr0,icc0
3a004b4: a0 18 00 02 beq icc0,0x0,3a004bc <mb93403_serial_putc+0x4c>
3a004b8: c0 1a ff f4 bra 3a00488 <mb93403_serial_putc+0x18>
3a004bc: 88 41 08 0c addi gr16,-2036,gr4
3a004c0: 8a 08 41 00 ld @(gr4,gr0),gr5
3a004c4: 88 c0 2f ff ldsbi @(fp,-1),gr4
3a004c8: 88 a0 40 18 slli gr4,24,gr4
3a004cc: 88 0c 50 80 st gr4,@(gr5,gr0)
3a004d0: 8a c8 20 08 ldi @(fp,8),gr5
3a004d4: 84 08 21 00 ld @(fp,gr0),fp
3a004d8: 82 40 10 18 addi sp,24,sp
3a004dc: 80 30 50 00 jmpl @(gr5,gr0)
......
03a01aa0 <printf>:
3a01aa0: 82 40 1f c8 addi sp,-56,sp
3a01aa4: 85 48 10 10 sti fp,@(sp,16)
3a01aa8: 84 40 10 10 addi sp,16,fp
3a01aac: 88 0d 01 c5 movsg lr,gr5
3a01ab0: 8b 48 20 08 sti gr5,@(fp,8)
3a01ab4: 91 4c 20 10 stdi gr8,@(fp,16)
3a01ab8: 95 4c 20 18 stdi gr10,@(fp,24)
3a01abc: 99 4c 20 20 stdi gr12,@(fp,32)
3a01ac0: 91 48 2f fc sti gr8,@(fp,-4)
3a01ac4: 90 f8 03 a0 sethi 0x3a0,gr8
3a01ac8: 90 f4 3b 2c setlo 0x3b2c,gr8
3a01acc: 92 fc 00 00 setlos lo(0x0),gr9
3a01ad0: 94 fc 02 00 setlos 0x200,gr10
3a01ad4: 80 3c 00 c3 call 3a01de0 <memset>
3a01ad8: 88 40 20 28 addi fp,40,gr4
3a01adc: 88 40 4f ec addi gr4,-20,gr4
3a01ae0: 89 48 2f f8 sti gr4,@(fp,-8)
3a01ae4: 90 f8 03 a0 sethi 0x3a0,gr8
3a01ae8: 90 f4 3b 2c setlo 0x3b2c,gr8
3a01aec: 92 c8 2f fc ldi @(fp,-4),gr9
3a01af0: 94 c8 2f f8 ldi @(fp,-8),gr10
3a01af4: 80 3c 04 43 call 3a02c00 <vsprintf>
3a01af8: 88 88 80 00 ori gr8,0,gr4
3a01afc: 89 44 2f f6 sthi gr4,@(fp,-10)
3a01b00: 90 f8 03 a0 sethi 0x3a0,gr8
3a01b04: 90 f4 3b 2c setlo 0x3b2c,gr8
/*
* BUG ?!
* It should be "call 03a00470 <puts>"
*/
3a01b08: fe 3f ff 00 call 3a01708 <readline+0x188>
3a01b0c: 8a c8 20 08 ldi @(fp,8),gr5
3a01b10: 84 08 21 00 ld @(fp,gr0),fp
3a01b14: 82 40 10 38 addi sp,56,sp
3a01b18: 80 30 50 00 jmpl @(gr5,gr0)
3a01b1c: 00 00 00 00 add.p gr0,gr0,gr0
It is very strange that when change the printf function implementation, everything is ok.
The following is my new printf implemtentation:
void printf(const char *fmt, ...)
{
va_list args;
u16 i;
memset(printbuffer, 0, CONSOLE_BUFFER_SIZE);
va_start(args, fmt);
/* For this to work, printbuffer must be larger than
* anything we ever want to print.
*/
i = vsprintf(printbuffer, fmt, args);
va_end(args);
/* Print the string */
if (console)
console->puts(printbuffer);
} /* end of printf(...) */
========================================================
真情回馈 超值优惠 VIP邮箱买一送四 买三送十二! http://vip.163.com
中国最大的免费邮箱在等你 25兆空间4兆附件! http://mail.163.com
点击网易泡泡惊喜无限 全免费手机短信任你发! http://popo.163.com