AnsweredAssumed Answered

How to link gcc object files with __eabi calls in main

Question asked by Sean Kauffman on Mar 3, 2016
Latest reply on Dec 18, 2017 by stanish

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




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.