Safety-certified tools Tools for Automotive Applications C-STAT Static analysis C-RUN Runtime analysis Debugging and trace probes
This Technical Note discusses how symbols from a library can be hidden, using isymexport and a steering file.
The application is defining global variables and/or functions having the same name as non-weak global variables and/or functions in a library you have made.
A solution is to use isymexport with a steering file and select which symbols in the library that will be visible for the application and which symbols to hide.
Usually the library file is pointed out by the option "Linker > Library > Additional libraries", but instead it can point to a file produced by isymexport.
However, the input to isymexport must be an executable ELF file (output from linking) so a library file cannot be used as the input file.
A way to get around this restriction is to make an additional project with the only purpose of linking the library and producing an output file (linked image) to be used as input to isymexport.
The following example (Example project.zip) contains three projects:
Builds a library file (library.a) containing a global int array and a five functions returning int values from the array.
Includes the library file (library.a) and produces a linked image. Invokes isymexport with a steering file to select which symbols to export and which symbols to hide. The name of the array and one of the functions are hidden.
The post-build command line calls post-build.bat, which invokes isymexport to produce common.symbols followed by ielfdumparm to dump the symbol table of common.symbols, i.e., the exported symbols.
A dummy function is defined, which is only used as entry symbol. This is to avoid including startup code in the linked image, which should only include the library.
To make sure everything in the library is inluded by the linker, the option
--whole_archive is used, together with the option --no_remove to make unreferenced sections kept by the linker and not removed from the linked image.
Defines an int array and a function having the same names as the array and one of the five functions in the library.
The application project calls all five functions in turn and the return value is printed to stdout.
The symbols exported by the library are imported via project common, by including the file common.symbols produced by isymexport.
With the C-SPY debugger, the application project as well as the common project can be executed in the simulator. The Terminal I/O window shows the int values returned by the called functions, where one value is from the array in the application and four values from the array in the library.
All product names are trademarks or registered trademarks of their respective owners.