The 32-Bit PA-RISC Run-Time Architecture Document, V. 1.0 for HP
Total Page:16
File Type:pdf, Size:1020Kb
The 32-bit PA-RISC Run-time Architecture Document HP-UX 11.0 Version 1.0 (c) Copyright 1997 HEWLETT-PACKARD COMPANY. The information contained in this document is subject to change without notice. HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Hewlett-Packard shall not be liable for errors contained herein or for incidental or consequential damages in connection with furnishing, performance, or use of this material. Hewlett-Packard assumes no responsibility for the use or reliability of its software on equipment that is not furnished by Hewlett-Packard. This document contains proprietary information which is protected by copyright. All rights are reserved. No part of this document may be photocopied, reproduced, or translated to another language without the prior written consent of Hewlett-Packard Company. CSO/STG/STD/CLO Hewlett-Packard Company 11000 Wolfe Road Cupertino, California 95014 By The Run-time Architecture Team 32-bit PA-RISC RUN-TIME ARCHITECTURE DOCUMENT 11.0 version 1.0 -1 -2 CHAPTER 1 Introduction 7 1.1 Target Audiences 7 1.2 Overview of the PA-RISC Runtime Architecture Document 8 CHAPTER 2 Common Coding Conventions 9 2.1 Memory Model 9 2.1.1 Text Segment 9 2.1.2 Initialized and Uninitialized Data Segments 9 2.1.3 Shared Memory 10 2.1.4 Subspaces 10 2.2 Register Usage 10 2.2.1 Data Pointer (GR 27) 10 2.2.2 Linkage Table Register (GR 19) 10 2.2.3 Stack Pointer (GR 30) 11 2.2.4 Space Registers 11 2.2.5 User-Readable Control Registers (CR 26 and CR 27) 11 2.2.6 General Registers Summary 12 2.3 External Naming Conventions 12 2.4 Conventions for Accessing Data 13 2.4.1 Static Variables 13 2.4.2 C-Style Common 14 2.4.3 Fortran-Style Common 14 2.4.4 COBOL-Style Common 14 2.4.5 Pascal Outer Block Globals 14 2.4.6 Constants and Literals 14 2.4.7 Automatic Variables 14 2.4.8 Position-Independence 15 2.5 Conventions for Calling Procedures 15 2.5.1 Stack Frame Layout and Marker 15 2.5.2 Stack frame after dynamic memory allocation 19 2.5.3 Parameter Passing and Return Values 21 2.5.4 Type Checking and Floating-Point Parameter Relocation 29 2.5.5 Standard Procedure Calls 32 2.5.6 Indirect Procedure Calls 36 2.5.7 Millicode Procedure Calls 38 2.6 Program Startup 39 CHAPTER 3 Relocatable Object Files 41 3.1 Object File Header 43 3.2 Compilation Unit Records 50 3.3 Space Dictionary 52 3.4 Subspace Dictionary 55 3.5 String Areas 62 3.6 Fixup Requests 62 3.6.1 Fixup Rounding Modes 64 3.6.2 Interpretation of rounding mode and field selector 65 3.6.3 Examples of applying the rounding mode 67 32-bit PA-RISC RUN-TIME ARCHITECTURE DOCUMENT version 1.0 -3 3.6.4 Apply Fixups on instructions 68 3.6.5 List of fixup requests 69 3.6.6 Fixup opcodes, lengths and parameters 75 3.6.7 Parameter Relocation Bits (rbits1, rbits2) 78 3.7 Symbol Table 80 CHAPTER 4 Relocatable Libraries 97 4.1 Archive Header 98 4.2 Library Symbol Table Header Record 100 4.3 Library Symbol Table Format 104 4.3.1 Symbol Directory 104 4.3.2 SOM Directory 113 4.3.3 Free Space List 114 CHAPTER 5 Executable Files 117 5.1 Object File Header 117 5.2 Auxiliary Headers 117 5.2.1 Loader Auxiliary Headers 120 5.2.2 Other Auxiliary Headers 121 5.3 Symbol Table 123 5.4 Stack Unwind Table 124 5.5 Recover Table 124 5.6 Auxiliary Unwind Table 124 CHAPTER 6 HP-UX Specifics 125 6.1 HP-UX Auxiliary Header 125 6.2 Program Startup 127 6.2.1 Sample Assembly Listing of crt0 code 128 6.3 Shared Libraries 141 6.3.1 Shared Library Memory Model 141 6.3.2 Linkage Table 141 6.3.3 The DL Header and Other Tables 143 6.3.4 Version Auxiliary Header 148 6.3.5 Import List 148 6.3.6 Export Table 149 6.3.7 Export Table Extension 152 6.3.8 Shared Library List 153 6.3.9 Module Table 155 6.3.10 Shared Library Unwind Info 156 6.3.11 String Table 158 6.3.12 Dynamic Relocation Records 158 6.3.13 Loading Shared Libraries 161 6.3.14 Intra-library Version Control 163 6.3.15 Library-Level Versioning 164 6.3.16 Import and Export Stubs 167 6.4 System Calls 168 -4 HP Proprietary CHAPTER 7 Symbolic Debug Information 171 7.1 The Debug Information Organization 171 7.2 Compilation Unit Headers 172 7.2.1 Basic typedef and structure definitions 172 7.2.2 XDB Header structure definition: 174 7.3 Name and Type Tables 175 7.3.1 File-class ("File") DNTT Entries 175 7.3.2 Code-class ("Scoping") DNTT Entries 176 7.3.3 Storage-class ("Name") DNTT Entries 183 7.3.4 Type-class ("Type") DNTT Entries 187 7.3.5 General ("overall") DNTT Entry Format 203 7.4 Static Analysis Information 205 7.4.1 XREF Table (XT) Entry Format 205 7.4.2 Static Analysis Support DNTT Entries 207 7.5 Source Line Table 208 7.5.1 SLT Entry Format 208 7.5.2 SLT Types and Data Structure 209 7.6 Value Table (VT) 211 7.7 Ordering of Table Entries 211 7.8 Postprocessing 212 7.9 Debug Format Changes for Debugging of Optimized Code (DOC) 216 7.9.1 Debug Format Changes 216 7.9.2 Object File Format Details 217 7.9.3 Building the Line Tables 218 7.9.4 Debug Format Changes 219 7.9.5 Line Number Table Definition 222 7.9.6 View/modify globals and arguments when safe 224 CHAPTER 8 Stack Unwind Library 227 8.1 Overview 227 8.2 Requirements for Stack Unwinding 228 8.2.1 Unwinding Across an Interrupt Marker 229 8.2.2 Unwinding from Stubs on HP-UX 229 8.2.3 Unwinding from Millicode 229 8.2.4 Instances in Which Unwinding May Fail 230 8.2.5 Callee-Saves Register Spill 230 8.2.6 Sample entry and exit code 230 8.3 Role of Stubs in Unwinding 232 8.3.1 The Stub Unwind Types 233 8.3.2 Unwinding from Parameter Relocation Stub 234 8.4 External Interface 236 8.4.1 The Unwind Descriptor 236 8.4.2 Unwind Utility Routines 240 8.4.3 Initialize a Stack Unwind 247 8.4.4 Unwind Examples: Using U_get_previous_frame 248 8.5 Setjmp and longjmp jmp_buf 256 8.6 Process Context 258 32-bit PA-RISC RUN-TIME ARCHITECTURE DOCUMENT version 1.0 -5 8.6.1 Ada Exception handling 258 8.6.2 C++ Exception handling 273 -6 HP Proprietary CHAPTER 1 Introduction This document describes the runtime architecture for PA-RISC systems running either the HP-UX or the MPE/iX operating system. Other operating systems running on PA-RISC may also use this runtime architecture or a variant of it. The runtime architecture defines all the conventions and formats necessary to compile, link, and execute a program on one of these operating systems. Its purpose is to ensure that object modules produced by many different compilers can be linked together into a single application, and to specify the interfaces between compilers and linker, and between linker and operating system. The runtime architecture applies only to hardware platforms based on PA-RISC Revi- sion 2.0. The runtime architecture does not specify the application programming interface (API), the set of services provided by the operating system to the program. Thus, observing the runtime architecture does not automatically lead to a program that will run on all PA-RISC platforms. It does, however, allow many of the development tools to be shared to a large extent among the various operating systems. When combined with a particular API, this runtime architecture leads to an application binary interface (ABI). In other words, an ABI can be regarded as the composition of an API, a hardware description, and a runtime architecture for that hardware. 1.1 Target Audiences This document is intended for a variety of readers. If you are a systems programmer, you will find information in this document describing the format of an executable object file, the memory model and startup environment 32-bit PA-RISC RUN-TIME ARCHITECTURE DOCUMENT 11.0 version 1.0 1-7 Introduction assumed by a valid program, and the architected interface between a program and the services provided by your operating system. If you develop compilers or other development tools, you will find information in this document about calling conventions and other coding conventions, the object file for- mat, interfaces to the linker, symbolic debug format, and other details important to pro- gram translation. If you are an application programmer, this document can help you learn about the low- level details of how programs execute on PA-RISC. If you need to write assembly code, process object files, examine the stack, or perform dynamic linking, you will find the necessary information in this document. 1.2 Overview of the PA-RISC Runtime Architecture Document Chapter 2 describes the coding conventions used by compilers and by assembly- language programmers. This includes details of the virtual memory model, usage of processor registers, external name conventions, addressing data, procedure calling and parameter passing, and the program startup environment.