Code generation with powerpc-eabivle-gcc.exe

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Code generation with powerpc-eabivle-gcc.exe

ソリューションへジャンプ
2,566件の閲覧回数
devver
Contributor I

Hello,

I'm having an issue with the code generated by powerpc-eabivle-gcc.exe. 

When I compile this code

----------------

//#define COMPILE_WITHOUT_TRAP_INSTRUCTION

#ifdef COMPILE_WITHOUT_TRAP_INSTRUCTION
#define FLASH_SECTOR_ADDRESS 0x00000004
#else
#define FLASH_SECTOR_ADDRESS 0x00000000
#endif

unsigned int MyFunc(void);

typedef struct {
unsigned char * Buffer;
} tProgFlash;

tProgFlash ProgFlash;

unsigned int MyFunc(void)
{
unsigned int CmdResult = 0;
if( *((unsigned int *) FLASH_SECTOR_ADDRESS) == 0xFFFFFFFF ) {
ProgFlash.Buffer = 0;
}
return CmdResult;
}

----------------

The output of powerpc-eabivle-objdump.exe is this:

Disassembly of section .text.MyFunc:

00000000 <MyFunc>:
0: 48 07 se_li r7,0
2: c0 77 se_lwz r7,0(r7)
4: 7f e0 00 08 trap

The full command prompt I use to compile:

"C:/SysGCC/powerpc-eabi/bin/powerpc-eabivle-gcc.exe" -c -O2 -g3 -Wall -c -fmessage-length=0 -ffunction-sections -fdata-sections -mcpu=e200z3 -mbig -mvle -mregnames -mhard-float -meabi -Werror -specs="C:/SysGCC/powerpc-eabi/powerpc-eabivle/lib/e200z3/nosys.specs" -I"C:/SysGCC/powerpc-eabi/powerpc-eabivle/include" --sysroot="C:/SysGCC/powerpc-eabi/powerpc-eabivle/lib/e200z3/" -MMD -MP -MF"Test.d" -MT"Test.o" -c -o "Test.o" "Test.c"

The version I'm using:

powerpc-eabivle-gcc.exe (BLD = 1607) 4.9.4 20160726 (build.sh rev=gceb1328 s=F494 -i /opt/freescale ELe200 -V release_gceb1328_build_Fed_ELe200_ML3)

With optimisation level O1 the trap instruction is not generated. When using the define "

COMPILE_WITHOUT_TRAP_INSTRUCTION" the code compiles perfectly, even with O2.

Can you please help out?

Thanks in advance.

ラベル(1)
1 解決策
2,259件の閲覧回数
martin_kovar
NXP Employee
NXP Employee

Hello,

please see the information below:

There is a conflict with the C language: NULL is defined as 0x00000000 and it must represent an invalid address, but you want to access 0x00000000 as a valid address. You can't have both. (BTW, this "feature" is architecture independent.)

  • Either we create a new system where NULL is something else (it is not going to happen because it would not be ABI compatible),
  • or you tell the compiler to not search for NULL pointer checks (see flag bellow),
  • or you change your code to use some other address (If you just want to check the presence of flash, any address that lies on the same page as address zero would work)

powerpc-eabivle-gcc -S -O2 test.c -fno-delete-null-pointer-checks

Results in:

MyFunc:
se_li 6,0
se_lwz 7,0(6)
e_cmp16i 7,-1
e_beq 0,.L4
se_li 3,0
se_blr
.L4:
e_lis 7,ProgFlash@ha
se_li 3,0
e_stw 6,ProgFlash@l(7)
se_blr

Regards,

Martin

元の投稿で解決策を見る

1 返信
2,260件の閲覧回数
martin_kovar
NXP Employee
NXP Employee

Hello,

please see the information below:

There is a conflict with the C language: NULL is defined as 0x00000000 and it must represent an invalid address, but you want to access 0x00000000 as a valid address. You can't have both. (BTW, this "feature" is architecture independent.)

  • Either we create a new system where NULL is something else (it is not going to happen because it would not be ABI compatible),
  • or you tell the compiler to not search for NULL pointer checks (see flag bellow),
  • or you change your code to use some other address (If you just want to check the presence of flash, any address that lies on the same page as address zero would work)

powerpc-eabivle-gcc -S -O2 test.c -fno-delete-null-pointer-checks

Results in:

MyFunc:
se_li 6,0
se_lwz 7,0(6)
e_cmp16i 7,-1
e_beq 0,.L4
se_li 3,0
se_blr
.L4:
e_lis 7,ProgFlash@ha
se_li 3,0
e_stw 6,ProgFlash@l(7)
se_blr

Regards,

Martin