UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 20068

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

Description

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();

}

AR# 20068
Date Created 09/03/2007
Last Updated 12/15/2012
Status Active
Type General Article