How to link gcc object files with __eabi calls in main

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

How to link gcc object files with __eabi calls in main

1,784 Views
seanmkauffman
Contributor I

I'm using CodeWarrior 5.9 and an MPC5554, which is a PowerPC chip with an e500mc core.

 

I am compiling some C code for my project, including the file with main, using a GCC cross compiler.  I need to link using CodeWarrior, though.  GCC adds a call to __eabi at the start of main, which is something that cannot be removed.  It's added by the compiler, which expects it to be provided by the crt.

 

This can be fixed by simply adding an __eabi function to the files from CodeWarrior.  In __ppc_eabi_init.c I added the function:

 

asm extern void __eabi(void)

{

    addis   r13,r0,_SDA_BASE_@h

    ori     r13,r13,_SDA_BASE_@l

    addis   r2,r0,_SDA2_BASE_@h

    ori     r2,r2,_SDA2_BASE_@l

    blr

}

 

Initially, when I tried this, I got a linker error.  However, this was because the function was accidentally placed inside an #ifdef block that was being excluded.

Labels (1)
0 Kudos
Reply
1 Reply

1,106 Views
stanish
NXP Employee
NXP Employee

Hello Sean,

I assume you are using S32DS e200 gcc compiler to build the code for MPC5554. This MCU contains e200 core.

GCC compiler indeed inserts an internal function __eabi() as a first calls in main() to perform initialization for EABI conformance.

I don't think it's good idea to mix object codes from two different compilers.

Anyway to overcome this error probably the easiest way is to rename main() to any other name.

GCC adds the __eabi() call into main() only.

Other approach is to add  a dummy __eabi() that does nothing just to make linker happy.

Hop it helps.

Stan

0 Kudos
Reply