This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Symbol relocation Error

Hi, I am using code gen tools 7.3 and i have this error,

warning: relocation from function "..." to symbol "..." overflowed; the 31-bit relocated address ... is too large to encode in the 31-bit signed PC-relative field.

Can someone tell me what does this mean and how to resolve it please.

  • What compiler options are you using, specifically any --mem_model options? If you are using some specific mem_model options, does the error go away when you remove them?

    This wiki article gives some background on relocation overflow errors, what could cause them and some solutions.

  •  

    The relocation overflow error is generated when the symbol referred to is out of range from the point at which the symbol is referenced.

    For example, if you were using a BDEC instruction to refer to an external symbol:

    .global ext_sym

    f1:

    ...

    BDEC ext_sym, A10

    ...

    The object generated by the compiler/assembler would contain an R_C6000_PCR_S10 relocation. That relocation type requires that the symbol "ext_sym" be within 10-bits of the BDEC instruction that references it when the file containing the BDEC instruction and the file containing the definition of "ext_sym" are linked together. If the definition of "ext_sym" is out of range, then the linker will generate a relocation overflow error.

    For your case, the relocation in question is likely an R_C6000_PREL31 type relocation, which is typically used in code that is generated to handle exceptions.

    Can you run "ofd6x -v file.obj" on the file that is mentioned in the relocation overflow error message? This should give you information about what relocation type is responsible for the relocation error. If you then look at a linker-generated map file to find the address of the symbol that is being referenced by the offending relocation, then you should be able to see whether the referenced symbol is actually in range of the relocation that generated the overflow.

    You may be able to avoid the relocation overflow error by changing the placement of either the reference to the symbol or the definition of the symbol.

    Regards,

    Todd Snider

    C6000 Code Generation Tools Team

    Texas Instruments Incorporated

  • I've read the article, but those are about variables, but the relocations are for functions.

    The warning does not go away even after I have changed the --mem_model to "far". I didn't set anything during my initial compilations.

  • The relocation is indeed the R_C6000_PREL31. The number of symbols that are relocated are numerous. Is there any other way to resolve the issue because the .OUT file could be generated but the linker gives a warning indicating that the .OUT file cannot be executed in the target.

  • The R_C6000_PREL31 relocation type is used in support of exception handling.

    Have you been able to verify that the location of the R_C6000_PREL31 relocation is out of range from the definition of the symbol it is referring to?

    If the symbol is within range (signed 31-bits) of the PREL31 relocation, then this is a defect in the linker. If this turns out to be the case, can you submit a defect report to support@ti.com and include a small test case that demonstrates the problem?

    - Todd