Go to main content

Oracle® Solaris 64-bit Developer's Guide

Exit Print View

Updated: March 2019
 
 

6.1 SPARC V9 ABI Features

64-bit applications are described by using Executable and Linking Format (ELF64), which allows large applications and large address spaces to be described completely.

SPARCV9. The SPARC Compliance Definition, Version 2.4.1, contains details of the SPARC V9 ABI. It describes the 32-bit SPARC V8 ABI and the 64-bit SPARC V9 ABI.

Following is a list of the SPARC V9 ABI features.

  • The SPARC V9 ABI allows all 64-bit SPARC instructions and 64-bit wide registers to be used to their full effect. Many of the new relevant instructions are extensions of the existing V8 instruction set. For more information, see Oracle SPARC Servers.

  • The basic calling convention is the same. The first six arguments of the caller are placed in the out registers %o0-%o5. The SPARC V9 ABI still uses a register window on a larger register file to make calling a function a "cheap" operation. Integer and pointer results are returned in %o0 and floating-point results are returned differently on both 32-bit and 64-bit ABIs. Because all registers are now treated as 64-bit, 64-bit values can now be passed in a single register, rather than a register pair.

  • The layout of the stack is different and the basic cell size is increased from 32-bit to 64-bit. The stack is always aligned on a 16-byte boundary for a 64-bit code and memory allocators like malloc() are expected to return 16-byte aligned data. The return address is still %o7 + 8.

  • %o6 is still referred to as the stack pointer register %sp, and %i6 is the frame pointer register %fp. However, the %sp and %fp registers are offset by a constant, known as the stack bias, from the actual memory location of the stack. The size of the stack bias is 2047 bytes.

  • Instruction sizes are still 32-bit. Address constant generation therefore takes more instructions. The call instruction can no longer be used to branch anywhere in the address space, since it can only reach within plus or minus 2 gigabytes of %pc.

  • Integer multiply and divide functions are now implemented completely in hardware.

  • Structure passing and return are accomplished differently. Small data structures and some floating point arguments are now passed directly in registers.

  • User traps allow certain traps from non-privileged code to be handled by a user trap handler (instead of delivering a signal).

  • Most of the data types are now aligned to their size.

  • Many basic derived types are larger. Thus many system call interface data structures are now of different sizes.

  • Two different sets of libraries exist on the system: those for 32-bit SPARC applications and those for 64-bit SPARC applications.

6.1.1 Stack Bias

An important feature of the SPARC V9 ABI for developers is the stack bias. For 64-bit SPARC programs, a stack bias of 2047 bytes must be added to both the frame pointer and the stack pointer to get to the actual data of the stack frame. See the following figure.

image:Image shows the addition of 2047 bytes of stack bias for a 64-bit SPARC             program

For more information about stack bias, please see the SPARC V9 ABI.

6.1.2 Address Space Layout of the SPARC V9 ABI

For 64-bit applications, the layout of the address space is closely related to that of 32-bit applications, though the starting address and addressing limits are radically different. Like SPARC V8, the SPARC V9 stack grows down from the top of the address space, while the heap extends the data segment from the bottom.

The diagram below shows the default address space provided to a 64-bit application. The regions of the address space marked as reserved might not be mapped by applications. These restrictions might be relaxed on future systems.

image:Diagram showing address space allocation for a typical SPARCV9 64-bit 						application

The actual addresses in the figure above describe a particular implementation on a particular system, and are given for illustrative purposes only.

6.1.3 Placement of Text and Data of the SPARC V9 ABI

By default, 64-bit programs are linked with a starting address of 0x100000000. The whole program is above 4 gigabytes, including its text, data, heap, stack, and shared libraries. This helps ensure that 64-bit programs are correct by making it so the program will fault in the lower 4 gigabytes of its address space, if it truncates any of its pointers.

While 64-bit programs are linked above 4 gigabytes, you can still link them below 4 gigabytes by using a linker mapfile and the -M option to the compiler or linker. A linker mapfile for linking a 64-bit SPARC program below 4 gigabytes is provided in /usr/lib/ld/sparcv9/map.below4G.

See the ld(1) linker man page for more information.

6.1.4 Code Models of the SPARC V9 ABI

    Different code models are available from the compiler for different purposes to improve performance and reduce code size in 64-bit SPARC programs. The code model is determined by the following factors:

  • Positioning (absolute versus position-independent code)

  • Code size ( < 2 gigabytes)

  • Location (low, middle, anywhere in address space)

  • External object reference model (small or large)

The following table describes the different code models available for 64-bit SPARC programs.

Table 3  Code Model Descriptions: SPARCV9
Code Model
Positionability
Code Size
Location
External Object Reference Model
abs32
Absolute
< 2 gigabytes
Low (low 32 bits of address space)
None
abs44
Absolute
< 2 gigabytes
Middle (low 44 bits of address space)
None
abs64
Absolute
< 2 gigabytes
Anywhere
None
pic13
PIC
< 2 gigabytes
Anywhere
Small (<= 1024 external objects)
pic32
PIC
< 2 gigabytes
Anywhere
Large (<= 2**29 external objects)

Shorter instruction sequences can be achieved in some instances with the smaller code models. The number of instructions needed to do static data references in absolute code is the fewest for the abs32 code model and the most for the abs64 code model, while abs44 is in the middle. Likewise, the pic code model uses fewer instructions for static data references than the PIC code model. Consequently, the smaller code models can reduce the code size and perhaps improve the performance of programs that do not need the fuller functionality of the larger code models.

To specify which code model to use, the –xcode=<model> compiler option should be used. Currently, for 64-bit objects, the compiler uses the abs44 model by default. You can optimize your code by using the abs44 code model; you will use fewer instructions and still cover the 44-bit address space that the current UltraSPARC platforms support.

For more information about code models, see the SPARC V9 ABI and compiler documentation.