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.

Relocation Overflow error

Hi,

I have an error I can't understand. I searched on net but the solution I found didn't work.

error: relocation overflow occurred at address 0x00002594 in section
            '.text' of input file
            'S:\\ddx4\\ddx4\\dsp\\bootrom\\dtxa_6437\\Debug\\Netas_command_line.obj'.  The 16-bit relocated address 0x9cb8 is too large to encode in the 15-bit field. You may need to add a mask to the assembly instruction or use other target specific assembly features if you really only need the lowest 15 bits of this symbol. Please see the section on Relocation in the Assembly User's Guide.

There are about ten errors like this.

In the Sections part in cmd, text is defined as:

.text               : {} > FLASH   run = IPRAM,   LOAD_START(FLASH_TEXT_START),     RUN_START(RAM_TEXT_START),         SIZE(TEXT_SIZE)

IPRAM is a location from internal memory (L2 Cache)

I don't think there is insufficient memory in IPRAM, the source of the problem may be something else.

Do you have any suggestions for this problem?

Thanks,

Erman

 

  • It seems you have run into the very reason you need .far variables as we had been discussing in your prior thread. So to go into detail on this we can discuss the way memory accesses happen on a C6x.

    Essentially, on the C64x processor, you have 32-bit instructions.  Inside the 32-bit instruction, you can only access memory based on the offset of a CPU register.  One of the CPU registers is used as the data pointer register for near memory when writing C code.  Whenever you access near memory, the CPU will use 15 bits of the 32-bit instruction as the offset from the data pointer register.  For this reason, the .bss near data memory section is limited to 2^15 = 32k bytes of memory that can be accessed in a single CPU cycle, since it is always addressable.

    However, to get access to the remainder of the memory map, you have far memory as well.  Far memory requires that you use an MVKL and MVKH set of instructions to build the absolute 32-bit address of the memory you wish to access.  For this reason, all data memory outside of the near memory section will take 3 CPU cycles to access, because the compiler must build the instructions to access the memory.

    So what our compiler will do in default is make all global single element variables near variables, and all aggregate array memory far variables.  Typically, this will work just fine but in your case this error is saying that some code in your executable is trying to access a variable in a 'near' fashion that is not near enough (i.e. it cannot fit the offset it would need within the 15 bit offset field),

    However, if you would like to improve upon this performance, or if you run out of near memory space, as it appears has happened in your case, there are some options available to you.

    1. Inside your CCS "Project" -> "Build Options", go to the "Compiler" tab, and then the "Advanced" category.  Here, you will find an option called "Memory Models".  If you select "--mem_model:data=far", this will resolve your issue because it will make all global memory far memory data.  However, please note that this is not the most efficient way to do things (all memory accesses now take 3 instructions).

    2. Another thing you can do is use the "near" and "far" keywords with all of your global variables.  This way, you can individually configure variables to be either near or far memory.  This is what I would recommend doing as it will allow you to still take advantage of near memory for the 32kB worth of variables that you access most often.  This is the most efficient solution.

  • There is a wiki article about this entire topic http://tiexpressdsp.com/wiki/index.php?title=C6000_Memory_models .

    Thanks and regards,

    -George

  • Hi,

    Thanks Bernie, this was a great explanation, and thanks Georgem for the link.

    However the problem still continues, although all the related variables are defined as far and their externs far too.

    warning: Detected a near (.bss section relative) data reference to the symbol
                _dtxa_test_common_msg_count defined in section .external.  The
                reference occurs in
                S:\\ddx4\\ddx4\\dsp\\bootrom\\dtxa_6437\\Debug\\ethernet_rx_comm_functions.obj, section .intprog, SPC offset 00000648.  Either make the symbol near data by placing it in the .bss section, or make the references to the symbol far.  For C/C++ code use 'far' or 'near' modifiers on the type definition of the symbol or compile with the --mem_model:data switch.

    >>   error: relocation overflow occurred at address 0x00000648 in section
                '.intprog' of input file
                'S:\\ddx4\\ddx4\\dsp\\bootrom\\dtxa_6437\\Debug\\ethernet_rx_comm_functions.obj'.  The 17-bit relocated address 0x12877 is too large to encode in the 15-bit field. You may need to add a mask to the assembly instruction or use other target specific assembly features if you really only need the lowest 15 bits of this symbol. Please see the section on Relocation in the Assembly User's Guide.

    For example I define the variable in .c file

    far Uint32 var;

    and declare it in .h file

    extern far Uint32 var;

    Maybe there is something else it needs. For example when I use this variable, should cast it to far Uint32? Like

    (far Uint32)var = 0;

    Or maybe the far keyword needs to be in the first order at the declaration like far extern Uint32 var.

     

     

     

  • Neither of these compile. There has to be something else.

    In the error and warning message, the file (ethernet_rx_comm_functions) which references to the variable is in .bss section, I checked this from the .map file. .bss is in the internal memory. But the data (variable) is in DDR, defined and declared as far. As far as I understand there should be no problem after I add far.

  • Is the ethernet_rx_comm_functions.obj something that you are building in your project or is this being linked in from an existing binary? This sort of thing can happen if you are linking in something that was built with older tools that handled reloaction differently, but if everything is built at the same time than there must be some declaration somewhere that is not congruent.

  • I can all but guarantee that at the time ethernet_rx_comm_functions.c is built, the compiler thinks the variable dtxa_test_common_msg_count is near.  Figure out why that is, and you probably be able to fix this.

    Thanks and regards,

    -George

     

  • Hi,

    I am learning TI DSP with DSK 6713. I encounter the relocation overflow problem. The message is:

    ////////////////////

    error: relocation overflow occurred at address 0x00000020 in section
                '.text' of input file 'C:\ti\myprojects\FIRcirc\FIRcircfunc.obj'.
                The 16-bit relocated address 0x9300 is too large to encode in the
                16-bit signed field. The value was truncated. You may need to add a
                mask to the assembly instruction or use other target specific
                assembly features if you really only need the lowest 16 bits of
                this symbol. Please see the section on Relocation in the Assembly
                User's Guide.
    >> warning: output file 'FIRcirc.out' is not executable

    Build Complete,
      1 Errors, 1 Warnings, 0 Remarks.

    ////////////////////

    I have read some threads, but cannot solve my problem because the problem is not about variable, it is about "printf" function. When I comment out printf function, the compiling succeeds. The C routine is from book on DSK 6713 , fir circular buffer usage. I post the lnk command file here:

    /*Linker command file for FIR using circular buffer*/

    MEMORY
    {
    VECS
    : org= 0h, len= 0x220
    IRAM
    : org = 0x00000220, len = 0x0000FDC0
    SDRAM
    : org = 0x80000000, len = 0x01000000
    FLASH
    : org = 0x90000000, len = 0x00020000
    }

    SECTIONS
    {
    circdata
    :> IRAM
    vectors
    :> VECS
    .text :> IRAM
    .bss :> IRAM
    .cinit :> IRAM
    .stack :> IRAM
    .sysmem :> SDRAM
    .const :> IRAM
    .switch :> IRAM
    .far :> SDRAM
    .cio :> SDRAM
    }

    The C routine is:

    void

    main()
    {
    int x;
    int y=0;
    short s;

    comm_intr();
    //init DSK, codec, McBSP
    // while(1); //infinite loop
    for (x=0; x<128; x++)
    {
    y
    =fircircfunc(s,h,N);
    printf("y=%d");
    }
    }

    There is an assembler in this project:

    .def _fircircfunc
    .def last_addr
    .def delays
    .sect "circdata" ;circular data section
    .align 256 ;align delay buffer 256-byte boundary
    delays .space 256 ;init 256-byte buffer with 0's
    last_addr .int last_addr-1 ;point to bottom of delays buffer
    .text ;code section
    _fircircfunc: ;FIR function using circ addr
    MV A6,A1 ;setup loop count
    MPY A6,2,A6 ;since dly buffer data as byte
    ZERO A8 ;init A8 for accumulation
    ADD A6,B4,B4 ;since coeff buffer data as bytes
    SUB B4,1,B4 ;B4=bottom coeff array h[N-1]

    MVKL
    0x00070040,B6 ;select A7 as pointer and BK0
    MVKH 0x00070040,B6 ;BK0 for 256 bytes (128 shorts)

    MVC B6,AMR
    ;set address mode register AMR

    MVK last_addr,A9
    ;A9=last circ addr(lower 16 bits)
    MVKH last_addr,A9 ;last circ addr (higher 16 bits)
    LDW *A9,A7 ;A7=last circ addr
    NOP 4
    STH A4,*A7
    ++ ;newest sample-->last address

    loop
    : ;begin FIR loop
    LDH *A7++,A2 ;A2=x[n-(N-1)+i] i=0,1,...,N-1
    || LDH *B4--,B2 ;B2=h[N-1-i] i=0,1,...,N-1
    SUB A1,1,A1 ;decrement count

    [A1] B loop
    ;branch to loop if count # 0
    NOP 2
    MPY A2,B2,A6
    ;A6=x[n-(N-1)+i]*h[N-1+i]
    NOP
    ADD A6,A8,A8
    ;accumulate in A8

    STW A7,*A9
    ;store last circ addr to last_addr
    B B3 ;return addr to calling routine
    MV A8,A4 ;result returned in A4
    NOP 4

    What is wrong with my project? Thanks a lot

  • Hi,

    I want to add some more questions to my post.

    I know that the asm code and C code are in the same memory IRAM. I have tried to reduce IRAM length to smaller than 7FFF, but it refuses. The asm is very short while I cannot see the C code memory length (even though there is only one printf). If comment out printf, there is such relocation error. Because the compiling does not pass, I cannot see any map file, or list file. Could you give me some clues? thanks again.

  • Hi,

    I find the problem causing relocation error although I do not know the reason. When I comment out [sect "circdata"] in FIRcircfunc.asm and [ circdata :> IRAM] in FIRcirc.cmd, compiling succeeds. That is, the section definition circdata causes the relocation error when printf presents. What is the reason? Thanks in advance.

  • This article may help.

    Thanks and regards,

    -George