HPlogo HP Assembler Reference Manual: HP 9000 Computers > Chapter 3 HP-UX Architecture Conventions

Subspaces

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

While a space is a fundamental concept of the architecture, a subspace is just a logical subdivision of a space. The Assembler places the program's code and data into subspaces within spaces. Each subspace belongs to the space that was current when the subspace was first declared. The linker groups subspaces into spaces as it builds an executable program file. For more details see the ld(1) entry in the HP-UX Reference. When the linker combines several relocatable files, it groups the subspaces from each file by name, so that all subspaces with the same name are placed contiguously in the program.

Attributes

Subspaces have several attributes. The alignment attribute specifies what memory alignment (in bytes) is required in the virtual address space. The alignment can be any power of two, from 1 through 4096, inclusive. Typically, the alignment is 4 or 8 to specify that the beginning of the subspace must be word or double-word aligned. Normally, the alignment attribute is computed automatically by the Assembler from the largest .ALIGN directive used within the subspace.

The quadrant attribute assigns the subspace to one of the four quadrants of its space. On HP-UX systems, all subspaces in the code space must be in quadrant 0, and all subspaces in the data space must be in quadrant 1.

The access rights attribute specifies the access rights that should be given to each physical page in the subspace. On HP-UX systems, all subspaces in the code space must have access rights of 0x2C (code page executable at any privilege level). All subspaces in the data space must have access rights of 0x1F (data page readable and writable at all privilege levels).

The sort key attribute allows the programmer to control the placement of a subspace relative to the other subspaces in its space. The linker places subspaces with lower sort keys in front of subspaces with higher sort keys.

Directives

The .SUBSPA directive is used to declare a subspace and its attributes. As with spaces, the assembly language programmer can switch from one subspace to another, and the Assembler will fill each subspace independently as if the source code had been presented one complete subspace at a time. When the .SPACE directive is used to switch spaces, the Assembler remembers the current subspace in each space.

Several additional Assembler directives are provided as shorthand to declare and switch to some standard spaces and subspaces. For example, the .CODE directive switches to the $TEXT$ space and the $CODE$ subspace, and the .DATA directive switches to the $PRIVATE$ space and the $DATA$ subspace.

You can declare as many subspaces as you can use, but the sort key attribute should be used carefully, because the stack unwind mechanism reserves a range of sort keys 56 through 255 for the $TEXT$ space. Refer to “Compiler Conventions” in this chapter. Some of the standard subspaces and sort keys used by the compilers are shown in Table 3-2 “Standard Subspaces and Sort Keys”. Directives that generate commonly used spaces and subspaces are found in Table 4-3 “Predefined Subspace Directives ”.

Table 3-2 Standard Subspaces and Sort Keys

Space

Subspace

Sort Key

Use

$TEXT$

8

$CODE$

24

Normal code.

$LIT$

16

Literals.

$MILLICODE$

8

Millicode library routines.

$SHLIB_INFO$

0

Shared library information.

$UNWIND$

64

Unwind information.

$PRIVATE$

16

$BSS$

82

Uninitialized data and common.

$DATA$

16

Global arrays and structures.

$DLT$

39

Data linkage table.

$GLOBAL$

40

Global variable base address.

$PLT

6

Procedure linkage table.

$SHLIB_DATA$

12

Shared library data.

$SHORTBSS$

80

Uninitialized data and common.

$SHORTDATA$

24

Global scalar variables.

$THREAD_SPECIFIC$

16

 
 

$TBSS$

40

Thread local storage

 

© 1998 Hewlett-Packard Development Company, L.P.