-qpic

Category

Object code control

Pragma equivalent

None.

Purpose

Generates position-independent code suitable for use in shared libraries.

Syntax

Read syntax diagramSkip visual syntax diagram
>>- -q--pic--+--------------+----------------------------------><
             |    .-small-. |   
             '-=--+-large-+-'   

Defaults

Parameters

small
Instructs the compiler to assume that the size of the Table of Contents (TOC) is no larger than 64 Kb. When -qpic=small is in effect, the compiler generates one instruction for each TOC access.
large
Instructs the compiler to assume that the size of the TOC is larger than 64 Kb. When -qpic=large is in effect, the compiler generates two instructions for each TOC access to enlarge the accessing range. This helps avoid TOC overflow conditions when the Table of Contents is larger than 64 Kb.
Notes:

Specifying -qpic without any suboptions is equivalent to -qpic=small.

Usage

Specifying -qpic=large has the same effect as passing -bbigtoc to ld.

You can use different TOC access options for different compilation units in an application.

Note: For applications whose TOC size is larger than 64K, using -qpic=large can improve performance. However, for applications whose TOC is smaller than 64K, using -qpic=large slows down the program. To decide whether to use -qpic=large, compile the program with -qpic=small first. If an overflow error message is generated, use -qpic=large instead.

Predefined macros

None.

Examples

To compile a shared library libmylib.so, use the following commands:
xlc mylib.c -qpic=small -c -o mylib.o 
xlc -qmkshrobj mylib -o libmylib.so.1

Related information