System V Application Binary Interface K1OM Architecture Processor Supplement Version 1.0
Total Page:16
File Type:pdf, Size:1020Kb
System V Application Binary Interface K1OM Architecture Processor Supplement Version 1.0 Edited by H.J. Lu1, Milind Girkar2, Michael Matz3, Jan Hubickaˇ 4, Andreas Jaeger5, Mark Mitchell6 April 26, 2012 [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] K1OM ABI 1.0 – April 26, 2012 – 11:23 Contents 1 Introduction 9 2 Software Installation 10 3 Low Level System Information 11 3.1 Machine Interface . 11 3.1.1 Processor Architecture . 11 3.1.2 Data Representation . 11 3.2 Function Calling Sequence . 14 3.2.1 Registers and the Stack Frame . 15 3.2.2 The Stack Frame . 15 3.2.3 Parameter Passing . 16 3.3 Operating System Interface . 24 3.3.1 Exception Interface . 24 3.3.2 Virtual Address Space . 24 3.3.3 Page Size . 24 3.3.4 Virtual Address Assignments . 24 3.4 Process Initialization . 27 3.4.1 Initial Stack and Register State . 27 3.4.2 Thread State . 30 3.4.3 Auxiliary Vector . 30 3.5 Coding Examples . 32 3.5.1 Architectural Constraints . 33 3.5.2 Conventions . 35 3.5.3 Position-Independent Function Prologue . 36 3.5.4 Data Objects . 37 3.5.5 Function Calls . 45 3.5.6 Branching . 47 1 K1OM ABI 1.0 – April 26, 2012 – 11:23 3.5.7 Variable Argument Lists . 50 3.6 DWARF Definition . 55 3.6.1 DWARF Release Number . 56 3.6.2 DWARF Register Number Mapping . 56 3.7 Stack Unwind Algorithm . 56 4 Object Files 60 4.1 ELF Header . 60 4.1.1 Machine Information . 60 4.1.2 Number of Program Headers . 60 4.2 Sections . 61 4.2.1 Section Flags . 61 4.2.2 Section types . 62 4.2.3 Special Sections . 62 4.2.4 EH_FRAME sections . 63 4.3 Symbol Table . 68 4.4 Relocation . 68 4.4.1 Relocation Types . 68 4.4.2 Large Models . 74 5 Program Loading and Dynamic Linking 75 5.1 Program Loading . 75 5.1.1 Program header . 76 5.2 Dynamic Linking . 76 5.2.1 Program Interpreter . 83 5.2.2 Initialization and Termination Functions . 83 6 Libraries 84 6.1 C Library . 84 6.1.1 Global Data Symbols . 84 6.1.2 Floating Point Environment Functions . 84 6.2 Unwind Library Interface . 85 6.2.1 Exception Handler Framework . 85 6.2.2 Data Structures . 88 6.2.3 Throwing an Exception . 90 6.2.4 Exception Object Management . 93 6.2.5 Context Management . 93 6.2.6 Personality Routine . 96 2 K1OM ABI 1.0 – April 26, 2012 – 11:23 6.3 Unwinding Through Assembler Code . 100 7 Development Environment 103 8 Execution Environment 104 9 Conventions 105 9.1 C++ . 106 9.2 Fortran . 107 9.2.1 Names . 107 9.2.2 Representation of Fortran Types . 108 9.2.3 Argument Passing . 109 9.2.4 Functions . 110 9.2.5 COMMON blocks . 111 9.2.6 Intrinsics . 112 A Linux Conventions 123 A.1 Execution of 32-bit Programs . 123 A.2 K1OM Linux Kernel Conventions . 123 A.2.1 Calling Conventions . 123 A.2.2 Stack Layout . 124 A.2.3 Required Processor Features . 124 A.2.4 Miscellaneous Remarks . 124 3 K1OM ABI 1.0 – April 26, 2012 – 11:23 List of Tables 3.1 Hardware Exceptions and Signals . 25 3.2 Floating-Point Exceptions . 25 3.3 x87 Floating-Point Control Word . 27 3.4 MXCSR Status Bits . 28 3.5 rFLAGS Bits . 28 4.1 K1OM Identification . 60 4.2 K1OM Specific Section Header Flag, sh_flags . 61 4.3 Section Header Types . 62 4.4 Special sections . 62 4.5 Additional Special Sections for the Large Code Model . 63 4.6 Common Information Entry (CIE) . 65 4.7 CIE Augmentation Section Content . 66 4.8 Frame Descriptor Entry (FDE) . 67 4.9 FDE Augmentation Section Content . 68 4.10 Relocation Types . 71 4.11 Large Model Relocation Types . 74 5.1 Program Header Types . 76 7.1 Predefined Pre-Processor Symbols . 103 9.1 Mil intrinsics . 113 9.2 F77 intrinsics . 115 9.3 F90 intrinsics . 116 9.4 Math intrinsics . 116 9.5 Unix intrinsics . 118 A.1 Required Processor Features . 125 4 K1OM ABI 1.0 – April 26, 2012 – 11:23 List of Figures 3.1 Scalar Types . 12 3.2 Bit-Field Ranges . 14 3.3 Stack Frame with Base Pointer . 16 3.4 Register Usage . 21 3.5 Parameter Passing Example . 23 3.6 Register Allocation Example . 23 3.7 Virtual Address Configuration . 26 3.8 Conventional Segment Arrangements . 27 3.9 Initial Process Stack . 29 3.10 auxv_t Type Definition . 30 3.11 Auxiliary Vector Types . 31 3.12 Position-Independent Function Prolog Code . 36 3.13 Absolute Load and Store (Small Model) . 38 3.14 Position-Independent Load and Store (Small PIC Model) . 39 3.15 Absolute Load and Store (Medium Model) . 40 3.16 Position-Independent Load and Store (Medium PIC Model) . 41 3.17 Position-Independent Load and Store (Medium PIC Model), con- tinued . 42 3.18 Absolute Global Data Load and Store . 43 3.19 Faster Absolute Global Data Load and Store . 43 3.20 Position-Independent Global Data Load and Store . 44 3.21 Faster Position-Independent Global Data Load and Store . 44 3.22 Position-Independent Direct Function Call (Small and Medium Model) . 45 3.23 Position-Independent Indirect Function Call . 45 3.24 Absolute Direct and Indirect Function Call . 46 3.25 Position-Independent Direct and Indirect Function Call . 46 3.26 Absolute Branching Code . 48 5 K1OM ABI 1.0 – April 26, 2012 – 11:23 3.27 Implicit Calculation of Target Address . 48 3.28 Position-Independent Branching Code . 49 3.29 Absolute Switch Code . 49 3.30 Position-Independent Switch Code . 50 3.31 Parameter Passing Example with Variable-Argument List . 51 3.32 Register Allocation Example for Variable-Argument List . 51 3.33 Register Save Area . 52 3.34 va_list Type Declaration . 53 3.35 Sample Implementation of va_arg(l, int) . 55 3.36 DWARF Register Number Mapping . 57 3.37 Pointer Encoding Specification Byte . 58 4.1 Relocatable Fields . 69 5.1 Global Offset Table . 77 5.2 Procedure Linkage Table (small and medium models) . 79 5.3 Final Large Code Model PLT . 82 6.1 Examples for Unwinding in Assembler . 102 9.1 Example mapping of names . 108.