Safety-certified tools Tools for Automotive Applications C-STAT Static analysis C-RUN Runtime analysis Debugging and trace probes
IAR Embedded Workbench for RISC-V now releasedTools for Risc-V
If functions and variables are not refered to in the main() call-tree or in any interrupt call-tree the linker will remove them by default.
You can prevent this and force the linker to keep a certain variable or function by using the __root extension keyword.
__root char myvariable;
__root void myfunction(void)
/* function code */
Other methods to keep the functions/variables are to use
The compiler also removes unused variables on absolute addresses.
This can lead to a problem when other modules refer to them.
It can be described with the below code.
Only the variable test1 will be kept in this compile unit.
test2, test3 and test4 are not kept since they are not accessed.
If you in some other C file use test2 as external, it will not be found by the linker.
__no_init int test1 @ 0x0004;
__no_init int test2 @ 0x0008;
__no_init int test3 @ 0x000C;
__no_init int test4 @ 0x0010;
test1 = 1;
One important reason for doing like this is that the device specific .h files creates a very large number of variables which could create segment overlap errors if included in more than one module.
All product names are trademarks or registered trademarks of their respective owners.