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.
Hi.
Is it possible to tell the command linker file (.cmd) to link in a library that is not used in the code?
The reason I want this is that I have a bootloader that I want to place in the FLASHA sector and to make good use of the remaining flash in this sector I would like to place the libraries I use in my application in that sector as well. This could be fx the FlashAPI and IQmath libraries.
When I build the bootloader project I get the warning: "#10068-D no matching section" which makes sense now that I don't use any functions from that library in this project, and I can see from the allocated memory that the linker indeed does not place the library in code. I understand that in a normal situation it would be a feature that the linker only include things that are actually used, but in this particular case, I would like to disable this behaviour.
Is there any ways to fix this :)?
Best Regards,
abaldur
Hi Abaldur,
Could you try disabling (off) below option if enabled?
If this does not help, I will loop in our compiler team to help you.
Thanks and regards,
Vamsi
Hi Vamsi
Just tried your suggestion, but it does not seem to work. I still see the "#10068-D no matching section" warning and the libs still remain not linked. Right now I'm just testing with the "Flash2812_API_V210.lib", and I can confirm that only if I call functions from this library in my code, it will be included by the linker.
Since I posted the question, I found that the linker has a command line argument --retain (Properties -> C2000 Linker -> Advanced Options -> Symbol Management) that sounds a bit like what I want. If you hover this option it says: "This option can be used to tell the linker to retain a list of sections that would otherwise be not retained". However, as it also says, it only works with the eabi (ELF) output type, but my project requires the TI-COFF type since I rely on libraries that are compiled this way.
I would really appreciate if you could forward the question to the compiler team : )
Best Regards,
abaldur
Hi Abaldur,
I will assign this post to our compiler team to help you further.
Thanks and regards,
Vamsi
To force the linker to include a function or data variable from a library, use the linker option --undef_sym. For example: --undef_sym=_name_of_function_in_the_library. You can specify it multiple times. To learn more this option, please search for it in the C28x assembly tools manual.
Thanks and regards,
-George
Hi George
I have just tried with fx the Flash_Erase function. After adding "--undef_sym=_Flash_Erase" it gives me the error "undefined symbol: _FlashErase". I also tried without the underscore (_) in front, but same result. Can you figure out what I do wrong?
Also, can you help me with a more complete example where I have two projects:
I guess that I would have to use the "NOLOAD" specifier in the application linker file along with a fixed address to where the FlashAPI is stored in the FLASH A section?
BR abaldur
After adding "--undef_sym=_Flash_Erase" it gives me the error "undefined symbol: _FlashErase".
Be sure the linker sees the option --undef_sym before it sees the library.
Thanks and regards,
-George
Hi George. Are you referring to the order of the arguments provided to the linker command? I have just added "_Flash_Erase" into the field found in project properties "C2000 Linker > Advanced Options > Symbol Management". Should it be done in another way?
BR abaldur
Please forget my last post. I just noticed something else.
After adding "--undef_sym=_Flash_Erase" it gives me the error "undefined symbol: _FlashErase"
The spelling of the symbol has to match everywhere it is used. In this case, there are 3 places it has to match.
There is one other detail to understand. Symbol names written in C have an underscore added to the front when generated by the compiler. For example, FlashErase in C becomes _FlashErase to the assembler and the linker. This is true for the older COFF ABI you currently use. It is not the case for the newer EABI.
With all that in mind ...
Notice that --undef_sym refers to _Flash_Erase while the diagnostic refers to _FlashErase. The difference is the underscore in the middle of the name. Make sure they are the same everywhere.
Thanks and regards,
-George