Reputation: 3203
I'm testing a C software written for Renesas RL78 microcontroller. The software is still in development, so there are functions which are implemented but not yet called. As a result, such functions are eliminated by the linker, which outputs the following entries in the listing:
CODE
Segment part 42. NOT NEEDED.
LOCAL ADDRESS
===== =======
function_name
My goal is to perform unit tests of these functions on the target system, so I need the code to be present in the output ELF file. How can I tell the linker to keep the unused functions? I already tried to set optimization level to None, and set module type to both Program or Library. I have also defined a single code segment called CODE
. All these actions had no desired effect on the linker output.
I can't modify the source code (technically, I can modify all I want, but I can't commit anything), so calling all the functions I need from main()
is not an option.
Upvotes: 1
Views: 3005
Reputation: 3203
I have found the relevant tech note which suggests the following:
- IAR XLINK Linker -g option
- IAR ILINK Linker --keep option
- use the REQUIRE keyword in assembler
- use the __root extension keyword
Since I use xlink
, I tried out the first option and it worked. Here's the option quick reference:
-gsymbol1[,symbol2,symbol3,…] Requires global entries
Here's how the option is set in the IDE:
And since M.M asked how do I unit test functions which are not called by the rest of the code, here's a screenshot of my debugger. Basically, it stopped the target once the main loop was reached, created an artificial stack frame for a function and called it.
Upvotes: 3