Handling table of contents (TOC) overflow
To handle table of contents (TOC) overflow, you can reduce the number of global symbols, enlarge the TOC access range, or apply interprocedural analysis.
The addresses of global symbols in programs are stored in a data structure called TOC. To access a global symbol, the address of the global symbol must be retrieved from the TOC. The default TOC data structure has a fixed size that can store a fixed number of global symbols. For example, the IBM® PowerPC® architecture uses an instruction with a signed 16-bit offset for indirect address calculations and limits the size of the TOC to 64 KB. A maximum of 16 K entries can be stored in the TOC in 32-bit mode and 8 K entries in 64-bit mode.
For large applications, it is common to have more global symbols than can be stored in the default TOC. If an application contains more TOC entries than the TOC can hold, the linker reports TOC overflow, indicating that an alternative mechanism must be used. Use the following approaches to handle TOC overflow:
- Reduce the number of global symbols in programs in the following
ways:
- Change the source code. It is the best approach to reduce the number of global symbols.
- Specify the -qminimaltoc option.
- Apply interprocedural analysis by specifying the -qipa option. For more information about the option, see Interprocedural analysis (IPA) and IPA Levels and other IPA suboptions.
- Enlarge the TOC access range by specifying
the following options:
- -bbigtoc (a linker option)
- -qpic=large