Download MSP430 Optimizing C/C++ Compiler User`s Guide
Transcript
Linker Code Optimizations www.ti.com 4.2 Linker Code Optimizations 4.2.1 Conditional Linking With ELF conditional linking, all sections are considered eligible for removal through conditional linking, except the .reset section. Sections are not removed if they are referenced or if they are marked with the .retain directive. A section that is never referenced by any other section in the program is removed from the program automatically, unless it is marked with .retain or is the .reset section. Conditional linking is disabled when performing a partial link or when relocation information is kept with the output of the link. 4.2.2 Generating Function Subsections (--gen_func_subsections Compiler Option) The compiler translates a source module into an object file. It may place all of the functions into a single code section, or it may create multiple code sections. The benefit of multiple code sections is that the linker may omit unused functions from the executable. When the linker collects code to be placed into an executable file, it cannot split code sections. If the compiler did not use multiple code sections, and any function in a particular module needs to be linked into the executable, then all functions in that module are linked in, even if they are not used. An example is a library .obj file that contains a signed divide routine and an unsigned divide routine. If the application requires only signed division, then only the signed divide routine is required for linking. If only one code section was used, both the signed and unsigned routines are linked in since they exist in the same .obj file. The --gen_func_subsections compiler option remedies this problem by placing each function in a file in its own subsection. Thus, only the functions that are referenced in the application are linked into the final executable. This can result in an overall code size reduction. The default setting for the --gen_func_subsections option is on. 4.3 Controlling the Linking Process Regardless of the method you choose for invoking the linker, special requirements apply when linking C/C++ programs. You must: • Include the compiler's run-time-support library • Specify the type of boot-time initialization • Determine how you want to allocate your program into memory This section discusses how these factors are controlled and provides an example of the standard default linker command file. For more information about how to operate the linker, see the linker description in the MSP430 Assembly Language Tools User's Guide SLAU132K – September 2015 Submit Documentation Feedback Linking C/C++ Code Copyright © 2015, Texas Instruments Incorporated 69