One of the optimizations performed during an IPO compilation is code layout. IPO analysis determines a layout order for all of the routines for which it has IR. If a single object is being generated, the compiler generates the layout simply by compiling the routines in the desired order.
For a multi-object IPO compilation, the compiler must tell the linker about the desired order. The compiler first puts each routine in a named text section (the first routine in .text00001, the second in .text00002, and so forth). It then generates a linker script that tells the linker to first link contributions from .text00001, then .text00002. This happens transparently when the same invocation is used for both the link-time compilation and the final link.
However, the linker script must be taken into account by the user if -ipo_c or -ipo_S is used. With these switches, the IPO compilation and actual link are done by different invocations. When this occurs, the compiler will issue an informational message indicating that it is generating an explicit linker script, ipo_layout.script.
When ipo_layout.script is generated, the typical response is to modify your link command to use this script:
If your application already requires a custom linker script, you can place the necessary contents of ipo_layout.script in your script. The layout-specific content of ipo_layout.script is at the beginning of the description of the .text section. For example, to describe the layout order for 12 routines:
*(.text00001) *(.text00002) *(.text00003) *(.text00004) *(.text00005)
*(.text00006) *(.text00007) *(.text00008) *(.text00009) *(.text00010)
For applications that already require a linker script, you can add this section of the .text section description to the customized linker script. If you add these lines to your linker script, it is desirable to add additional entries to account for future development. This is harmless, since the “*(…)” syntax makes these contributions optional.
If you choose to not use the linker script your application will still build, but the layout order will be random. This may have an adverse affect on application performance, particularly for large applications.