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/TMS570LS3137: CCSV8 using stubs for function, linker error #10056

Part Number: TMS570LS3137
Other Parts Discussed in Thread: TMDS570LS31HDK

Tool/software: TI C/C++ Compiler

Development kit:: "TMDS570LS31HDK Hercules Development Kit‎"

CCS version CCV8.

Compiler tool chain: ti-cgt-arm_18.1.1.LTS

For writing tests I have needs to provide stubs of the functions (one or more) implemented in one or more than one source files. I have used the '--gen_func_subsections' compiler options to put each function in its own section and see the effect in the .lst file. I have also used the linker option '--unused_section_elimination=on' explicitly even though the default is always on. But I still get error #10056 symbol redefined error during linking. using the option --diag_warning=10056 or --diag-remark=10056 does not downgrade the error to warning or remarks.

I have the stub obj before the actual obj implementing the actual functionality so the stub should get linked into the out file.

How can I suppress the 10056 error and have the stub take precedence over the actual implementation during linking?

I have referred this thread "https://e2e.ti.com/support/tools/ccs/f/81/t/218808?tisearch=e2e-sitesearch&keymatch=stub%2010056" but the recommendation in the thread to have each function in its own source file is useless.

  • If you have the same function defined in two object files in the same link, then the symbol redefined error is unavoidable.

    Here are two other ways to handle it that may solve your problem.  In this description, I will call one function definition primary and the other function definition secondary.  In the conditions described, it is not an error to have the same function defined twice, and the primary one is used.

    One method ... Make the secondary definition weak.  You can do this with #pragma WEAK or with the weak function attribute.  Both are described in the TI ARM compiler's manual.  Search it for the term weak.  

    Another method ... The secondary definition is in an object file that is inside a library.  If the primary definition is present, it gets used.  If the primary definition is not present, the secondary definition in the library gets used.

    Thanks and regards,

    -George

  • Thank you George. The proposed solution will not work for me.

    The primary definition is in the code that cannot be modified, the actual source.

    The stub may have weak binding, but in that case the stub will not be linked in.

    I am not an expert in CCS or the TI''s compiler tool chain but was hoping there could be something simpler like link in first definition encountered and throw a warning which can be elevated as error if the user decides to not allow redefinitions (like in actual source) but okay to have it in tests.

    Is there no other way?

  • Consider using the linker option --symbol_map.  Please search for it in the ARM assembly tools manual.  In your case, use something like --symbol_map=primary=secondary.  

    Thanks and regards,

    -George