Sun Studio 12: Fortran User's Guide

3.4.122 –xcode=keyword

(SPARC) Specify code address space on SPARC platforms.

The values for keyword are:

keyword

Feature  

abs32

Generate 32-bit absolute addresses. Code+data+bss size is limited to 2**32 bytes. This is the default on 32-bit platforms. 

abs44

Generate 44-bit absolute addresses. Code+data+bss size is limited to 2**44 bytes. Available only on 64-bit platforms. 

abs64

Generate 64-bit absolute addresses. Available only on 64-bit platforms. 

pic13

Generate position-independent code (small model). Equivalent to -pic. Permits references to at most 2**11 unique external symbols on 32-bit platforms, 2**10 on 64-bit platforms.

pic32

Generate position-independent code (large model). Equivalent to -PIC. Permits references to at most 2**30 unique external symbols on 32-bit platforms, 2**29 on 64-bit platforms.

The defaults for not specifying -xcode=keyword explicitly are:

–xcode=abs32 on 32–bit platforms.–xcode=abs44 on 64–bit platforms.

3.4.122.1 Position-Independent Code:

Use -xcode=pic13 or -xcode=pic32 when creating dynamic shared libraries to improve runtime performance.

While the code within a dynamic executable is usually tied to a fixed address in memory, position-independent code can be loaded anywhere in the address space of the process.

When you use position-independent code, relocatable references are generated as an indirect reference through a global offset table. Frequently accessed items in a shared object will benefit from compiling with -xcode=pic13 or -xcode=pic32 by not requiring the large number of relocations imposed by code that is not position-independent.

The size of the global offset table is limited to 8Kb.

There are two nominal performance costs with -xcode={pic13|pic32} :

When considering the above costs, remember that the use of -xcode=pic13 or -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_

A .o file containing position-independent code will contain an unresolved external reference to _GLOBAL_OFFSET_TABLE_ as marked by the letter U.

To determine whether to use -xcode=pic13 or -xcode=pic32, check the size of the Global Offset Table (GOT) by using elfdump -c (see the elfdump(1) man page for more information) and for the section header, sh_name: .got. The sh_size value is the size of the GOT. If the GOT is less than 8,192 bytes, specify -xcode=pic13, otherwise specify -xcode=pic32.

In general, use the following guidelines to determine how you should use -xcode:

Compiling with the -xcode=pic13 or pic32 (or -pic or -PIC) options is recommended when building dynamic libraries. See the Solaris Linker and Libraries Guide.