-qstackprotect

Category

Object code control

Pragma equivalent

None.

Purpose

Provides protection against malicious code or programming errors that overwrite or corrupt the stack.

Syntax

Read syntax diagramSkip visual syntax diagram
        .-nostackprotect-.                          
>>- -q--+-stackprotect---+----=----+-all--------+--------------><
                                   '-size--=--N-'   

Defaults

Parameters

all
all protects all procedures whether or not there are vulnerable objects. This option is not set by default.
size=N
size=N protects all procedures containing automatic objects greater or equal to N bytes in size. The default size is 8 when -qstackprotect is enabled.
Note: When both all and size are used, the last option wins.

Usage

-qstackprotect generates extra code to protect procedures with vulnerable objects against stack corruption. This option is disabled by default because it can cause performance degradation. The default option is -qnostackprotect.

To generate code to protect all procedures with vulnerable objects:

xlc myprogram.c -qstackprotect=all

To generate code to protect procedures with objects of certain bytes:

xlc myprogram.c -qstackprotect=size=8
Note:
  • This option cannot be used with #pragma options.
  • Because of the dependency on glibc in Linux®, this option requires the following Linux levels:
    • Linux OS with GLIBC 2.4 and up (Machines with GCC 4.X and up).
  • All supported Linux systems already support this feature.

Predefined macros

None.

Related information