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.

Linker Bug

Other Parts Discussed in Thread: CCSTUDIO

Hi,

I have a Problem with the linker (CGT 6.1.11 / CGT 6.1.12). It hangs up during linking.

__________________________________________________________________
The scenario (3 Files):

Global.cpp:
#pragma DATA_SECTION(".uid");
unsigned int g_uiUniqueId;

Global.hpp:
extern unsigned int g_uiUniqueId;

Main.cpp:
#include "Global.hpp"

int main()
{
  unsigned int test = g_uiUniqueId;
}

__________________________________________________________________

If I don't use g_uiUniqueId in main.cpp, all works perfect.
If the #pragma DATA_SECTION in Global.cpp is removed, it also works perfect.
It seems that the linker hangs up during linking main, when the DATA_SECTION pragma is used.

Regards,
Joe

  • Have you defined the section ".uid" in your linker command file?

    What compiler switches do you use?

  • Sure, I've defined the section ".uid" in my linker file. If I use the variable "g_uiUniqueId" in Global.cpp all works fine and it is linked to the right address. Only when I use it outside, linker hangs up.

    Compiler:
    -g -pdsw225 -fr"$(Proj_dir)\_ObjectFiles" -i"D:\Projekte\App\embedded\App_PRJ\Main" -i"C:\CCStudio_v3.3\c64plus\dsplib_v210" -d"_DEBUG" -d"DSP_BIOS" -d"TMS320C674X" -d"EROA_ALIGNMENT" -d"RAM_TEST" -mv6740

    Linker:
    -c -m".\Debug\App.map" -o".\_Binary\App.out" -w -x

  • Have you tried maybe adding the pragma in the header file as well?

    Global.cpp:

    #pragma DATA_SECTION(".uid");
    unsigned int g_uiUniqueId;

    Global.hpp:

    #pragma DATA_SECTION(".uid");
    extern unsigned int g_uiUniqueId;

  • Same Problem. Linker hangs up and if the pragma is in the header, there is the warning:

    pragma DATA_SECTION can only be applied to a file level symbol definition, not...

  • What processor are you using?

    Did it work for older versions of CGT?

    Can you provide a simple test case where the issue occurs?

     

  • We use the C6747.

    No, I tried with 6.1.9/11/12.

    You find the simple test case in the first post above:
    __________________________________________________________________
    The scenario (3 Files):

    Global.cpp:
    #pragma DATA_SECTION(".uid");
    unsigned int g_uiUniqueId;

    Global.hpp:
    extern unsigned int g_uiUniqueId;

    Main.cpp:
    #include "Global.hpp"

    int main()
    {
      unsigned int test = g_uiUniqueId;
    }

    __________________________________________________________________

     

  • Hi Joachim,

    I tried the test case and got the error:

    <Linking>
    "main.cpp", line 11: warning: relocation type is static base-relative, but
       references symbol "_g_uiUniqueId" defined in section ".uid"; references to
       section ".uid" are not relative to any static base, so this relocation
       cannot be performed (type = 'R_C60BASE' (80), file =
       "C:\\CCStudio_v3.3\\boards\\evmc6747_v1\\dsp\\tests\\Copy of
       led\\Debug\\main.obj", offset = 0x00000004, section = ".text")
    warning: output file "./Debug/led.out" cannot be loaded and run on a target
       system

    I could solve it replacing:

    extern unsigned int g_uiUniqueId;

    with

    extern far unsigned int g_uiUniqueId;

     

       In C6x compiler manual, 6.8.4, page 136, The DATA_SECTION Pragma, it says the following:

     

    The DATA_SECTION pragma is useful if you have data objects that you want to link into an area separate

    from the .bss section. If you allocate a global variable using a DATA_SECTION pragma and you want to

    reference the variable in C code, you must declare the variable as extern far.

     

  • Hi Mariana,
    It works. Thanks a lot.

    My CCS 3.3 never showed me this wonderful message ;-). It simply stopped after <Linking>.

  • My test also showed the message that Mariana listed, even going back to CGT 6.0.8. And this message should only be related to the CGT version, not directly to CCS.

    My CCS version is 3.3.82.13 which is SR12. If you are on an earlier version, you should update it to see if this fixes some of your related problems like this message/linker hang.