-qfuncsect
Category
Pragma equivalent
#pragma options [no]funcsect
Purpose
Places instructions for each function in a separate object file control section or CSECT. Placing each function in its own section or CSECT might reduce the size of your program because the linker can collect garbage per function rather than per object file.
When -qfuncsect is specified, the compiler generates references from each function to the static data area, if one exists, in order to ensure that if any function from that object file is included in the final executable, the static data area also is included. This is done to ensure that any static strings or strings from a pragma comment, possible containing copyright information, are also included in the executable. This can, in some cases, cause code bloat or unresolved symbols at link time.
When -qnofuncsect is in effect, each object file consists of a single control section combining all functions defined in the corresponding source file. You can use -qfuncsect to place each function in a separate control section.
In prior releases, -qfuncsect had minimal size reductions for C++ programs. You should see an improvement in the current release.
Syntax
.-nofuncsect-------------------------------. >>- -q--+-funcsect--+----------------------------+-+----------->< | .-implicitstaticref---. | '-=--+-noimplicitstaticref-+-'
Defaults
-qnofuncsect
Parameters
- implicitstaticref | noimplicitstaticref
- Specifies whether references to the static data section of the
object file by functions that are contained in
static variables, virtual function tables, or exception handling tables,
are maintained. In releases before XL C/C++ for AIX® V11.1, all exception handling tables were placed in one static data section. Including one exception handling table meant all the other tables were also included. Therefore, references to functions in the unused exception handling tables prevented linker garbage collection of those functions, which would otherwise have been cleaned up. Starting from XL C/C++ for AIX, V11.1, this problem is solved by allocating each exception handling table its own TOC entry. As a result, the size of the final executable might be reduced.Note: The XL C/C++ for AIX, V11.1 enhancement enables large TOC access, which sets no limit on the number of TOC entries.
When your code contains a #pragma comment directive or a static string for copyright information purposes, the compiler automatically places these strings in the static data area and generates references to these static data areas in the object code.
When -qfuncsect=implicitstaticref is in effect, a reference to the static area is generated even if not otherwise referenced.
When -qfuncsect=noimplicitstaticref is in effect, a reference to the static area is only generated if referenced by the program.
Specifying -qfuncsect with no suboption implies -qfuncsect=implicitstaticref.
Usage
Using multiple control sections increases the size of the object file, but it can reduce the size of the final executable by allowing the linker to remove functions that are not called or that have been inlined by the optimizer at all places they are called.
The pragma directive must be specified before the first statement in the compilation unit.
Predefined macros
None.



