Linkers and Loaders

Total Page:16

File Type:pdf, Size:1020Kb

Linkers and Loaders Linkers and Loaders CS 167 VI–1 Copyright © 2008 Thomas W. Doeppner. All rights reserved. Does Location Matter? int main(int argc, char *[ ]) { return(argc); } main: pushl %ebp ; push frame pointer movl %esp, %ebp ; set frame pointer to point to new frame movl 8(%ebp), %eax ; put argc into return register (eax) movl %ebp, %esp ; restore stack pointer popl %ebp ; pop stack into frame pointer ret ; return: pops end of stack into eip CS 167 VI–2 Copyright © 2008 Thomas W. Doeppner. All rights reserved. The material in this slide through slide 14 is taken directly from the textbook. Location Matters … int X=6; int *aX = &X; int main( ) { void subr(int); int y=X; subr(y); return(0); } void subr(int i) { printf("i = %d\n", i); } CS 167 VI–3 Copyright © 2008 Thomas W. Doeppner. All rights reserved. We don’t need to look at the assembler code to see what’s different about this program: the machine code produced for it can’t simply be copied to an arbitrary location in our computer’s memory and executed. The location identified by the name aX should contain the address of the location containing X. But since the address of X will not be known until the program is copied into memory, neither the compiler nor the assembler can initialize aX correctly. Similarly, the addresses of subr and printf are not known until the program is copied into memory — again, neither the compiler nor the assembler would know what addresses to use. A Slight Revision extern int X; #include <stdio.h> int *aX = &X; int X; int main( ) { void subr(int i) { void subr(int); printf("i = %d\n", i); int y = *aX; } subr(y); subr.c return(0); } main.c gcc –o prog main.c subr.c CS 167 VI–4 Copyright © 2008 Thomas W. Doeppner. All rights reserved. main.s 0: .data ; what follows is initialized data 0: .globl aX ; aX is global: it may be used by others 0: aX: 0: .long X 4: 0: .text ; offset restarts; what follows is text (read-only code) 0: .globl main 0: main: 0: pushl %ebp ; save the frame pointer 1: movl %esp,%ebp ; point to current frame 3: subl $4,%esp ; make space for y on stack 6: movl aX,%eax ; put contents of X into eax 11: movl (%eax),%eax ; put *X into %eax 13: movl %eax,-4(%ebp) ; store *aX into y 16: pushl -4(%ebp) ; push y onto stack 19: call subr 24: addl $4,%esp ; remove y from stack 27: movl $0,%eax ; set return value to 0 31: movl %ebp, %esp ; restore stack pointer 33: popl %ebp ; pop frame pointer 35: ret CS 167 VI–5 Copyright © 2008 Thomas W. Doeppner. All rights reserved. subr.s 0: .data ; what follows is initialized data 0: printfarg: 0: .string "i = %d\n" 8: 0: .comm X,4 ; 4 bytes in BSS is required for global X 4: 0: .text ; offset restarts; what follows is text (read-only code) 0: .globl subr 0: subr: 0: pushl %ebp ; save the frame pointer 1: movl %esp, %ebp ; point to current frame 3: pushl 8(%ebp) ; push i onto stack 6: pushl $printfarg ; push address of string onto stack 11: call printf 16: addl $8, %esp ; pop arguments from stack 19: movl %ebp, %esp ; restore stack pointer 21: popl %ebp ; pop frame pointer 23: ret CS 167 VI–6 Copyright © 2008 Thomas W. Doeppner. All rights reserved. main.o Data: Size: 4 Global: aX, offset 0 Undefined: X Relocation: offset 0, size 4, value: address of X Contents: 0x00000000 bss: Size: 0 Text: Size: 36 Global: main, offset 0 Undefined: subr Relocation: offset 7, size 4, value: address of aX offset 20, size 4, value: PC-relative address of subr Contents: [machine instructions] CS 167 VI–7 Copyright © 2008 Thomas W. Doeppner. All rights reserved. subr.o Data: Size: 8 Contents: "i = %d\n" bss: Size: 4 Global: X, offset 0 Text: Size: 44 Global: subr, offset 0 Undefined: printf Relocation: offset 7, size 4, value: address of printfarg offset 12, size 4, value: PC-relative address of printf Contents: [machine instructions] CS 167 VI–8 Copyright © 2008 Thomas W. Doeppner. All rights reserved. printf.o Data: Size: 1024 Global: StandardFiles Contents: … bss: Size: 256 Text: Size: 12000 Global: printf, offset 100 … Undefined: write Relocation: offset 211, value: address of StandardFiles offset 723, value: PC-relative address of printf Contents: [machine instructions] CS 167 VI–9 Copyright © 2008 Thomas W. Doeppner. All rights reserved. write.o Data: Size: 0 bss: Size: 4 Global: errno, offset 0 Text: Size: 16 Contents: [machine instructions] CS 167 VI–10 Copyright © 2008 Thomas W. Doeppner. All rights reserved. prog Text main 4096 subr 4132 printf 4156 write 16156 startup 16172 Data aX 16384 printfargs 16388 StandardFiles 16396 bss X 17420 errno 17680 CS 167 VI–11 Copyright © 2008 Thomas W. Doeppner. All rights reserved. Shared Libraries Process A Process B printf( ) stdio printf( ) printf( ) CS 167 VI–12 Copyright © 2008 Thomas W. Doeppner. All rights reserved. Consider the situation shown in the slide: we have two processes, each containing a program that calls printf. Up to this point in our discussion, the two processes have no means for sharing a single copy of printf—each must have its own. If you consider that pretty much every C program calls printf, a huge amount of disk space in the world could be wasted because of all the copies of printf. Furthermore, when each program is loaded into primary memory, large amount of such memory is wasted because of multiple copies of printf. What is needed is a means for programs to share a single copy of printf (as well as other routines). However, sharing of code is not trivial to implement. A big problem is relocation. The code for printf might well contain relocatable addreses, such as references to global data and other procedures. What makes things difficult is that the code for printf might be mapped into the two processes at different virtual locations. Relocation and Shared Libraries 1) Prerelocation: relocate libraries ahead of time 2) Limited sharing: relocate separately for each process 3) Position-Independent Code: no need for relocation CS 167 VI–13 Copyright © 2008 Thomas W. Doeppner. All rights reserved. If all users of printf agree to load it and everything it references into the same locations in their address spaces, we would have no relocation problem. But such agreement is, in general, hard to achieve. It is, however, the approach used in Windows. A possibility might be for the users of printf to share a single on-disk copy, but for this copy to be relocated separately in each process when loaded. This would allow sharing of disk space, but not of primary storage. Another possibility is for printf to be written in such a way that relocation is not necessary. Code written in this fashion is known as position-independent code (PIC). Position-Independent Code ld r2, r1[printf] 0 printf( ) { ld r2, r1[printf] ld r2, call r2 r1[doprint] call r2 call r2 . } 1000 doprint( ) { r1 printf 10000 . r1 printf 20000 } doprint 11000 doprint 21000 CS 167 VI–14 Copyright © 2008 Thomas W. Doeppner. All rights reserved. Here is an example of the use of position-independent code (PIC). Processes A and B are sharing the library containing printf (note that printf contains a call to another shared routine, doprint), though each has it mapped into a different location. Each process maintains a private table, pointed to by register r1. In the table are the addresses of shared routines, as mapped into the process. Thus, rather than call a routine directly (via an address embedded in the code), a position-independent call is made: the address of the desired routine is stored at some fixed offset within the table. The contents of the table at this offset are loaded into register r2, and then the call is made via r2. Linking and Loading on Linux with ELF • Substitution • Shared libraries • Versioning • Dynamic linking • Interpositioning CS 167 VI–15 Copyright © 2008 Thomas W. Doeppner. All rights reserved. ELF stands for “executable and linking format” and is used on most Unix systems, including Linux, Solaris, FreeBSD, NetBSD, and OpenBSD, but not MacOS X. Creating a Library % gcc -c sub1.c sub2.c sub3.c % ls sub1.c sub2.c sub3.c sub1.o sub2.o sub3.o % ar cr libpriv1.a sub1.o sub2.o sub3.o % ar t libpriv1.a sub1.o sub2.o sub3.o % CS 167 VI–16 Copyright © 2008 Thomas W. Doeppner. All rights reserved. Using a Library % cat prog.c % gcc -o prog prog.c -L. -lpriv1 int main() { sub1(); sub2(); sub3(); Where does puts come from? } % cat sub1.c void sub1() { puts("sub1"); } %gcc –o prog prog.c –L. \ -lpriv1 –L/lib -lc CS 167 VI–17 Copyright © 2008 Thomas W. Doeppner. All rights reserved. Substitution % cat myputs.c int puts(char *s) { write(1, "My puts: ", 9); write(1, s, strlen(s)); write(1, "\n", 1); return 1; } % gcc –c myputs.c % ar cr libmyputs.a myputs.o % gcc -o prog prog.c -L. -lpriv1 -lmyputs % CS 167 VI–18 Copyright © 2008 Thomas W. Doeppner. All rights reserved. Shared Libraries 1 Compile program 2 Track down linkages with ld – archives (containing relocatable objects) in “.a” files are statically linked – shared objects in “.so” files are dynamically linked 3 Run program – ld.so is invoked to complete the linking and relocation steps, if necessary CS 167 VI–19 Copyright © 2008 Thomas W.
Recommended publications
  • Download Article (PDF)
    Proceedings of the 2nd International Conference on Computer Science and Electronics Engineering (ICCSEE 2013) SecGOT: Secure Global Offset Tables in ELF Executables Chao Zhang, Lei Duan, Tao Wei, Wei Zou Beijing Key Laboratory of Internet Security Technology Institute of Computer Science and Technology, Peking University Beijing, China {chao.zhang, lei_duan, wei_tao, zou_wei}@pku.edu.cn Abstract—Global Offset Table (GOT) is an important feature library code for these two processes are different). This to support library sharing in Executable and Linkable Format problem also restrains the code sharing feature of libraries. (ELF) applications. The addresses of external modules’ global A solution called PIC (Position Independent Code [3]) is variables and functions are runtime resolved and stored in the proposed for the ELF (Executable and Linkable Format [4]) GOT and then are used by the program. If attackers tamper executable binaries which are common in Linux. with the function pointers in the GOT, they can hijack the In libraries or main modules supporting PIC, the code program’s control flow and execute arbitrary malicious code. section does not reference any absolute addresses in order to Current research pays few attentions on this threat (i.e. GOT support code sharing between processes. However, absolute hijacking attack). In this paper, we proposed and implemented addresses are unavoidable in programs. As a result, a GOT a protection mechanism SecGOT to randomize the GOT at table (Global Offset Table [4]) is introduced in the library. load time, and thus prevent attackers from guessing the GOT’s position and tampering with the function pointers. SecGOT is This table resides in the data section and is not shared evaluated against 101 binaries in the /bin directory for Linux.
    [Show full text]
  • Csc 453 Linking and Loading
    CSc 453 Linking and Loading Saumya Debray The University of Arizona Tucson Tasks in Executing a Program 1. Compilation and assembly. Translate source program to machine language. The result may still not be suitable for execution, because of unresolved references to external and library routines. 2. Linking. Bring together the binaries of separately compiled modules. Search libraries and resolve external references. 3. Loading. Bring an object program into memory for execution. Allocate memory, initialize environment, maybe fix up addresses. CSc 453: Linking and Loading 2 1 Contents of an Object File Header information Overall information about the file and its contents. Object code and data Relocations (may be omitted in executables) Information to help fix up the object code during linking. Symbol table (optional) Information about symbols defined in this module and symbols to be imported from other modules. Debugging information (optional) CSc 453: Linking and Loading 3 Example: ELF Files (x86/Linux) Linkable sections Executable segments ELF Header Program Header (optional, ignored) describes sections Table sections segments Section Header describes sections (optional, ignored) Table CSc 453: Linking and Loading 4 2 ELF Files: contcont’’’’dddd ELF Header structure 16 bytes ELF file identifying information (magic no., addr size, byte order) 2 bytes object file type (relocatable, executable, shared object, etc.) 2 bytes machine info 4 bytes object file version 4 bytes entry point (address where execution begins) 4 bytes offset of program header table 4 bytes offset of section header table 4 bytes processor-specific flags 2 bytes ELF header size (in bytes) 2 bytes size of each entry in program header table 2 bytes no.
    [Show full text]
  • Dynamic Linking Considered Harmful
    DYNAMIC LINKING CONSIDERED HARMFUL 1 WHY WE NEED LINKING ¡ Want to access code/data defined somewhere else (another file in our project, a library, etc) ¡ In compiler-speak, “we want symbols with external linkage” § I only really care about functions here ¡ Need a mechanism by which we can reference symbols whose location we don’t know ¡ A linker solves this problem. Takes symbols annotated by the compiler (unresolved symbols) and patches them 2 DYNAMIC LINKING ¡ We want to: ¡ use code defined somewhere else, but we don’t want to have to recompile/link when it’s updated ¡ be able to link only those symbols used as runtime (deferred/lazy linking) ¡ be more efficient with resources (may get to this later) 3 CAVEATS ¡ Applies to UNIX, particularly Linux, x86 architecture, ELF Relevant files: -glibcX.X/elf/rtld.c -linux-X.X.X/fs/exec.c, binfmt_elf.c -/usr/include/linux/elf.h ¡ (I think) Windows linking operates similarly 4 THE BIRTH OF A PROCESS 5 THE COMPILER ¡ Compiles your code into a relocatable object file (in the ELF format, which we’ll get to see more of later) ¡ One of the chunks in the .o is a symbol table ¡ This table contains the names of symbols referenced and defined in the file ¡ Unresolved symbols will have relocation entries (in a relocation table) 6 THE LINKER ¡ Patches up the unresolved symbols it can. If we’re linking statically, it has to fix all of them. Otherwise, at runtime ¡ Relocation stage. Will not go into detail here. § Basically, prepares program segments and symbol references for load time 7 THE SHELL fork(), exec() 8 THE KERNEL (LOADER) ¡ Loaders are typically kernel modules.
    [Show full text]
  • Linkers and Loaders Do?
    Linkers & Loaders by John R. Levine Table of Contents 1 Table of Contents Chapter 0: Front Matter ........................................................ 1 Dedication .............................................................................................. 1 Introduction ............................................................................................ 1 Who is this book for? ......................................................................... 2 Chapter summaries ............................................................................. 3 The project ......................................................................................... 4 Acknowledgements ............................................................................ 5 Contact us ........................................................................................... 6 Chapter 1: Linking and Loading ........................................... 7 What do linkers and loaders do? ............................................................ 7 Address binding: a historical perspective .............................................. 7 Linking vs. loading .............................................................................. 10 Tw o-pass linking .............................................................................. 12 Object code libraries ........................................................................ 15 Relocation and code modification .................................................... 17 Compiler Drivers .................................................................................
    [Show full text]
  • Dynamic Libraries
    Dynamic Libraries G. Lettieri 14 July 2020 1 Introduction Static libraries are just a collection of object files. In Linux, an .a is only an archive of .o files created using the ar(1) command, an ancient archive- management tool that only survives today because of its use in static libraries1 During linking, the link editor extracts the object files from the archive as needed and adds them to the list of files that must be linked together. The resulting executable keeps no record of the fact that some objects originally came from a library (except maybe in debugging info, if present). Dynamic libraries try to address some (perceived) shortcomings of static libraries: Objects used in several executables (e.g., those extracted from the C li- brary) are copied several times and waste space on disk and in central memory; when a library must be updated to fix a bug, all executables that were built using the old library must be identified and re-built using the new one. Dynamic libraries solve these problems by having \incomplete" executables that are linked to the libraries at load time. The libraries can now be updated with- out updating the executables. Moreover, the libraries are built and linked in a way that allows multiple processes to share almost all of their contents. 2 The price to pay is slower executable start up times (because of the dynamic linking), slightly slower libraries (because of the way they are compiled) and, above all, great management complexity because of possible incompatibilities between library versions. Some people (like the go developers) think that the price to pay is too high while the advantages are either marginal or non exis- tent (space is not a problem today, and library-version incompatibilities often 1Because of this specialized use, modern GNU ar can also add a symbol index to the archive all by itself.
    [Show full text]
  • Mach-O Programming Topics
    Mach-O Programming Topics Tools > Compiling & Debugging 2006-11-28 subsidiaries in the United States and other Apple Inc. countries. © 2003, 2006 Apple Computer, Inc. Java and all Java-based trademarks are All rights reserved. trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other No part of this publication may be countries. reproduced, stored in a retrieval system, or transmitted, in any form or by any means, PowerPC and and the PowerPC logo are mechanical, electronic, photocopying, trademarks of International Business recording, or otherwise, without prior Machines Corporation, used under license written permission of Apple Inc., with the therefrom. following exceptions: Any person is hereby UNIX is a registered trademark of The Open authorized to store documentation on a Group single computer for personal use only and Simultaneously published in the United to print copies of documentation for States and Canada. personal use provided that the documentation contains Apple’s copyright Even though Apple has reviewed this document, APPLE MAKES NO WARRANTY OR notice. REPRESENTATION, EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THIS The Apple logo is a trademark of Apple Inc. DOCUMENT, ITS QUALITY, ACCURACY, MERCHANTABILITY, OR FITNESS FOR A Use of the “keyboard” Apple logo PARTICULAR PURPOSE. AS A RESULT, THIS (Option-Shift-K) for commercial purposes DOCUMENT IS PROVIDED “AS IS,” AND YOU, THE READER, ARE ASSUMING THE without the prior written consent of Apple ENTIRE RISK AS TO ITS QUALITY AND may constitute trademark infringement and ACCURACY. unfair competition in violation of federal IN NO EVENT WILL APPLE BE LIABLE FOR and state laws.
    [Show full text]
  • 28Library.Pdf
    To speed-up virtual-to-real translation, a special cache is maintained of recent translations — it’s called the translation lookaside buffer (TLB). It resides in the chip, one per core and hyperthread. The TLB shown in the slide is a two-way set associative cache, as discussed in lecture 17. This one assumes a 32-bit virtual address with a 4k page. Things are more complicated when multiple page sizes are supported. For example, is there just one entry for a large page that covers its entire range of addresses, or is a large page dealt with by putting into the cache multiple entries covering the large page, but each for the size of a small page? Both approaches are not only possible, but done. Three issues concerning the mechanism for caching are the following: the fetch policy, which governs when item are fetched to go into the cache, the placement policy, which governs where the fetched items are placed in the cache, and the replacement policy, which governs when and which items are removed from the cache (and perhaps written back to their source). The (kernel) thread that maintains the free page-frame list is typically called the pageout daemon. Its job is to make certain that the free page-frame list has enough page frames on it. If the size of the list drops below some threshold, then the pageout daemon examines those page frames that are being used and selects a number of them to be freed. Before freeing a page, it must make certain that a copy of the current contents of the page exists on secondary storage.
    [Show full text]
  • An Evil Copy: How the Loader Betrays You
    An Evil Copy: How the Loader Betrays You Xinyang Ge Mathias Payer Trent Jaeger Microsoft Research Purdue University The Pennsylvania State University [email protected] [email protected] [email protected] Abstract—Dynamic loading is a core feature used on current the value that is being written. Despite significant investment in systems to (i) enable modularity and reuse, (ii) reduce memory bug finding techniques, memory corruption is still an important footprint by sharing code pages of libraries and executables problem, as 745 individual CVEs for 2015 and 692 CVEs for among processes, and (iii) simplify update procedures by elim- 2016 are reported. While not all these vulnerabilities allow an inating the need to recompile executables when a library is attacker to compromise a system with arbitrary code execution, updated. The Executable and Linkable Format (ELF) is a generic many do. specification that describes how executable programs are stitched together from object files produced from source code to libraries Without any defense, attackers inject and execute code to and executables. Programming languages allow fine-grained con- trol over variables, including access and memory protections, so take control of a system through memory corruption vulner- programmers may write defense mechanisms assuming that the abilities. Over the past decade, a set of defense mechanisms permissions specified at the source and/or compiler level will hold have been deployed on commodity systems. Data execution at runtime. prevention [5] is a common defense that enforces code in- tegrity. Code integrity prohibits an attacker from injecting new Unfortunately, information about memory protection is lost code into a running process and is usually enforced by hard- during compilation.
    [Show full text]
  • Outline Executable/Object File Formats Brief History of Binary File Formats
    Outline CSci 5980/8980 ELF basics Manual and Automated Binary Reverse Engineering Slides 5: The ELF Binary File Format Stephen McCamant Static and dynamic linking University of Minnesota Executable/object file formats Brief history of binary file formats (Unix) Modern systems usually use a common format for Early Unix had a simple a.out format relocatable object files during compilation and final Lasted until early days of free Linux/BSD, now obsolete executables AT&T’s second try was named COFF Mostly binary data representing code and data Still limited, but widely adopted with changes Plus metadata allowing the data to be linked and AT&T’s third try was ELF, now used in almost all Unix loaded systems Brief history of binary file formats (non-Unix) Compile-time and run-time Early DOS and Windows had several limited formats Some file features are used during compilation Since the 32-bit era, Windows uses the PE (Portable Typically first created by assembler, then used/modified Executable) format by the linker Partially derived from COFF Other features are used when the program runs OS X era Apple (including iOS, etc) uses a format By the OS when the program starts named Mach-O And now also by runtime linking First developed for the Mach microkernel used on the NeXT Static and dynamic/shared linking ELF Traditional “static” linking happens all at compile time Executable (or Extensible) and Linking (or Linkable) Libraries become indistinguishable from the rest of the Format program First appeared in System V Release 4 Unix, c. 1989 For efficiency and flexibility, it is now more common to postpone library linking until runtime Linux switched to ELF c.
    [Show full text]
  • Linker and Libraries
    Linker and Libraries 2550 Garcia Avenue Mountain View, CA 94043 U.S.A. A Sun Microsystems, Inc. Business 1994 Sun Microsystems, Inc. 2550 Garcia Avenue, Mountain View, California 94043-1100 U.S.A. All rights reserved. This product and related documentation are protected by copyright and distributed under licenses restricting its use, copying, distribution, and decompilation. No part of this product or related documentation may be reproduced in any form by any means without prior written authorization of Sun and its licensors, if any. Portions of this product may be derived from the UNIX® and Berkeley 4.3 BSD systems, licensed from UNIX System Laboratories, Inc., a wholly owned subsidiary of Novell, Inc., and the University of California, respectively. Third-party font software in this product is protected by copyright and licensed from Sun’s font suppliers. RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the United States Government is subject to the restrictions set forth in DFARS 252.227-7013 (c)(1)(ii) and FAR 52.227-19. The product described in this manual may be protected by one or more U.S. patents, foreign patents, or pending applications. TRADEMARKS Sun, the Sun logo, Sun Microsystems, Sun Microsystems Computer Corporation, Solaris, are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and certain other countries. UNIX and OPEN LOOK are registered trademarks of UNIX System Laboratories, Inc., a wholly owned subsidiary of Novell, Inc. PostScript and Display PostScript are trademarks of Adobe Systems, Inc. All other product names mentioned herein are the trademarks of their respective owners.
    [Show full text]
  • ELF for the ARM 64-Bit Architecture (Aarch64)
    ELF for the ARM 64-bit architecture (AArch64) ELF for the ARM® 64-bit Architecture (AArch64) Document number: ARM IHI 0056B, current through AArch64 ABI release 1.0 Date of Issue: 22nd May 2013 Abstract This document describes the use of the ELF binary file format in the Application Binary Interface (ABI) for the ARM 64-bit architecture. Keywords ELF, AArch64 ELF, ... How to find the latest release of this specification or report a defect in it Please check the ARM Information Center (http://infocenter.arm.com/) for a later release if your copy is more than 3 months old (navigate to the Software Development Tools section, Application Binary Interface for the ARM Architecture subsection). Please report defects in this specification to arm dot eabi at arm dot com. Licence THE TERMS OF YOUR ROYALTY FREE LIMITED LICENCE TO USE THIS ABI SPECIFICATION ARE GIVEN IN SECTION 1.4, Your licence to use this specification (ARM contract reference LEC-ELA-00081 V2.0). PLEASE READ THEM CAREFULLY. BY DOWNLOADING OR OTHERWISE USING THIS SPECIFICATION, YOU AGREE TO BE BOUND BY ALL OF ITS TERMS. IF YOU DO NOT AGREE TO THIS, DO NOT DOWNLOAD OR USE THIS SPECIFICATION. THIS ABI SPECIFICATION IS PROVIDED “AS IS” WITH NO WARRANTIES (SEE SECTION 1.4 FOR DETAILS). Proprietary notice ARM, Thumb, RealView, ARM7TDMI and ARM9TDMI are registered trademarks of ARM Limited. The ARM logo is a trademark of ARM Limited. ARM9, ARM926EJ-S, ARM946E-S, ARM1136J-S ARM1156T2F-S ARM1176JZ-S Cortex, and Neon are trademarks of ARM Limited. All other products or services mentioned herein may be trademarks of their respective owners.
    [Show full text]
  • System V Application Binary Interface X86-64
    System V Application Binary Interface AMD64 Architecture Processor Supplement Draft Version 0.95 Edited by Jan Hubickaˇ 1, Andreas Jaeger2, Mark Mitchell3 January 24, 2005 [email protected] [email protected] [email protected] AMD64 ABI Draft 0.95 – January 24, 2005 – 12:10 Contents 1 Introduction 8 1.1 Differences from the Intel386 ABI . 8 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 . 14 3.2.2 The Stack Frame . 15 3.2.3 Parameter Passing . 16 3.3 Operating System Interface . 23 3.3.1 Exception Interface . 23 3.3.2 Virtual Address Space . 23 3.3.3 Page Size . 23 3.3.4 Virtual Address Assignments . 23 3.4 Process Initialization . 26 3.4.1 Initial Stack and Register State . 26 3.4.2 Auxiliary Vector . 29 3.5 Coding Examples . 31 3.5.1 Architectural Constraints . 32 3.5.2 Conventions . 34 3.5.3 Position-Independent Function Prologue . 35 3.5.4 Data Objects . 35 3.5.5 Function Calls . 44 3.5.6 Branching . 46 1 AMD64 ABI Draft 0.95 – January 24, 2005 – 12:10 3.5.7 Variable Argument Lists . 49 3.6 DWARF Definition . 54 3.6.1 DWARF Release Number . 54 3.6.2 DWARF Register Number Mapping . 54 3.7 Stack Unwind Algorithm . 54 4 Object Files 58 4.1 ELF Header . 58 4.1.1 Machine Information .
    [Show full text]