-qfuncsect

Category

Object code control

Pragma equivalent

#pragma options [no]funcsect

Purpose

Places instructions for each function in a separate object file control section or CSECT which may reduce the size of your program. Placing each function in its own CSECT enables the linker to perform garbage collection on a per function basis 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.

Syntax

Read syntax diagramSkip visual syntax diagram
        .-nofuncsect-------------------------------.   
>>- -q--+-funcsect--+----------------------------+-+-----------><
                    |    .-implicitstaticref---. |     
                    '-=--+-noimplicitstaticref-+-'     

Defaults

-qnofuncsect

Parameters

implicitstaticref | noimplicitstaticref
Specifies whether references to the static data section of the object file by functions contained in static variables, virtual function tables, or exception handling tables, are maintained.
In releases before XL 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 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 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 implicitstaticref is in effect, a reference to the static area is generated even if not otherwise referenced.

When noimplicitstaticref is in effect, a reference to the static area is only generated if referenced by the program.

Specifying -qfuncsect with no suboption implies implicitstaticref.

Usage

Using multiple control sections increases the size of the object file, but 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.

Related information