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.

Compiler/TMS320F28377D: retain a section of code from a library

Part Number: TMS320F28377D

Tool/software: TI C/C++ Compiler

Hi,

I am working on a library project which builds a .lib. I have a section of code written in assembly in an assembly file that I would like to retain in another project. The functions defined in these assembly sections are not called directly.

The section I am trying to retain is in a library, and local in scope. The #pragma RETAIN won't work because it is in assembly. I did look at what the #pragma generates in a compiled assembly file and duplicated that, however it still does not work.
Attached is what I added in my assembly file.
Unfortunately, the section in the project which includes the library is empty. The data/code is not retained in the project.
How can I retain this section of code in a library to another CCS project?
sal
  • In the main CCS project, add the linker option --undef_sym=_STL_CLA_seg01start.  Please read about that option in the C2000 assembly tools manual.  Note the retain (pragma or directive) is not necessary.

    For others reading this thread ... If you experience this situation, and the library function you want to force into the build is written in C/C++, then there is an additional detail to consider.  The C2000 tools version 16.9.x.LTS and older only support COFF ABI.  Under that ABI, symbols written in C/C++ have an underscore added to the beginning when written in assembly.  All other TI compilers default to the newer EABI.  Under EABI, a symbol is written the same way in both C/C++ and assembly.  In such a case, you would use something like --undef_sym=lib_function_to_force.

    Thanks and regards,

    -George

  • Hi George,

    I have 28 of these sections in one asm file.

    It looks like I only need to do this for one section for it to retain all of them. Is that correct?

    sal
  • That is correct for COFF ABI.  But not for the new EABI, which is introduced in C2000 tools version 16.12.0.STS.  Under EABI, the linker is much more aggressive about removing sections that are not referenced.  Under EABI, you would need --undef_sym for all 28 sections.  That is not practical to manage from the command line.  Put them all in a dedicated command file, then supply that command file to the linker.

    It is unusual to have 28 sections that are not referenced.  Usually, there is just one, and that section contains the interrupt vector table.

    Thanks and regards,

    -George

  • George,

    The sections I am including are from a CLA assembly file. And I am getting some linker errors now.

    <Linking>

    INTERNAL ERROR: C:\ti\ccsv7\tools\compiler\ti-cgt-c2000_16.9.1.LTS\bin\lnk2000.exe failed to allocate memory

    This is caused by a defect in the compiler itself. TI Customer
    Support may be able to suggest a workaround to avoid this.

    Upgrading to the newest version of the compiler may fix this problem.

    Contact TI in the E2E support forums at http://e2e.ti.com under
    "Development Tools", "TI C/C++ Compiler". See the link titled
    "Submitting an issue". Include this ENTIRE error message and a
    copy of the .pp file created when option --preproc_with_comment
    (-ppc) is used.


    >> Compilation failure
    makefile:152: recipe for target 'test_application.out' failed
    gmake: *** [test_application.out] Error 1
    gmake: Target 'all' not remade because of errors.

    **** Build Finished ****

    After using the -ppc flag, i get this
    >> ERROR: no source files, nothing to do

    and it tells me no dependency graph was generated.

    sal
  • I narrowed down the sections which are causing the trouble.

    There are three sections in the .asm file which work with each other. The ASM code branches and calls/returns between these 3 different code sections.

    Once I include a linker command option flag for any of these three sections, I get the linking error. ANd the project is unable to linker properly.

    sal
  • Unfortunately, the only way to make progress on ...

    Sal Pezzino said:
    INTERNAL ERROR: C:\ti\ccsv7\tools\compiler\ti-cgt-c2000_16.9.1.LTS\bin\lnk2000.exe failed to allocate memory

    ... is to reproduce the behavior ourselves.  And for that, we need a test case from you.  In this particular situation, we need you to submit the full CCS project.  Please see this post for the details.

    Thanks and regards,

    -George

  • You can see the problem -undef_sym in the STA_F2837xD_RAM_CPU!_CLASWBIST.cmd

    sal

    claswbist_LinkError.zip

  • I am unable to reproduce the problem.  I'm not sure why, but the linker command file is not present.  Please try collecting the project together with the method described in this forum post.

    Thanks and regards,

    -George

  • I followed the forum post the first time. I did the archive and created a ZIP.

    STA_F2837xD_RAM_CPU1.zip