1 Linux Standard Base Specification for the IA32 Architecture 1.1.0 2 3 Copyright © 2001 by Free Standards Group 4 5 This material may be distributed only subject to the terms and conditions set 6 forth in the Open Publication License, v1.0 or later (the latest version is 7 presently available at http://www.opencontent.org/openpub/) and provided that 8 neither the name of the Free Standards Group, the name of the Linux Standard 9 Base, nor the names of its contributors may be used to endorse or promote 10 derived works without specific prior written permission. 11 12 Portions of the text were taken from other copyrighted documents in accordance 13 with the respective license of those documents. 14 15 ------------------------------------------------------------------------------- 16 17 Table of Contents 18 I. Introduction 19 20 1. Introduction 21 22 Introduction 23 Purpose 24 Related Standards 25 Related Implementations 26 Relevant Libraries 27 How to Use this Standard 28 Definitions 29 Terminology 30 31 II. Low Level System Information 32 33 2. Machine Interface 34 35 Processor Architecture 36 Data Representation 37 38 3. Function Calling Sequence 39 40 CPU Registers 41 Floating Point Registers 42 Stack Frame 43 Arguments 44 Return Values 45 46 4. Operating System Interface 47 48 Virtual Address Space 49 Processor Execution Mode 50 Exception Interface 51 Signal Delivery 52 53 5. Process Initialization 54 55 Special Registers 56 Process Stack (on entry) 57 Auxilliary Vectors 58 Environment 59 60 6. Coding Examples 61 62 Code Model Overview/Architecture Constraints 63 Position-Independent Fucntion Prologue 64 Data Objects 65 Function Calls 66 Branching 67 68 7. C Stack Frame 69 70 Variable Argument List 71 Dynamic Allocation of Stack Space 72 73 8. Debug Information 74 75 III. Object Format 76 77 9. ELF Header 78 79 Machine Information 80 81 10. Sections 82 83 Special Sections 84 Linux Special Sections 85 Section Types 86 Section Attribute Flags 87 Special Section Types 88 89 11. Symbol Table 90 12. Relocation 91 92 Relocation Types 93 94 IV. Program Loading and Dynamic Linking 95 96 13. Program Header 97 98 Types 99 Flags 100 101 14. Program Loading 102 15. Dynamic Linking 103 104 Program Intepreter/Dynamic Linker 105 Dynamic Section 106 Global Offset Table 107 Shared Object Dependencies 108 Function Addresses 109 Procedure Linkage Table 110 Initialization and Termination Functions 111 112 V. Base Libraries 113 114 16. Libraries 115 116 Interfaces for libc 117 Data Definitions for libc 118 Interfaces Definitions for libc 119 Interfaces for libm 120 Data Definitions for libm 121 122 A. Alphabetical Listing of Interfaces 123 124 libc 125 126 List of Tables 127 1-1. Related Standards 128 1-2. Related Implementations 129 1-3. Relevant Libraries 130 2-1. Scalar Types 131 10-1. 132 10-2. 133 16-1. libc Definition 134 16-2. libc - Standard Library Function Interfaces 135 16-3. libc - Language Support Function Interfaces 136 16-4. libm Definition 137 A-1. libc Function Interfaces 138 139 I. Introduction 140 141 Table of Contents 142 1. Introduction 143 144 ------------------------------------------------------------------------------- 145 146 Chapter 1. Introduction 147 148 Introduction 149 150 This is version 1.1.0 of the Linux Standard Base Specification for the IA32 151 Architecture. An implementation of this version of the specification may not 152 claim to be an implementation of the Linux Standard Base unless it has 153 successfully completed the compliance process as defined by the Free Standards 154 Group. 155 156 ------------------------------------------------------------------------------- 157 158 Purpose 159 160 The Linux Standard Base (LSB) defines a system interface for compiled 161 applications and a minimal environment for support of installation scripts. Its 162 purpose is to enable a uniform industry standard environment for high-volume 163 applications conforming to the LSB. 164 165 The LSB defines a binary interface for application programs that are compiled 166 and packaged for LSB-conforming implementations on many different hardware 167 architectures. Since a binary specification must include information specific 168 to the computer processor architecture for which it is intended, it is not 169 possible for a single document to specify the interface for all possible 170 LSB-conforming implementations. Therefore, the LSB is a family of 171 specifications, rather than a single one. 172 173 The LSB is composed of two basic parts: A common part of the specification 174 describes those parts of the interface that remain constant across all hardware 175 implementations of the LSB, and an architecture-specific part of the 176 specification describes the parts of the specification that are specific to a 177 particular processor architecture. Together, the generic LSB and the 178 architecture-specific supplement for a single hardware architecture provide a 179 complete interface specification for compiled application programs on systems 180 that share a common hardware architecture. 181 182 This document is the architecture-specific suppliment. It must be used in 183 conjunction with the generic LSB. This document provides architecture-specific 184 information that supplements the generic LSB as well as additional information 185 that is not found in the generic LSB. 186 187 This document should be used in conjunction with the documents it references. 188 This document enumerates the system components it includes, but descriptions of 189 those components may be included entirely or partly in this document, partly in 190 other documents, or entirely in other reference documents. For example, the 191 section that describes system service routines includes a list of the system 192 routines supported in this interface, formal declarations of the data 193 structures they use that are visible to applications, and a pointer to the 194 underlying referenced specification for information about the syntax and 195 semantics of each call. Only those routines not described in standards 196 referenced by this document, or extensions to those standards, are described in 197 the detail. Information referenced in this way is as much a part of this 198 document as is the information explicitly included here. 199 200 ------------------------------------------------------------------------------- 201 202 Related Standards 203 204 The specifications listed below are referenced in whole or in part by the Linux 205 Standard Base. Such references may be normative or non-normative; a reference 206 to specification shall only be considered normative if it is explicitly cited 207 as such. The LSB may make normative references to a portion of these 208 specifications (that is, to define a specific function or group of functions); 209 in such cases, only the explicitly referenced portion of the specification is 210 to be considered normative. 211 212 Table 1-1. Related Standards 213 214 +-----------------------------------------------------------------------------+ 215 |System V Application Binary Interface |http://www.caldera.com| | 216 |- DRAFT - 22 June 2000 |/developers/gabi/ | | 217 | |2000-07-17/ | | 218 | |contents.html | | 219 |--------------------------------------+----------------------+---------------| 220 |Filesystem Hierarchy Standard 2.2 |http:// | | 221 | |www.pathname.com/fhs/ | | 222 |--------------------------------------+----------------------+---------------| 223 |IEEE Standard for Binary |http://www.ieee.org/ |ANSI/IEEE | 224 |Floating-Point Arithmetic | |Standards | 225 | | |745-1985 and | 226 | | |854-1987 | 227 |--------------------------------------+----------------------+---------------| 228 |System V Application Binary Interface,|http://www.caldera.com| | 229 |Edition 4.1 |/developers/devspecs/ | | 230 | |gabi41.pdf | | 231 |--------------------------------------+----------------------+---------------| 232 |IA32 Architecture Software Developer's|http:// | | 233 |Manual Volume 1: Basic Architecture |developer.intel.com/ | | 234 | |design/pentiium4/ | | 235 | |manuals/24570.ht | | 236 |--------------------------------------+----------------------+---------------| 237 |IA32 Architecture Software Developer's|http:// | | 238 |Manual Volume 2: Instruction Set |developer.intel.com/ | | 239 |Reference |design/pentiium4/ | | 240 | |manuals/24571.ht | | 241 |--------------------------------------+----------------------+---------------| 242 |IA32 Architecture Software Developer's|http:// | | 243 |Manual Volume 3: System Programming |developer.intel.com/ | | 244 |Guide |design/pentiium4/ | | 245 | |manuals/24572.ht | | 246 |--------------------------------------+----------------------+---------------| 247 |System V Application Binary Interface |http://www.caldera.com| | 248 |- Intel386 Architecture Processor |/developers/devspecs/ | | 249 |Supplement |abi386-4.pdf | | 250 |--------------------------------------+----------------------+---------------| 251 |Itanium Architecture Software |http:// | | 252 |Developer's Manual Volume 1: |developer.intel.com/ | | 253 |Application Architecture |design/itanium/ | | 254 | |downloads/24531702 | | 255 |--------------------------------------+----------------------+---------------| 256 |Itanium Architecture Software |http:// | | 257 |Developer's Manual Volume 2: System |developer.intel.com/ | | 258 |Architecture |design/itanium/ | | 259 | |downloads/24531802 | | 260 |--------------------------------------+----------------------+---------------| 261 |Itanium Architecture Software |http:// | | 262 |Developer's Manual Volume 3: |developer.intel.com/ | | 263 |Instruction Set Reference |design/itanium/ | | 264 | |downloads/24531902 | | 265 |--------------------------------------+----------------------+---------------| 266 |Itanium Architecture Software |http:// | | 267 |Developer's Manual Volume 4: Itanium |developer.intel.com/ | | 268 |Processor Programmer's Guide |design/itanium/ | | 269 | |downloads/24532002 | | 270 |--------------------------------------+----------------------+---------------| 271 |Itanium(R) Software Conventions & |http:// | | 272 |Runtime Architecture Guide |developer.intel.com/ | | 273 | |design/ia-64/downloads| | 274 | |/245358.htm | | 275 |--------------------------------------+----------------------+---------------| 276 |ISO/IEC 9899: 1990, Programming | | | 277 |Languages --C | | | 278 |--------------------------------------+----------------------+---------------| 279 |ISO/IEC 9899: 1999, Programming | | | 280 |Languages --C | | | 281 |--------------------------------------+----------------------+---------------| 282 |Linux Assigned Names And Numbers |http://www.lanana.org/| | 283 |Authority | | | 284 |--------------------------------------+----------------------+---------------| 285 |Large File Support |http:// | | 286 | |www.UNIX-systems.org/ | | 287 | |version2/whatsnew/ | | 288 | |lfs20mar.html | | 289 |--------------------------------------+----------------------+---------------| 290 |Linux Standard Base |http:// | | 291 | |www.linuxbase.org/spec| | 292 | |/ | | 293 |--------------------------------------+----------------------+---------------| 294 |OpenGL® Application Binary Interface |http://oss.sgi.com/ | | 295 |for Linux |projects/ogl-sample/ | | 296 | |ABI/ | | 297 |--------------------------------------+----------------------+---------------| 298 |IEEE Std POSIX 1003.2-1992 (ISO/IEC |http://www.ieee.org/ | | 299 |9945-2:1993) | | | 300 |--------------------------------------+----------------------+---------------| 301 |POSIX 1003.1c |http://www.ieee.org/ | | 302 |--------------------------------------+----------------------+---------------| 303 |CAE Specification, May 1996, X/Open |http:// | | 304 |Curses, Issue 4, Version 2 (ISBN: |www.opengroup.org/ | | 305 |1-85912-171-3, C610), plus Corrigendum| | | 306 |U018 | | | 307 |--------------------------------------+----------------------+---------------| 308 |CAE Specification, January 1997, |http:// | | 309 |System Interface Definitions (XBD), |www.opengroup.org/ | | 310 |Issue 5 (ISBN: 1-85912-186-1, C605) | | | 311 |--------------------------------------+----------------------+---------------| 312 |CAE Specification, January 1997, |http:// | | 313 |Commands and Utilities (XCU), Issue 5 |www.opengroup.org/ | | 314 |(ISBN: 1-85912-191-8, C604) | | | 315 |--------------------------------------+----------------------+---------------| 316 |CAE Specification, February 1997, |http:// | | 317 |Networking Services (XNS), Issue 5 |www.opengroup.org/ | | 318 |(ISBN: 1-85912-165-9, C523) | | | 319 |--------------------------------------+----------------------+---------------| 320 |CAE Specification, January 1997, |http:// | | 321 |System Interfaces and Headers (XSH), |www.opengroup.org/ | | 322 |Issue 5 (ISBN: 1-85912-181-0, C606) | | | 323 |--------------------------------------+----------------------+---------------| 324 |The Single UNIX Specification Version |http:// | | 325 |1 (UNIX 95) System Interfaces & |www.opengroup.org/ | | 326 |Headers | | | 327 |--------------------------------------+----------------------+---------------| 328 |System V Interface Definition, Issue 3| |ISBN 0201566524| 329 |--------------------------------------+----------------------+---------------| 330 |System V Interface Definition,Fourth | | | 331 |Edition | | | 332 |--------------------------------------+----------------------+---------------| 333 |Double Buffer Extension Library |http://www.x.org/ | | 334 |--------------------------------------+----------------------+---------------| 335 |X Display Power Management Signaling |http://www.x.org/ | | 336 |(DPMS) Extension, Library | | | 337 |Specification | | | 338 |--------------------------------------+----------------------+---------------| 339 |X Record Extension Library |http://www.x.org/ | | 340 |--------------------------------------+----------------------+---------------| 341 |Security Extension Specification, |http://www.x.org/ | | 342 |Version 7.1 | | | 343 |--------------------------------------+----------------------+---------------| 344 |X Nonrectangular Window Shape |http://www.x.org/ | | 345 |Extension Library Version 1.0 | | | 346 |--------------------------------------+----------------------+---------------| 347 |MIT-SHM--The MIT Shared Memory |http://www.x.org/ | | 348 |Extension | | | 349 |--------------------------------------+----------------------+---------------| 350 |X Synchronization Extension Library |http://www.x.org/ | | 351 |--------------------------------------+----------------------+---------------| 352 |XTEST Extension Library |http://www.x.org/ | | 353 |--------------------------------------+----------------------+---------------| 354 |X11R6.4 X Inter-Client Exchange (ICE) |http://www.x.org/ | | 355 |Protocol | | | 356 |--------------------------------------+----------------------+---------------| 357 |X11R6.4 X11 Input Extension Library |http://www.x.org/ | | 358 |--------------------------------------+----------------------+---------------| 359 |X11R6.4 Xlib - C library |http://www.x.org/ | | 360 |--------------------------------------+----------------------+---------------| 361 |X/Open Portability Guide, Issue 4 |http:// | | 362 | |www.opengroup.org/ | | 363 |--------------------------------------+----------------------+---------------| 364 |X11R6.4 X Session Management Library |http://www.x.org/ | | 365 |--------------------------------------+----------------------+---------------| 366 |X11R.4 X Toolkit Intrinsics |http://www.x.org/ | | 367 |--------------------------------------+----------------------+---------------| 368 |zlib 1.1.3 Manual |http://www.gzip.org/ |See | 369 | |zlib/ | | 370 +-----------------------------------------------------------------------------+ 371 ------------------------------------------------------------------------------- 372 373 Related Implementations 374 375 The implementations listed here are referenced in whole or in part by the Linux 376 Standard Base when no formal specification is available. 377 378 Table 1-2. Related Implementations 379 380 +-----------------------------------------------------------------------------+ 381 |BSD 4.4 Lite | | | 382 |version 2 | | | 383 |------------------+--------------------+-------------------------------------| 384 |GNU/Linux defacto |http://www.gnu.org/ | | 385 |standard | | | 386 |------------------+--------------------+-------------------------------------| 387 |RFC 1831 & 1832 |http://www.ietf.org/|Still need API reference, instead of | 388 | | |protocol reference | 389 |------------------+--------------------+-------------------------------------| 390 |RPM Package Format|http://www.rpmdp.org| | 391 |V3.0 |/rpmbook/ | | 392 +-----------------------------------------------------------------------------+ 393 ------------------------------------------------------------------------------- 394 395 Relevant Libraries 396 397 The libraries listed here shall be available on a Linux Standard Base system. 398 This list is an addition to the list in the general specification. 399 400 Table 1-3. Relevant Libraries 401 402 +--------------------------------+ 403 |Library |Runtime Name | 404 |---------------+----------------| 405 |libm |libm.so.6 | 406 |---------------+----------------| 407 |libutil |libutil.so.1 | 408 |---------------+----------------| 409 |libc |libc.so.6 | 410 |---------------+----------------| 411 |libpthread |libpthread.so.0 | 412 |---------------+----------------| 413 |proginterp-ia32|/lib/ld-lsb.so.1| 414 |---------------+----------------| 415 |librt |librt.so.1 | 416 +--------------------------------+ 417 418 These libraries will be in an implementation-dependent directory which the 419 dynamic linker will search by default. 420 421 ------------------------------------------------------------------------------- 422 423 How to Use this Standard 424 425 The complete LSB specification is composed of a generic LSB specification and 426 this supplemental processor-specific specification. These two documents 427 constitute a specification that should be used in conjunction with the 428 publicly-available standards documents it references. The LSB enumerates the 429 system components it includes, but descriptions of those components may be 430 included entirely in the LSB, partly in the LSB and partly in other documents, 431 or entirely in other reference documents. 432 433 ------------------------------------------------------------------------------- 434 435 Definitions 436 437 gLSB 438 439 This document. 440 441 LSB-Compliant Application 442 443 An application written to include only the system routines, commands, and 444 other resources included in this document, and that has been compiled into 445 an executable file that has the formats and characteristics specified for 446 such files in this document, and whose behavior complies, installs, and is 447 executed in the environment with the rules given in this document. 448 449 LSB-Conforming Implementation 450 451 An implementation that provides the binary system interface for 452 applications described in this document. 453 454 Non-LSB-Compliant Application 455 456 An application which has been written to include system routines, commands, 457 or other resources not included in this document, or which has been 458 compiled into a different from those specified here, or which does not 459 behave as specified in this document. 460 461 LSB Implementation Conformance 462 463 An implementation satisfying the following requirements: 464 465 1. The implementation shall implement fully the architecture described in 466 the hardware manual for the target processor architecture. 467 468 2. The implementation shall be capable of executing compiled applications 469 having the and using the system interfaces described in this document. 470 471 3. The implementation shall provide libraries containing the interfaces 472 specified by this document, and shall provide a dynamic linking 473 mechanism that allows these interfaces to be attached to applications 474 at runtime. All the interfaces shall behave as specified in the 475 normative references and requirements of this document. 476 477 4. The map of virtual memory provided by the implementation shall conform 478 to the requirements of this document. 479 480 5. The implementation's low-level behavior with respect to function call 481 linkage, system traps, signals, and other such activities shall conform 482 to the formats described in this document. 483 484 6. The compilation system shall compile source code into executable files 485 having the formats and characteristics specified in this document. 486 487 7. The implementation shall provide all of the mandatory interfaces in 488 their entirety. 489 490 8. The implementation may provide one or more of the optional interfaces. 491 Each optional interface that is provided shall be provided in its 492 entirety. The product documentation shall state which optional 493 interfaces are provided. 494 495 9. The implementation shall provide all files and utilities specified as 496 part of this document in the defined here and in other referenced 497 documents. All commands and utilities shall behave as required by this 498 document. The implementation shall also provide all mandatory 499 components of an application's runtime environment that are included or 500 referenced in this document. 501 502 10. The implementation, when provided with standard data formats and values 503 at a named interface, shall provide the behavior defined for those 504 values and data formats at that interface. However, a conforming 505 implementation may consist of components which are separately packaged 506 and/or sold. For example, a vendor of a conforming implementation might 507 sell the hardware, operating system, and windowing system as separately 508 packaged items. 509 510 11. The implementation may provide additional interfaces with different 511 names. It may also provide additional behavior corresponding to data 512 values outside the standard ranges, for standard named interfaces. 513 514 LSB Application Conformance 515 516 An application with the following characteristics: 517 518 1. Its executable files are either shell scripts or object files in the 519 defined for the Object File Format system interface. 520 521 2. Its object files participate in dynamic linking as defined in the 522 Program Loading and Linking System interface. 523 524 3. It employs only the instructions, traps, and other low-level facilities 525 defined in the Low-Level System interface as being for use by 526 applications. 527 528 4. If it requires any optional interface defined in this document in order 529 to be installed or to execute successfully, the requirement for that 530 optional interface is stated in the application's documentation. 531 532 5. It does not use any interface or data that is not required to be 533 provided by a conforming implementation, unless: 534 535 o If such an interface or data is supplied by another application 536 through direct invocation of that application during execution, 537 that application is in turn an LSB-compliant application. 538 539 o The use of that interface or data , as well as its source, is 540 identified in the documentation of the application. 541 542 6. It must not use any values for a named interface that are reserved for 543 vendor extensions. 544 545 A strictly conforming application does not require or use any interface, 546 facility, or implementation-defined extension that is not defined in this 547 document in order to be installed or to execute successfully. 548 549 Rationale 550 551 An LSB-compliant application is expected to have no dependencies on any 552 vendor extensions to this document. The most common such extensions are 553 additional function entry points and additional libraries other than the 554 ones defined in this document. If an application requires such extensions, 555 it is not portable, since other LSB-conforming implementations may not 556 provide those extensions. 557 558 An LSB-compliant application is required to use system services on the 559 implementation on which it is running, rather than importing system 560 routines from some other implementation. Thus, it must link dynamically to 561 any routines in the implementation that perform system traps to kernel 562 services. 563 564 It is to be expected that some applications may be companion applications 565 to other applications. For example, a query application may be a companion 566 to a database application; a preprocessor may be an adjunct to one or more 567 compilers; a data reformatter may convert data from one document manager to 568 another. In such cases, the application may or may not be LSB-compliant, 569 regardless of whether the other application on which it is dependent is 570 LSB-compliant. If such an application merely uses data produced by another 571 application, the application's compliance is independent of the other 572 application's compliance. If such an application actually invokes another 573 application during execution (as, for example, a third-party math library), 574 the invoking application is LSB-compliant only if it also constitutes a 575 LSB-compliant application in combination with the invoked application. 576 577 Shell Script 578 579 A file that is read by an interpreter (e.g., awk). The first line of the 580 shell script includes a reference to its interpreter binary. 581 582 ------------------------------------------------------------------------------- 583 584 Terminology 585 586 can 587 588 Describes a permissible optional feature or behavior available to the user 589 or application. The feature or behavior is mandatory for an implementation 590 that conforms to this document. An application can rely on the existence of 591 the feature or behavior. 592 593 implementation-defined 594 595 Describes a value or behavior that is not defined by this document but is 596 selected by an implementor. The value or behavior may vary among 597 implementations that conform to this document. An application should not 598 rely on the existence of the value or behavior. An application that relies 599 on such a value or behavior cannot be assured to be portable across 600 conforming implementations. The implementor shall document such a value or 601 behavior so that it can be used correctly by an application. 602 603 Same as implementation-dependent. 604 605 may 606 607 Describes a feature or behavior that is optional for an implementation that 608 conforms to this document. An application should not rely on the existence 609 of the feature or behavior. An application that relies on such a feature or 610 behavior cannot be assured to be portable across conforming 611 implementations. 612 613 To avoid ambiguity, the opposite of may is expressed as need not, instead 614 of may not. 615 616 must 617 618 Describes a feature or behavior that is mandatory for an application or 619 user. An implementation that conforms to this document shall support this 620 feature or behavior. 621 622 shall 623 624 Describes a feature or behavior that is mandatory for an implementation 625 that conforms to this document. An application can rely on the existence of 626 the feature or behavior. 627 628 should 629 630 For an implementation that conforms to this document, describes a feature 631 or behavior that is recommended but not mandatory. An application should 632 not rely on the existence of the feature or behavior. An application that 633 relies on such a feature or behavior cannot be assured to be portable 634 across conforming implementations. 635 636 For an application, describes a feature or behavior that is recommended 637 programming practice for optimum portability. 638 639 undefined 640 641 Describes the nature of a value or behavior not defined by this document 642 which results from use of an invalid program construct or invalid data 643 input. The value or behavior may vary among implementations that conform to 644 this document. An application should not rely on the existence or validity 645 of the value or behavior. An application that relies on any particular 646 value or behavior cannot be assured to be portable across conforming 647 implementations. 648 649 unspecified 650 651 Describes the nature of a value or behavior not specified by this document 652 which results from use of a valid program construct or valid data input. 653 The value or behavior may vary among implementations that conform to this 654 document. An application should not rely on the existence or validity of 655 the value or behavior. An application that relies on any particular value 656 or behavior cannot be assured to be portable across conforming 657 implementations. 658 659 will 660 661 Same meaning as shall; shall is the preferred term. 662 663 II. Low Level System Information 664 665 Table of Contents 666 2. Machine Interface 667 3. Function Calling Sequence 668 4. Operating System Interface 669 5. Process Initialization 670 6. Coding Examples 671 7. C Stack Frame 672 8. Debug Information 673 674 ------------------------------------------------------------------------------- 675 676 Chapter 2. Machine Interface 677 678 Processor Architecture 679 680 The IA32 Architecture is specified by the following documents 681 682 * Intel Architecture Software Developer's Manual, Volume 1: Basic 683 Architecture 684 685 * Intel Architecture Software Developer's Manual, Volume 2: Instruction Set 686 Reference Manual 687 688 * Intel Architecture Software Developer's Manual, Volume 3: System 689 Programming Guide 690 691 Only the features of the Intel486 processor instruction set may be assumed to 692 be present. An application is responsible for determining if any additional 693 instruction set features are available before using those additional features. 694 If a feature is not present, then the application may not use it. 695 696 Applications conforming to this specification must provide feedback to the user 697 if a feature that is required for correct execution of the application is not 698 present. Applications conforming to this specification should attempt to 699 execute in a diminished capacity if a required instruction set feature is not 700 present. 701 702 This specfication does not provide any performance guarantees of a conforming 703 system. A system conforming to this specification may be implemented in either 704 hardware or software. 705 706 ------------------------------------------------------------------------------- 707 708 Data Representation 709 710 LSB-conforming applications shall use the data representation as defined in 711 Chapter 3 of the System V Application Binary Interface - Intel386 Architecture 712 Processor Supplement. 713 714 ------------------------------------------------------------------------------- 715 716 Byte Ordering 717 718 ------------------------------------------------------------------------------- 719 720 Fundamental Types 721 722 In addition to the fundamental types specified in Chapter 3 of the System V 723 Application Binary Interface - Intel386 Architecture, a 64 bit data type is 724 defined here. 725 726 Table 2-1. Scalar Types 727 728 +---------------------------------------------------------------------------+ 729 |Type |C |sizeof|Alignment (bytes)|IntelI386 Architecture| 730 |--------+------------------+------+-----------------+----------------------| 731 | |long long | | | | 732 | |------------------|8 |4 |signed double word | 733 |Integral|signed long long | | | | 734 | |------------------+------+-----------------+----------------------| 735 | |unsigned long long|8 |4 |unsigned double word | 736 +---------------------------------------------------------------------------+ 737 738 ------------------------------------------------------------------------------- 739 740 Aggregates and Unions 741 742 ------------------------------------------------------------------------------- 743 744 Bit Fields 745 746 ------------------------------------------------------------------------------- 747 748 Chapter 3. Function Calling Sequence 749 750 LSB-conforming applications shall use the function calling sequence as defined 751 in Chapter 3 of the System V Application Binary Interface - Intel386 752 Architecture Processor Supplement. 753 754 ------------------------------------------------------------------------------- 755 756 CPU Registers 757 758 ------------------------------------------------------------------------------- 759 760 Floating Point Registers 761 762 ------------------------------------------------------------------------------- 763 764 Stack Frame 765 766 ------------------------------------------------------------------------------- 767 768 Arguments 769 770 ------------------------------------------------------------------------------- 771 772 Integral/Pointer 773 774 ------------------------------------------------------------------------------- 775 776 Floating Point 777 778 ------------------------------------------------------------------------------- 779 780 Struct and Union Point 781 782 ------------------------------------------------------------------------------- 783 784 Variable Arguments 785 786 ------------------------------------------------------------------------------- 787 788 Return Values 789 790 ------------------------------------------------------------------------------- 791 792 Void 793 794 ------------------------------------------------------------------------------- 795 796 Integral/Pointer 797 798 ------------------------------------------------------------------------------- 799 800 Floating Point 801 802 ------------------------------------------------------------------------------- 803 804 Struct and Union Point 805 806 ------------------------------------------------------------------------------- 807 808 Chapter 4. Operating System Interface 809 810 LSB-conforming applications shall use the Operating System Interfaces as 811 defined in Chapter 3 of the System V Application Binary Interface - Intel386 812 Architecture Processor Supplement. 813 814 ------------------------------------------------------------------------------- 815 816 Virtual Address Space 817 818 ------------------------------------------------------------------------------- 819 820 Page Size 821 822 ------------------------------------------------------------------------------- 823 824 Virtual Address Assignments 825 826 ------------------------------------------------------------------------------- 827 828 Managing the PRocess Stack 829 830 ------------------------------------------------------------------------------- 831 832 Coding Guidlines 833 834 ------------------------------------------------------------------------------- 835 836 Processor Execution Mode 837 838 ------------------------------------------------------------------------------- 839 840 Exception Interface 841 842 ------------------------------------------------------------------------------- 843 844 Hardware Exception Types 845 846 ------------------------------------------------------------------------------- 847 848 Software Trap Types 849 850 ------------------------------------------------------------------------------- 851 852 Signal Delivery 853 854 ------------------------------------------------------------------------------- 855 856 Signal Handler Interface 857 858 ------------------------------------------------------------------------------- 859 860 Chapter 5. Process Initialization 861 862 LSB-conforming applications shall use the Process Initialization as defined in 863 Chapter 3 of the System V Application Binary Interface - Intel386 Architecture 864 Processor Supplement. 865 866 ------------------------------------------------------------------------------- 867 868 Special Registers 869 870 ------------------------------------------------------------------------------- 871 872 Process Stack (on entry) 873 874 ------------------------------------------------------------------------------- 875 876 Auxilliary Vectors 877 878 ------------------------------------------------------------------------------- 879 880 Environment 881 882 ------------------------------------------------------------------------------- 883 884 Chapter 6. Coding Examples 885 886 LSB-conforming applications may implement fundamental operations using the 887 Coding Examples as defined in Chapter 3 of the System V Application Binary 888 Interface - Intel386 Architecture Processor Supplement. 889 890 ------------------------------------------------------------------------------- 891 892 Code Model Overview/Architecture Constraints 893 894 ------------------------------------------------------------------------------- 895 896 Position-Independent Fucntion Prologue 897 898 ------------------------------------------------------------------------------- 899 900 Data Objects 901 902 ------------------------------------------------------------------------------- 903 904 Absolute Load & Store 905 906 ------------------------------------------------------------------------------- 907 908 Position Relative Load & Store 909 910 ------------------------------------------------------------------------------- 911 912 Function Calls 913 914 ------------------------------------------------------------------------------- 915 916 Absolute Direct Function Call 917 918 ------------------------------------------------------------------------------- 919 920 Absolute Indirect Function Call 921 922 ------------------------------------------------------------------------------- 923 924 Position-Independent Direct Function Call 925 926 ------------------------------------------------------------------------------- 927 928 Position-Independent Indirect Function Call 929 930 ------------------------------------------------------------------------------- 931 932 Branching 933 934 ------------------------------------------------------------------------------- 935 936 Branch Instruction 937 938 ------------------------------------------------------------------------------- 939 940 Absolute switch() code 941 942 ------------------------------------------------------------------------------- 943 944 Position-Independent switch() code 945 946 ------------------------------------------------------------------------------- 947 948 Chapter 7. C Stack Frame 949 950 Variable Argument List 951 952 ------------------------------------------------------------------------------- 953 954 Dynamic Allocation of Stack Space 955 956 ------------------------------------------------------------------------------- 957 958 Chapter 8. Debug Information 959 960 The LSB does not currently specify the format of Debug information. 961 962 III. Object Format 963 964 LSB-conforming implementations shall support an object file , called Executable 965 and Linking Format (ELF) as defined by the System V Application Binary 966 Interface, Edition 4.1, the System V Application Binary Interface - DRAFT - 967 April 29, 1998, System V Application Binary Interface - Intel386 Architecture 968 Processor Supplement and as supplemented by the Linux Standard Base 969 Specification and this document. 970 971 Table of Contents 972 9. ELF Header 973 10. Sections 974 11. Symbol Table 975 12. Relocation 976 977 ------------------------------------------------------------------------------- 978 979 Chapter 9. ELF Header 980 981 Machine Information 982 983 LSB-conforming applications shall use the Machine Information as defined in 984 Chapter 4 of the System V Application Binary Interface - Intel386 Architecture 985 Processor Supplement. 986 987 ------------------------------------------------------------------------------- 988 989 File Class 990 991 ------------------------------------------------------------------------------- 992 993 Data Encoding 994 995 ------------------------------------------------------------------------------- 996 997 OS Identification 998 999 ------------------------------------------------------------------------------- 1000 1001 Processor Identification 1002 1003 ------------------------------------------------------------------------------- 1004 1005 Processor Specific Flags 1006 1007 ------------------------------------------------------------------------------- 1008 1009 Chapter 10. Sections 1010 1011 ------------------------------------------------------------------------------- 1012 1013 Special Sections 1014 1015 The following sections are defined in the System V Application Binary Interface 1016 - Intel386 Architecture Processor Supplement. 1017 1018 Table 10-1. 1019 1020 +-----------------------------------------+ 1021 |Name| Type | Attributes | 1022 |----+------------+-----------------------| 1023 |.got|SHT_PROGBITS|SHF_ALLOC+SHF_WRITE | 1024 |----+------------+-----------------------| 1025 |.plt|SHT_PROGBITS|SHF_ALLOC+SHF_EXECINSTR| 1026 +-----------------------------------------+ 1027 1028 .got 1029 1030 This section holds the global offset table. 1031 1032 .plt 1033 1034 This section holds the procedure linkage table. 1035 1036 1037 1038 ------------------------------------------------------------------------------- 1039 1040 Linux Special Sections 1041 1042 The following Linux IA-32 specific sections are defined here. 1043 1044 Table 10-2. 1045 1046 +--------------------------+ 1047 |Name | Type |Attributes | 1048 |-----+--------+-----------| 1049 |.sbss|SHT_NOTE|SHF_WRITE | 1050 +--------------------------+ 1051 1052 .sbss 1053 1054 Need a proper description 1055 1056 1057 1058 ------------------------------------------------------------------------------- 1059 1060 Section Types 1061 1062 ------------------------------------------------------------------------------- 1063 1064 Section Attribute Flags 1065 1066 ------------------------------------------------------------------------------- 1067 1068 Special Section Types 1069 1070 ------------------------------------------------------------------------------- 1071 1072 Chapter 11. Symbol Table 1073 1074 LSB-conforming applications shall use the Symbol Table as defined in Chapter 4 1075 of the System V Application Binary Interface - Intel386 Architecture Processor 1076 Supplement. 1077 1078 ------------------------------------------------------------------------------- 1079 1080 Chapter 12. Relocation 1081 1082 LSB-conforming applications shall use Relocations as defined in Chapter 4 of 1083 the System V Application Binary Interface - Intel386 Architecture Processor 1084 Supplement. 1085 1086 ------------------------------------------------------------------------------- 1087 1088 Relocation Types 1089 1090 IV. Program Loading and Dynamic Linking 1091 1092 LSB-conforming implementations shall support the object file information and 1093 system actions that create running programs as specified in the System V 1094 Application Binary Interface, Edition 4.1, the System V Application Binary 1095 Interface - DRAFT - April 29, 1998, System V Application Binary Interface - 1096 Intel386 Architecture Processor Supplement and as supplemented by the Linux 1097 Standard Base Specification and this document. 1098 1099 Table of Contents 1100 13. Program Header 1101 14. Program Loading 1102 15. Dynamic Linking 1103 1104 ------------------------------------------------------------------------------- 1105 1106 Chapter 13. Program Header 1107 1108 ------------------------------------------------------------------------------- 1109 1110 Types 1111 1112 ------------------------------------------------------------------------------- 1113 1114 Flags 1115 1116 ------------------------------------------------------------------------------- 1117 1118 Chapter 14. Program Loading 1119 1120 ------------------------------------------------------------------------------- 1121 1122 Chapter 15. Dynamic Linking 1123 1124 ------------------------------------------------------------------------------- 1125 1126 Program Intepreter/Dynamic Linker 1127 1128 The LSB specifies the Program Interpreter to be 1129 1130 * /lib/ld-lsb.so.1 1131 1132 ------------------------------------------------------------------------------- 1133 1134 Dynamic Section 1135 1136 The following dynamic entries are defined in the System V Application Binary 1137 Interface - Intel386 Architecture Processor Supplement. 1138 1139 DT_PLTGOT 1140 1141 On the Intel386 architecture, this entrys d_ptr member gives the address of 1142 the first entry in the global offset table. 1143 1144 1145 1146 ------------------------------------------------------------------------------- 1147 1148 Global Offset Table 1149 1150 ------------------------------------------------------------------------------- 1151 1152 Shared Object Dependencies 1153 1154 ------------------------------------------------------------------------------- 1155 1156 Function Addresses 1157 1158 ------------------------------------------------------------------------------- 1159 1160 Procedure Linkage Table 1161 1162 ------------------------------------------------------------------------------- 1163 1164 Initialization and Termination Functions 1165 1166 V. Base Libraries 1167 1168 Table of Contents 1169 16. Libraries 1170 1171 ------------------------------------------------------------------------------- 1172 1173 Chapter 16. Libraries 1174 1175 An LSB-conforming implementation shall support some base libraries which 1176 provide interfaces for accessing the operating system, processor and other 1177 hardware in the system. 1178 1179 Interfaces that are unique to the IA32 platform are defined here. This section 1180 should be used in conjunction with the corresponding section in the Linux 1181 Standard Base Specification. 1182 1183 ------------------------------------------------------------------------------- 1184 1185 Interfaces for libc 1186 1187 Table 16-1. libc Definition 1188 1189 +-------------------+ 1190 |Library:|libc | 1191 |--------+----------| 1192 |SONAME: |libc.so.6 | 1193 +-------------------+ 1194 1195 The behavior of the interfaces in this library is specified by the following 1196 standards. 1197 1198 Linux Standard Base[1] 1199 1200 ------------------------------------------------------------------------------- 1201 1202 Standard Library 1203 1204 Table 16-2. libc - Standard Library Function Interfaces 1205 1206 +---------------------------------------------+ 1207 |ioperm(GLIBC_2.0)[1]|iopl(GLIBC_2.0)[1]| | | | 1208 +---------------------------------------------+ 1209 ------------------------------------------------------------------------------- 1210 1211 Language Support 1212 1213 Table 16-3. libc - Language Support Function Interfaces 1214 1215 +-------------------------------+ 1216 |__divdi3(GLIBC_2.0)[1] | | | | | 1217 +-------------------------------+ 1218 ------------------------------------------------------------------------------- 1219 1220 Data Definitions for libc 1221 1222 ------------------------------------------------------------------------------- 1223 1224 Interfaces Definitions for libc 1225 1226 Table of Contents 1227 __divdi3 -- mathematic operation 1228 ioperm -- set port input/output permissions 1229 iopl -- change I/O privilege level 1230 1231 __divdi3 1232 1233 Name 1234 1235 __divdi3 -- mathematic operation 1236 1237 Synopsis 1238 1239 DItype 1240 __divdi3(DItype u, DItype v); 1241 1242 Description 1243 1244 __divdi3() divides two DItypes(unsigned ints). 1245 1246 __divdi3 is not in the source standard; it is only in the binary standard. 1247 1248 ioperm 1249 1250 Name 1251 1252 ioperm -- set port input/output permissions 1253 1254 Synopsis 1255 1256 #include /* for libc5 */ 1257 #include /* for glibc */ 1258 1259 int ioperm(unsigned long from, unsigned long num, int turn_on); 1260 1261 Description 1262 1263 ioperm sets the port access permission bits for the process for num bytes 1264 starting from port address from to the value turn_on. The use of ioperm 1265 requires root privileges. 1266 1267 Only the first 0x3ff I/O ports can be specified in this manner. For more ports, 1268 the iopl function must be used. Permissions are not inherited on fork, but on 1269 exec they are. This is useful for giving port access permissions to 1270 non-privileged tasks. 1271 1272 Return Value 1273 1274 On success, zero is returned. On error, -1 is returned, and errno is set 1275 appropriately. 1276 1277 Notes 1278 1279 Libc5 treats it as a system call and has a prototype in . Glibc1 does 1280 not have a prototype. Glibc2 has a prototype both in and in . Avoid the latter, it is available on i386 only. 1282 1283 iopl 1284 1285 Name 1286 1287 iopl -- change I/O privilege level 1288 1289 Synopsis 1290 1291 #include /* for libc5 */ 1292 #include /* for glibc */ 1293 1294 int iopl(int level); 1295 1296 Description 1297 1298 iopl changes the I/O privilege level of the current process, as specified in 1299 level. 1300 1301 This call is necessary to allow 8514-compatible X servers to run under Linux. 1302 Since these X servers require access to all 65536 I/O ports, the ioperm call is 1303 not sufficient. 1304 1305 In addition to granting unrestricted I/O port access, running at a higher I/O 1306 privilege level also allows the process to disable interrupts. This will 1307 probably crash the system, and is not recommended. 1308 1309 Permissions are inherited by fork and exec. 1310 1311 The I/O privilege level for a normal process is 0. 1312 1313 Return Value 1314 1315 On success, zero is returned. On error, -1 is returned, and errno is set 1316 appropriately. 1317 1318 Errors 1319 1320 EINVAL 1321 1322 level is greater than 3. 1323 1324 EPERM 1325 1326 The current user is not the super-user. 1327 1328 Notes from the Kernel Source 1329 1330 iopl has to be used when you want to access the I/O ports beyond the 0x3ff 1331 range: to get the full 65536 ports bitmapped you'd need 8kB of bitmaps/process, 1332 which is a bit excessive. 1333 1334 Notes 1335 1336 Libc5 treats it as a system call and has a prototype in . Glibc1 does 1337 not have a prototype. Glibc2 has a prototype both in and in . Avoid the latter, it is available on i386 only. 1339 1340 ------------------------------------------------------------------------------- 1341 1342 Interfaces for libm 1343 1344 Table 16-4. libm Definition 1345 1346 +-------------------+ 1347 |Library:|libm | 1348 |--------+----------| 1349 |SONAME: |libm.so.6 | 1350 +-------------------+ 1351 1352 ------------------------------------------------------------------------------- 1353 1354 Data Definitions for libm 1355 1356 ------------------------------------------------------------------------------- 1357 1358 Appendix A. Alphabetical Listing of Interfaces 1359 1360 ------------------------------------------------------------------------------- 1361 1362 libc 1363 1364 The behaviour of the interfaces in this library is specified by the following 1365 Standards. 1366 1367 Linux Standard Base 1368 1369 Table A-1. libc Function Interfaces 1370 1371 +--------------------------------------------------------------+ 1372 |__divdi3(GLIBC_2.0)[1]|ioperm(GLIBC_2.0)[1]|iopl(GLIBC_2.0)[1]| 1373 +--------------------------------------------------------------+ 1374 1375 Notes 1376 1377 [1] Linux Standard Base 1378