Sun Studio 12 Update 1: C++ User's Guide

A.2.119 –xcode=a

SPARC: Specifies the code address space.


Note –

You should build shared objects by specifying -xcode=pic13 or -xcode=pic32. Shared objects built without pic13 or pic32 will not work correctly, and might not build at all.


A.2.119.1 Values

a must be one of the following values.

Table A–29 The -xcode Values

Value 

Meaning  

abs32

Generates 32-bit absolute addresses, which are fast, but have limited range. Code + data + bss size is limited to 2**32 bytes. 

abs44

SPARC: Generates 44-bit absolute addresses, which have moderate speed and moderate range. Code + data + bss size is limited to 2**44 bytes. Available only on 64-bit architectures. Do not use this value with dynamic (shared) libraries. 

abs64

SPARC: Generates 64-bit absolute addresses, which are slow, but have full range. Available only on 64-bit architectures. 

pic13

Generates position-independent code (small model), which is fast, but has limited range. Equivalent to– Kpic. Permits references to at most 2**11 unique external symbols on 32-bit architectures; 2**10 on 64-bit.

pic32

Generates position-independent code (large model), which might not be as fast as pic13 , but has full range. Equivalent to– KPIC. Permits references to at most 2**30 unique external symbols on 32-bit architectures; 2**29 on 64-bit.

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:

Defaults

The default is -xcode=abs32 for 32–bit architectures. The default for 64–bit architectures is-xcode=abs44.

When building shared dynamic libraries, the default -xcode values of abs44 and abs32 will not work with 64–bit architectures. Specify -xcode=pic13 or -xcode=pic32 instead. There are two nominal performance costs with -xcode=pic13 and -xcode=pic32 on SPARC:

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.