linking error is reported when Runtime.PPCEABI.H.a is not present.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

linking error is reported when Runtime.PPCEABI.H.a is not present.

Jump to solution
1,114 Views
ShawnBai
Contributor III

Hello, guys,

 

     Here is a question about Codewarrior's linking.

    

     Before this question comes up,   we link our program together with "Runtime.PPCEABI.H.a" supplied by Codewarrior. And it goes well.

 

     But when "Runtime.PPCEABI.H.a" is not present in our project,  there are more than 100 similar linking errors coming up, like "undefined _savegpr_23", "undefined _savegpr_27", etc.

 

     In my opinion, it seems that if possible, CodeWarrior will use general purpose registers to store local variables in function block,

 

     The sample code goes below:

 

U32 flash_block_erase(U32 addr_first, U32 addr_last)
{
    U32 flag = 0;
    U32 base = 0;
    U32 block_first = 0;
    U32 tmp = 0;
    U32 num = 0;
    U32 index = 0;
    U32 ret = ERROR_NONE;
    U32 base_addr[NOR_FLASH_BANKS_NUM] = NOR_FLASH_BASE_ADDR_SET;
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Link error is as follows:
 
Link Error   : undefined: '_savegpr_23'
Referenced from 'flash_block_erase' in nor_flash.o
Link Error   : undefined: '_restgpr_23'
Referenced from 'flash_block_erase' in nor_flash.o
 .......
Link Error   : too many link errors
Link failed.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
The result of disassmble of sample code using CodeWarrior is below:
 
Hunk: Kind=HUNK_GLOBAL_CODE     Name="flash_block_erase"  Size=388
Source file (.debug):          nor_flash.c
Producer:             MW EABI PPC C-Compiler
 
;  632: U32 flash_block_erase(U32 addr_first, U32 addr_last) 
;  633: { 
000006E8: 00000000: 9421FFC0  stwu     rsp,-64(rsp)
000006EC: 00000004: 7C0802A6  mflr     r0
000006F0: 00000008: 90010044  stw      r0,68(rsp)
000006F4: 0000000C: 39610040  addi     r11,rsp,64
000006F8: 00000010: 48000001  bl       _savegpr_23
000006FC: 00000014: 7C771B78  mr       r23,r3
00000700: 00000018: 7C982378  mr       r24,r4
;  634:     U32 flag = 0; 
00000704: 0000001C: 3B400000  li       r26,0
;  635:     U32 base = 0; 
00000708: 00000020: 3BC00000  li       r30,0
;  636:     U32 block_first = 0; 
0000070C: 00000024: 3BA00000  li       r29,0
;  637:     U32 tmp = 0; 
00000710: 00000028: 3B800000  li       r28,0
;  638:     U32 num = 0; 
00000714: 0000002C: 3B200000  li       r25,0
;  639:     U32 index = 0; 
00000718: 00000030: 3BE00000  li       r31,0
;  640:     U32 ret = ERROR_NONE; 
0000071C: 00000034: 3B600000  li       r27,0
;  641:     U32 base_addr[NOR_FLASH_BANKS_NUM] = NOR_FLASH_BASE_ADDR_SET; 
;  642:      
00000720: 00000038: 80000000  lwz      r0,@205@sda21
00000724: 0000003C: 90010008  stw      r0,8(rsp)


    

     Does anybody has experience in dealing with this kind of errors ?

 

     Any suggestion is welcome.

 

     Thanks in advance.

 

Best Regards,

Shawn

Labels (1)
0 Kudos
1 Solution
600 Views
stanish
NXP Employee
NXP Employee

Hi ShawnBai,

 

As far as I know It's not possible to force the compiler to allocate the local variables on stack. The local variables are being placed according to the spec. defined by EABI standard. You can change the ABI used.

 

What is the goal of having the loacal variables on stack rather then in registers?

 

BTW: how do you use ANSI-C libraries routines e.g. printf, strcpy,...they are located in a library (MSL/EWL) as well...

 

Stanish

 

View solution in original post

0 Kudos
6 Replies
600 Views
JohnPan
Contributor I

Hello, Shawn,

 

I have the same question with you.

 

For some special purpose, I don't want to use the runtime library in my project.

 

Besides to  add runtime.c into the project, have you found any other good methods to fix this problem?

 

Best regards,

John 

 

0 Kudos
600 Views
ShawnBai
Contributor III

And, if we donot want Runtime.PPCEABI.H.a to involve in our project, what shoud we do ?

0 Kudos
600 Views
stanish
NXP Employee
NXP Employee

Hi ShawnBai,

 

Which specific CodeWarrior do you use?

You can add the runtime source files into your project to get rid of runtime library.

E.g. _savegpr* and _restgpr* are implemented in the file runtime.c located here (in case of CodeWarrior for MPC55xx/56xx):

 

"<CW for MPC55xx and MPC56xx>\PowerPC_EABI_Support\Runtime\Src\runtime.c"

You should be aware that runtime library includes also other important runtime routines e.g. 64bit integer arithmetic, casting routines, startup code, etc...

 

 

Stanish

0 Kudos
600 Views
ShawnBai
Contributor III

Hi, Stanish,

 

Which specific CodeWarrior do you use?

 

  You mean for which processor's family?

  It's MPC83xx serial.

 

 

 

Ya, you are right, file runtime.c may be what we need.

 

Actually, we just want Codewarrior to be a compiler, linker, loader, debugger for our project, and we do not want to depond on source code or archive or object file it supplies.

 

we have rewritten startup code for our board according to U-BOOT.

 

we are minimizing code size of our project.

 

To the end,

what should we do to make local variables allocate in stack, not registers  by default?

 

Thanks.

 

0 Kudos
601 Views
stanish
NXP Employee
NXP Employee

Hi ShawnBai,

 

As far as I know It's not possible to force the compiler to allocate the local variables on stack. The local variables are being placed according to the spec. defined by EABI standard. You can change the ABI used.

 

What is the goal of having the loacal variables on stack rather then in registers?

 

BTW: how do you use ANSI-C libraries routines e.g. printf, strcpy,...they are located in a library (MSL/EWL) as well...

 

Stanish

 

0 Kudos
600 Views
ShawnBai
Contributor III

Hi, Stanish,

 

    Actually,  wanting to use local variabls in stack is the consequence of removing runtime libraries supplied by CodeWarrior.

 

   As I say before,  it seems that,  by default,  local variables is allocated in general purpose registers, So, in my opinion, if we can allocate these local variabls in stack,   it should be enough to move runtime libraries away.

 

  Truthfully,  I am not very familiar with EABI standard.

  As you said, if locating variables in gpr is the behavior of EABI,   and if we wanna go on together with EABI, it seems that this is an impossible mission.

 

Speaking of ANSI-C libraries routines, in fact, we do not use them often,  that is, thers is no strong requirement of them.

If needded,  the usual way we goes is to impliment them ourself.

 

Next, I will go to specs standardized by EABI to learn more about how to locate variable reigsters.

 

Thanks.

0 Kudos