Sun WorkShop Compiler C 5.0 User's Guide

-xcode=v

(SPARC) Specify code address space. v must be one of:

abs32 

Generate 32-bit absolute addresses. Code + data + bss size is limited to 2**32 bytes. This is the default on 32-bit architectures: -xarch-generic, v7, v8, v8a, v8plus, v8plusa

abs44 

Generate 44-bit absolute addresses. Code + data + bss size is limited to 2**44 bytes. Available only on 64-bit architectures: -xarch=v9, v9a

abs64 

Generate 64-bit absolute addresses. Available only on 64-bit architectures: -xarch=v9, v9a

pic13 

Generate position-independent code for use in shared libraries (small model). Equivalent to -Kpic. Permits references to at most 2**11 unique external symbols on 32-bit architectures, 2**10 on 64-bit architectures. 

The -xcode=pic13 command is similar to -xcode=pic32, except that the size of the global offset table is limited to 8Kbytes.

pic32 

Generate position-independent code for use in shared libraries (large model). Equivalent to -KPIC. Permits references to at most 2**30 unique external symbols on 32-bit architectures, 2**29 on 64-bit architectures. 

Each reference to a global datum is generated as a dereference of a pointer in the global offset table. Each function call is generated in pc-relative addressing mode through a procedure linkage table. With this option, the global offset table spans the range of 32-bit addresses in those rare cases where there are too many global data objects for -xcode=pic32.

The default is -xcode=abs32 for SPARC V7 and V8, and -xcode=abs64 for SPARC and UltraSPARC V9 (with -xarch=v9|v9a).

When building shared dynamic libraries with -xarch=v9 or v9a on 64-bit Solaris 7, you must specify -xcode=pic13 or -xcode=pic32.

There are two nominal performance costs with -xcode=pic13 and -xcode=pic32:

When considering the above costs, remember that the use of -xcode=pic13 and -xcode=pic32 can significantly reduce system memory requirements, due to the effect of library code sharing. Every page of code in a shared library compiled -xcode=pic13 or -xcode=pic32 can be shared by every process that uses the library. If a page of code in a shared library contains even a single non-pic (that is, absolute) memory reference, the page becomes nonsharable, and a copy of the page must be created each time a program using the library is executed.

The easiest way to tell whether or not a .o file has been compiled with -xcode=pic13 or -xcode=pic32 is with the nm command:


% nm file.o | grep _GLOBAL_OFFSET_TABLE_
U _GLOBAL_OFFSET_TABLE_

A .o file containing position-independent code contains an unresolved external reference to _GLOBAL_OFFSET_TABLE_, as indicated by the letter U.

To determine whether to use -xcode=pic13 or -xcode=pic32, use nm to identify the number of distinct global and static variables used or defined in the library. If the size of _GLOBAL_OFFSET_TABLE_ is under 8,192 bytes, you can use -Kpic. Otherwise, you must use -xcode=pic32.