Main

11.1 EDK - "ERROR: relocation truncated to fit: R_PPC_REL24 myFunction"

AR# 20068

Search For Another Answer

Topic EDK-GNU
Last Updated 11/19/2009
Status Active
Description

Keywords: R_PPC, link, powerpc-eabi-ld

When I attempt to link a PowerPC application that contains functions separated by more than 26 bits of address space, the following error message appears:

"Error: relocation truncated to fit: R_PPC_REL24 <myFunction>"

Solution

The default assembly command used by the GCC compiler to branch to a new function is "bl," which allows at most a 26-bit offset to the current address. If a function is separated from the function from which it is called by greater than 26 bits, the attribute "longcall" can be placed on the function in C to specify that the compiler must use a longer branch to reach the function. This can be specified, as follows, in the function declaration:

void myFunction(void) __attribute__ ((longcall));

Solution 2
You can make all functions perform a long jump by adding the following option to the extra compiler switches:

-mlongcall

Solution 3
Alternatively, the function can be called as a function pointer, which is treated as being inherently FAR by the compiler.

Example:

void myFunction(void) {/*your code here*/};

int main()
{
void (*f2)(void);
f2 = myFunction;
f2();
}

Solution 4
Finally, a function can also be called as a pointer with an absolute address; for example, a jump from a bootloader to the start address of code.

Example:

int main()
{
void (*f2)(void);
f2 = (void *) 0x00001000;
f2();
}



 
 
/csi/footer.htm