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.

[FAQ] TDA4VM: C7x compiler status on address beyond +/- 2GB

Part Number: TDA4VM

The following error is seen during compilation when we increase the size of C7x scratch or C7x Local heap

Linking /home/nikhil/SDK_8.4/ti-processor-sdk-rtos-j721e-evm-08_04_00_06/vision_apps/out/J7/C71/FREERTOS/release/vx_app_rtos_linux_c7x_1.out
"/home/nikhil/SDK_8.4/ti-processor-sdk-rtos-j721e-evm-08_04_00_06/ti-cgt-c7000_3.0.0.STS/include/string.h", line 275: error:
   relocation from function "appInit" to symbol "g_ddr_local_mem" overflowed;
   the 33-bit relocated address 0x80096600 is too large to encode in the 32-bit
   signed PC-Relative field (type = 'R_C7X_PCR_OFFSET_ADDKPC_HI27' (33), file =
   "/home/nikhil/SDK_8.4/ti-processor-sdk-rtos-j721e-evm-08_04_00_06/vision_app
   s/out/J7/C71/FREERTOS/release/app_rtos_common_c7x_1.lib<app_init.obj>",
   offset = 0x000000000084, section = ".text")
error: errors encountered during linking;
   "/home/nikhil/SDK_8.4/ti-processor-sdk-rtos-j721e-evm-08_04_00_06/vision_app
   s/out/J7/C71/FREERTOS/release/vx_app_rtos_linux_c7x_1.out" not built

  • Reasoning

    On C7000 devices, all symbol references are handled in a position-independent manner through a PC-relative offset. However, linker-defined symbols may have a value that does not resolve to a valid symbol address or resolves to an address that is beyond the +/- 2 GB reach of normal PC-relative addressing.

    Let us consider a scenario to demonstrate this in J721e SDK 8.4

    The appInit (@ 0xab669980) in the code section of C7x could reach upto 2GB (i.e. till 0x12B669980).

    A variable g_ddr_local_mem (@ 0x12B700000) pointing to the C7X_1_LOCAL_HEAP_ADDR is being accessed by appInit. Since this variable is out of its reach, the below error is seen during compilation.

    Linking /home/nikhil/SDK_8.4/ti-processor-sdk-rtos-j721e-evm-08_04_00_06/vision_apps/out/J7/C71/FREERTOS/release/vx_app_rtos_linux_c7x_1.out
    "/home/nikhil/SDK_8.4/ti-processor-sdk-rtos-j721e-evm-08_04_00_06/ti-cgt-c7000_3.0.0.STS/include/string.h", line 275: error:
       relocation from function "appInit" to symbol "g_ddr_local_mem" overflowed;
       the 33-bit relocated address 0x80096600 is too large to encode in the 32-bit
       signed PC-Relative field (type = 'R_C7X_PCR_OFFSET_ADDKPC_HI27' (33), file =
       "/home/nikhil/SDK_8.4/ti-processor-sdk-rtos-j721e-evm-08_04_00_06/vision_app
       s/out/J7/C71/FREERTOS/release/app_rtos_common_c7x_1.lib<app_init.obj>",
       offset = 0x000000000084, section = ".text")
    error: errors encountered during linking;
       "/home/nikhil/SDK_8.4/ti-processor-sdk-rtos-j721e-evm-08_04_00_06/vision_app
       s/out/J7/C71/FREERTOS/release/vx_app_rtos_linux_c7x_1.out" not built

    Solution

    When accessing such symbols, you must use the _symval() intrinsic to force the use of absolute addressing. Such addressing prevents the compiler from generating PC-relative offsets/relocations for symbols that don't actually correspond to addresses or to addresses that are beyond the +/- 2 GB reach of PC-relative addressing.

    Considering our example scenario, we could use _symval(g_ddr_local_mem) inside appInit() function.

    The following information is available in the SPRUIG8E_C7000_Compiler_Users_Guide.pdf available in the SDK in the section 12.6 Linker Symbols

    ${PSDKRA}/ti-cgt-c7000_3.0.0.STS/docs/SPRUIG8E_C7000_Compiler_Users_Guide.pdf

    Regards,
    Nikhil Dasan