-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.

In prior releases, -qfuncsect had minimal size reductions for C++ programs. You should see an improvement in the current release.

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.

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, any references to the static area by functions that are removed by the linker's garbage collection procedures are maintained; this may result in unresolved function definition errors by the linker.

When noimplicitstaticref is in effect, these references to the static area are removed, allowing for successful linking and potentially reduced executable size; note, however, that this may result in a failure to include the static data area and any copyright information that it may contain.

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