This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Help about mipsel-linux-gcc 4.1.2 asm codes.
- From: "Sync ma" <sync dot jma at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 10 Jul 2007 15:57:27 +0800
- Subject: Help about mipsel-linux-gcc 4.1.2 asm codes.
Hi, all:
I'm confused about asm codes generator by mipsel-linux-gcc,
.text_rom:9000F788 lw $v1, 0x148+arg_4($fp)
.text_rom:9000F78C lw $v0, 0($v1)
as I know, mips has a load delay slot, and there should not be any
instruction use reg '$v1' before the slot on this situation.
am I right? or have I missed anything?
asm codes seems have not notice that, and a invalid argv[0] address
passed to the called function.
here are asm codes(disasm by IDA):
.text_rom:9000F760 get_ftype:
.text_rom:9000F760
.text_rom:9000F760 var_138 = -0x138
.text_rom:9000F760 var_134 = -0x134
.text_rom:9000F760 var_128 = -0x128
.text_rom:9000F760 var_124 = -0x124
.text_rom:9000F760 var_120 = -0x120
.text_rom:9000F760 var_18 = -0x18
.text_rom:9000F760 var_14 = -0x14
.text_rom:9000F760 var_10 = -0x10
.text_rom:9000F760 var_8 = -8
.text_rom:9000F760 var_4 = -4
.text_rom:9000F760 arg_0 = 0
.text_rom:9000F760 arg_4 = 4
.text_rom:9000F760 arg_8 = 8
.text_rom:9000F760
.text_rom:9000F760 addiu $sp, -0x148
.text_rom:9000F764 sw $ra, 0x148+var_4($sp)
.text_rom:9000F768 sw $fp, 0x148+var_8($sp)
.text_rom:9000F76C move $fp, $sp
.text_rom:9000F770 sw $a0, 0x148+arg_0($fp)
.text_rom:9000F774 sw $a1, 0x148+arg_4($fp)
.text_rom:9000F778 sw $a2, 0x148+arg_8($fp)
.text_rom:9000F77C sw $0, 0x148+var_124($fp)
.text_rom:9000F780 li $v0, 1
.text_rom:9000F784 sw $v0, 0x148+var_128($fp)
.text_rom:9000F788 lw $v1, 0x148+arg_4($fp)
.text_rom:9000F78C lw $v0, 0($v1)
.text_rom:9000F790 bnez $v0, loc_9000F7A4
.text_rom:9000F794 lw $v0, 0x148+arg_4($fp)
.text_rom:9000F798 li $v0, 0xFFFFFFFF
.text_rom:9000F79C j loc_9000F93C
.text_rom:9000F7A0 sw $v0, 0x148+var_10($fp)
src code:
Status get_ftype( int argc, char *argv[], unsigned int *id)
{
char ftype[2];
FFS_FILE *p_file = 0;
IMAGE_PREFIX Image;
Status status = SBL_FILECONTINUE;
int len;
unsigned int *buf_ptr;
if( !argv[ 0 ] )
return SBL_EFAILURE;
if( (p_file = fopen( argv[0], "r" )) == NULL )
{
return SBL_EFAILURE;
}
.........// other code
}
Compile options:
-march=mips32 -mtune=r4600 -mabi=32 -G 0 -ansi -fno-builtin
-fdelayed-branch -fthread-jumps -fno-pic -mno-abicalls -O0 -g
-fschedule-insns2 -msoft-float
gcc version:
# mipsel-linux-uclibc-gcc -v
Using built-in specs.
Target: mipsel-linux-uclibc
Configured with: xxxx/gcc-4.1.2/configure --prefix xxxxx
--build=i386-redhat-linux --host=i386-redhat-linux
--target=mipsel-linux-uclibc --enable-languages=c,c++ --enable-shared
--disable-__cxa_atexit --enable-target-optspace --with-gnu-ld
--disable-nls
Thread model: posix
gcc version 4.1.2