AnsweredAssumed Answered

"relocation truncated to fit: R_PPC_VLE_REL24" when placing function in .data section

Question asked by vierman.gert on Mar 6, 2017
Latest reply on May 3, 2017 by vierman.gert

Hello,

 

Trying to make a workaround for the flash-not-ready-after-leaving-power-saving problem, I am placing the below function in a section which goes into the .data section:

 

__attribute__ (( __section__ ("halt"))) void halt0(void)
{
ME.HALT0.B.CFLAON = ME.RUN[0].B.CFLAON = 1;
ME.HALT0.B.DFLAON = ME.RUN[0].B.DFLAON = 1;

ME.MCTL.R = SPC5_ME_MCTL_MODE(SPC5_RUNMODE_HALT0) | SPC5_ME_MCTL_KEY;
ME.MCTL.R = SPC5_ME_MCTL_MODE(SPC5_RUNMODE_HALT0) | SPC5_ME_MCTL_KEY_INV;
while(ME.GS.B.S_MTRANS);

ME.RUN[0].B.CFLAON = 3;
ME.RUN[0].B.DFLAON = 3;

ME.MCTL.R = SPC5_ME_MCTL_MODE(SPC5_RUNMODE_RUN0) | SPC5_ME_MCTL_KEY;
ME.MCTL.R = SPC5_ME_MCTL_MODE(SPC5_RUNMODE_RUN0) | SPC5_ME_MCTL_KEY_INV;
while(ME.GS.B.S_MTRANS);
}

Calling this function from code in the .text segment cause the linker to fail with the message

relocation truncated to fit: R_PPC_VLE_REL24 against symbol `halt0' defined in flop section in arch/spc560/halt0.o

The exact reason for this error is not clear to me, as it is quite cryptic.

 

However - and this is the strange part - if I adjust the function and take out some code, the object compiles and links just fine. For example, remove the last 3 lines, and the problem is gone.

 

Can anyone explain what exactly causes the error message, and if there is a workaround for this?

Outcomes