Reduce Code Size in RTS Library

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search
Translate this page to   

This page is for you if you meet these requirements:

All that said, it does show how to rebuild the RTS library. That might be interesting.

For these compilers, the RTS library is built so that all the functions from a single source file are collected together into a single section. If any function in the file is referenced (usually by a direct call, but possibly by taking its address), then the linker brings in the entire section, including the functions that are not referenced. This means wasted code size. Not so much for the C part of the RTS library, because most of those functions are alone in their source file. The C++ portion of the library, however, commonly has several functions in each source file. For that part of the library, it makes sense to use the compiler option that places each function in its own subsection. Placing each function in its own subsection means the linker brings in only the functions actually referenced. And thus the code size contribution from the RTS library can be reduced. In some cases, it may be reduced by quite a bit.

To see the compiler option for placing each function in a subsection, run a command similar to this ...

   % cl55 | find "subsection"
      -mo                  Place each function in a separate subsection

Using this option does not always mean code size gets better. It may get worse. For details, see Appendix A of this application note.

This is how to rebuild a C5500 RTS library with -mo. Adjust to your situation. The file rtssrc.zip is in the \lib directory of the compiler distribution. Unzip it into an empty directory. Examine the file rtssrc_zip_README.txt to learn about how you need to have make (or some variant) and Perl installed. Also, the compiler tools need to be in the path. Edit the file Makefile. Add the –mo option to the variable OPT_ALL.

   OPT_ALL   = -ms2 -mg –mo

Then issue a command similar to this:

   % make rts55.lib

That command rebuilds rts55.lib, leaving it the same directory. Use your variant of make and name the exact library you want to rebuild.

Save off the library that came with the compiler release and replace it with your new one. And thus you probably reduced your code size.

Leave a Comment
Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox