Using the GNU Compiler Collection

Total Page:16

File Type:pdf, Size:1020Kb

Using the GNU Compiler Collection Using the GNU Compiler Collection For gcc version 4.4.1 (Sourcery G++ Lite 2010q1-188) Richard M. Stallman and the GCC Developer Community Published by: GNU Press Website: www.gnupress.org a division of the General: [email protected] Free Software Foundation Orders: [email protected] 51 Franklin Street, Fifth Floor Tel 617-542-5942 Boston, MA 02110-1301 USA Fax 617-542-2652 Last printed October 2003 for GCC 3.3.1. Printed copies are available for $45 each. Copyright c 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being \Funding Free Software", the Front-Cover Texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled \GNU Free Documentation License". (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. i Short Contents Introduction ::::::::::::::::::::::::::::::::::::::::::::: 1 1 Programming Languages Supported by GCC ::::::::::::::: 3 2 Language Standards Supported by GCC :::::::::::::::::: 5 3 GCC Command Options ::::::::::::::::::::::::::::::: 9 4 C Implementation-defined behavior ::::::::::::::::::::: 253 5 Extensions to the C Language Family ::::::::::::::::::: 261 6 Extensions to the C++ Language :::::::::::::::::::::: 533 7 GNU Objective-C runtime features ::::::::::::::::::::: 545 8 Binary Compatibility :::::::::::::::::::::::::::::::: 551 9 gcov|a Test Coverage Program ::::::::::::::::::::::: 555 10 Known Causes of Trouble with GCC :::::::::::::::::::: 563 11 Reporting Bugs ::::::::::::::::::::::::::::::::::::: 581 12 How To Get Help with GCC :::::::::::::::::::::::::: 583 13 Contributing to GCC Development ::::::::::::::::::::: 585 Funding Free Software ::::::::::::::::::::::::::::::::::: 587 The GNU Project and GNU/Linux::::::::::::::::::::::::: 589 GNU General Public License :::::::::::::::::::::::::::::: 591 GNU Free Documentation License ::::::::::::::::::::::::: 603 Contributors to GCC :::::::::::::::::::::::::::::::::::: 611 Option Index :::::::::::::::::::::::::::::::::::::::::: 627 Keyword Index ::::::::::::::::::::::::::::::::::::::::: 643 iii Table of Contents Introduction :::::::::::::::::::::::::::::::::::::::: 1 1 Programming Languages Supported by GCC ::::::::::::::::::::::::::::::::::::::::::::::::: 3 2 Language Standards Supported by GCC ::::: 5 2.1 C language::::::::::::::::::::::::::::::::::::::::::::::::::::: 5 2.2 C++ language ::::::::::::::::::::::::::::::::::::::::::::::::: 6 2.3 Objective-C and Objective-C++ languages ::::::::::::::::::::: 7 3 GCC Command Options ::::::::::::::::::::::: 9 3.1 Option Summary::::::::::::::::::::::::::::::::::::::::::::::: 9 3.2 Options Controlling the Kind of Output ::::::::::::::::::::::: 21 3.3 Compiling C++ Programs :::::::::::::::::::::::::::::::::::: 27 3.4 Options Controlling C Dialect ::::::::::::::::::::::::::::::::: 27 3.5 Options Controlling C++ Dialect ::::::::::::::::::::::::::::: 32 3.6 Options Controlling Objective-C and Objective-C++ Dialects :: 40 3.7 Options to Control Diagnostic Messages Formatting ::::::::::: 44 3.8 Options to Request or Suppress Warnings ::::::::::::::::::::: 44 3.9 Options for Debugging Your Program or GCC ::::::::::::::::: 65 3.10 Options That Control Optimization :::::::::::::::::::::::::: 80 3.11 Options Controlling the Preprocessor:::::::::::::::::::::::: 120 3.12 Passing Options to the Assembler ::::::::::::::::::::::::::: 130 3.13 Options for Linking ::::::::::::::::::::::::::::::::::::::::: 131 3.14 Options for Directory Search :::::::::::::::::::::::::::::::: 134 3.15 Specifying subprocesses and the switches to pass to them :::: 136 3.16 Specifying Target Machine and Compiler Version :::::::::::: 143 3.17 Hardware Models and Configurations ::::::::::::::::::::::: 143 3.17.1 ARC Options :::::::::::::::::::::::::::::::::::::::::: 143 3.17.2 ARM Options:::::::::::::::::::::::::::::::::::::::::: 144 3.17.3 AVR Options :::::::::::::::::::::::::::::::::::::::::: 148 3.17.4 Blackfin Options ::::::::::::::::::::::::::::::::::::::: 149 3.17.5 CRIS Options:::::::::::::::::::::::::::::::::::::::::: 152 3.17.6 CRX Options :::::::::::::::::::::::::::::::::::::::::: 154 3.17.7 Darwin Options :::::::::::::::::::::::::::::::::::::::: 154 3.17.8 DEC Alpha Options ::::::::::::::::::::::::::::::::::: 158 3.17.9 DEC Alpha/VMS Options ::::::::::::::::::::::::::::: 162 3.17.10 FR30 Options :::::::::::::::::::::::::::::::::::::::: 162 3.17.11 FRV Options ::::::::::::::::::::::::::::::::::::::::: 163 3.17.12 GNU/Linux Options :::::::::::::::::::::::::::::::::: 166 3.17.13 H8/300 Options::::::::::::::::::::::::::::::::::::::: 167 3.17.14 HPPA Options:::::::::::::::::::::::::::::::::::::::: 167 iv Using the GNU Compiler Collection (GCC) 3.17.15 Intel 386 and AMD x86-64 Options ::::::::::::::::::: 170 3.17.16 IA-64 Options :::::::::::::::::::::::::::::::::::::::: 181 3.17.17 M32C Options :::::::::::::::::::::::::::::::::::::::: 184 3.17.18 M32R/D Options ::::::::::::::::::::::::::::::::::::: 185 3.17.19 M680x0 Options :::::::::::::::::::::::::::::::::::::: 186 3.17.20 M68hc1x Options ::::::::::::::::::::::::::::::::::::: 191 3.17.21 MCore Options ::::::::::::::::::::::::::::::::::::::: 192 3.17.22 MIPS Options :::::::::::::::::::::::::::::::::::::::: 193 3.17.23 MMIX Options ::::::::::::::::::::::::::::::::::::::: 204 3.17.24 MN10300 Options :::::::::::::::::::::::::::::::::::: 205 3.17.25 PDP-11 Options :::::::::::::::::::::::::::::::::::::: 205 3.17.26 picoChip Options ::::::::::::::::::::::::::::::::::::: 206 3.17.27 PowerPC Options::::::::::::::::::::::::::::::::::::: 207 3.17.28 IBM RS/6000 and PowerPC Options :::::::::::::::::: 207 3.17.29 S/390 and zSeries Options :::::::::::::::::::::::::::: 219 3.17.30 Score Options::::::::::::::::::::::::::::::::::::::::: 222 3.17.31 SH Options ::::::::::::::::::::::::::::::::::::::::::: 223 3.17.32 SPARC Options :::::::::::::::::::::::::::::::::::::: 227 3.17.33 SPU Options ::::::::::::::::::::::::::::::::::::::::: 231 3.17.34 Options for System V ::::::::::::::::::::::::::::::::: 232 3.17.35 V850 Options ::::::::::::::::::::::::::::::::::::::::: 232 3.17.36 VAX Options ::::::::::::::::::::::::::::::::::::::::: 233 3.17.37 VxWorks Options ::::::::::::::::::::::::::::::::::::: 234 3.17.38 x86-64 Options ::::::::::::::::::::::::::::::::::::::: 234 3.17.39 i386 and x86-64 Windows Options :::::::::::::::::::: 234 3.17.40 Xstormy16 Options ::::::::::::::::::::::::::::::::::: 235 3.17.41 Xtensa Options ::::::::::::::::::::::::::::::::::::::: 235 3.17.42 zSeries Options ::::::::::::::::::::::::::::::::::::::: 236 3.18 Options for Code Generation Conventions ::::::::::::::::::: 237 3.19 Environment Variables Affecting GCC :::::::::::::::::::::: 245 3.20 Using Precompiled Headers ::::::::::::::::::::::::::::::::: 247 3.21 Running Protoize ::::::::::::::::::::::::::::::::::::::::::: 249 4 C Implementation-defined behavior :::::::: 253 4.1 Translation :::::::::::::::::::::::::::::::::::::::::::::::::: 253 4.2 Environment::::::::::::::::::::::::::::::::::::::::::::::::: 253 4.3 Identifiers:::::::::::::::::::::::::::::::::::::::::::::::::::: 253 4.4 Characters ::::::::::::::::::::::::::::::::::::::::::::::::::: 254 4.5 Integers:::::::::::::::::::::::::::::::::::::::::::::::::::::: 254 4.6 Floating point ::::::::::::::::::::::::::::::::::::::::::::::: 255 4.7 Arrays and pointers :::::::::::::::::::::::::::::::::::::::::: 256 4.8 Hints :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 257 4.9 Structures, unions, enumerations, and bit-fields ::::::::::::::: 257 4.10 Qualifiers ::::::::::::::::::::::::::::::::::::::::::::::::::: 258 4.11 Declarators ::::::::::::::::::::::::::::::::::::::::::::::::: 258 4.12 Statements ::::::::::::::::::::::::::::::::::::::::::::::::: 258 4.13 Preprocessing directives ::::::::::::::::::::::::::::::::::::: 258 4.14 Library functions ::::::::::::::::::::::::::::::::::::::::::: 259 v 4.15 Architecture :::::::::::::::::::::::::::::::::::::::::::::::: 259 4.16 Locale-specific behavior ::::::::::::::::::::::::::::::::::::: 259 5 Extensions to the C Language Family :::::: 261 5.1 Statements and Declarations in Expressions :::::::::::::::::: 261 5.2 Locally Declared Labels :::::::::::::::::::::::::::::::::::::: 262 5.3 Labels as Values ::::::::::::::::::::::::::::::::::::::::::::: 263 5.4 Nested Functions :::::::::::::::::::::::::::::::::::::::::::: 264 5.5 Constructing Function Calls:::::::::::::::::::::::::::::::::: 266 5.6 Referring to a Type with typeof ::::::::::::::::::::::::::::: 268 5.7 Conditionals with Omitted Operands::::::::::::::::::::::::: 269 5.8 Double-Word Integers :::::::::::::::::::::::::::::::::::::::: 270 5.9 Complex Numbers ::::::::::::::::::::::::::::::::::::::::::: 270 5.10 Additional Floating Types :::::::::::::::::::::::::::::::::: 271 5.11 Half-Precision Floating Point ::::::::::::::::::::::::::::::: 271 5.12 Decimal Floating Types::::::::::::::::::::::::::::::::::::: 272 5.13 Hex Floats:::::::::::::::::::::::::::::::::::::::::::::::::: 272 5.14 Fixed-Point Types :::::::::::::::::::::::::::::::::::::::::: 272 5.15 Arrays of Length Zero :::::::::::::::::::::::::::::::::::::: 274
Recommended publications
  • Fujitsu SPARC64™ X+/X Software on Chip Overview for Developers]
    White paper [Fujitsu SPARC64™ X+/X Software on Chip Overview for Developers] White paper Fujitsu SPARC64™ X+/X Software on Chip Overview for Developers Page 1 of 13 www.fujitsu.com/sparc White paper [Fujitsu SPARC64™ X+/X Software on Chip Overview for Developers] Table of Contents Table of Contents 1 Software on Chip Innovative Technology 3 2 SPARC64™ X+/X SIMD Vector Processing 4 2.1 How Oracle Databases take advantage of SPARC64™ X+/X SIMD vector processing 4 2.2 How to use of SPARC64™ X+/X SIMD instructions in user applications 5 2.3 How to check if the system and operating system is capable of SIMD execution? 6 2.4 How to check if SPARC64™ X+/X SIMD instructions indeed have been generated upon compilation of a user source code? 6 2.5 Is SPARC64™ X+/X SIMD implementation compatible with Oracle’s SPARC SIMD? 6 3 SPARC64™ X+/X Decimal Floating Point Processing 8 3.1 How Oracle Databases take advantage of SPARC64™ X+/X Decimal Floating-Point 8 3.2 Decimal Floating-Point processing in user applications 8 4 SPARC64™ X+/X Extended Floating-Point Registers 9 4.1 How Oracle Databases take advantage of SPARC64™ X+/X Decimal Floating-Point 9 5 SPARC64™ X+/X On-Chip Cryptographic Processing Capabilities 10 5.1 How to use the On-Chip Cryptographic Processing Capabilities 10 5.2 How to use the On-Chip Cryptographic Processing Capabilities in user applications 10 6 Conclusions 12 Page 2 of 13 www.fujitsu.com/sparc White paper [Fujitsu SPARC64™ X+/X Software on Chip Overview for Developers] Software on Chip Innovative Technology 1 Software on Chip Innovative Technology Fujitsu brings together innovations in supercomputing, business computing, and mainframe computing in the Fujitsu M10 enterprise server family to help organizations meet their business challenges.
    [Show full text]
  • Glibc and System Calls Documentation Release 1.0
    Glibc and System Calls Documentation Release 1.0 Rishi Agrawal <[email protected]> Dec 28, 2017 Contents 1 Introduction 1 1.1 Acknowledgements...........................................1 2 Basics of a Linux System 3 2.1 Introduction...............................................3 2.2 Programs and Compilation........................................3 2.3 Libraries.................................................7 2.4 System Calls...............................................7 2.5 Kernel.................................................. 10 2.6 Conclusion................................................ 10 2.7 References................................................ 11 3 Working with glibc 13 3.1 Introduction............................................... 13 3.2 Why this chapter............................................. 13 3.3 What is glibc .............................................. 13 3.4 Download and extract glibc ...................................... 14 3.5 Walkthrough glibc ........................................... 14 3.6 Reading some functions of glibc ................................... 17 3.7 Compiling and installing glibc .................................... 18 3.8 Using new glibc ............................................ 21 3.9 Conclusion................................................ 23 4 System Calls On x86_64 from User Space 25 4.1 Setting Up Arguements......................................... 25 4.2 Calling the System Call......................................... 27 4.3 Retrieving the Return Value......................................
    [Show full text]
  • Introduction to Programming in Fortran 77 for Students of Science and Engineering
    Introduction to programming in Fortran 77 for students of Science and Engineering Roman GrÄoger University of Pennsylvania, Department of Materials Science and Engineering 3231 Walnut Street, O±ce #215, Philadelphia, PA 19104 Revision 1.2 (September 27, 2004) 1 Introduction Fortran (FORmula TRANslation) is a programming language designed speci¯cally for scientists and engineers. For the past 30 years Fortran has been used for such projects as the design of bridges and aeroplane structures, it is used for factory automation control, for storm drainage design, analysis of scienti¯c data and so on. Throughout the life of this language, groups of users have written libraries of useful standard Fortran programs. These programs can be borrowed and used by other people who wish to take advantage of the expertise and experience of the authors, in a similar way in which a book is borrowed from a library. Fortran belongs to a class of higher-level programming languages in which the programs are not written directly in the machine code but instead in an arti¯cal, human-readable language. This source code consists of algorithms built using a set of standard constructions, each consisting of a series of commands which de¯ne the elementary operations with your data. In other words, any algorithm is a cookbook which speci¯es input ingredients, operations with them and with other data and ¯nally returns one or more results, depending on the function of this algorithm. Any source code has to be compiled in order to obtain an executable code which can be run on your computer.
    [Show full text]
  • Writing Fast Fortran Routines for Python
    Writing fast Fortran routines for Python Table of contents Table of contents ............................................................................................................................ 1 Overview ......................................................................................................................................... 2 Installation ...................................................................................................................................... 2 Basic Fortran programming ............................................................................................................ 3 A Fortran case study ....................................................................................................................... 8 Maximizing computational efficiency in Fortran code ................................................................. 12 Multiple functions in each Fortran file ......................................................................................... 14 Compiling and debugging ............................................................................................................ 15 Preparing code for f2py ................................................................................................................ 16 Running f2py ................................................................................................................................. 17 Help with f2py ..............................................................................................................................
    [Show full text]
  • Red Hat Enterprise Linux 6 Developer Guide
    Red Hat Enterprise Linux 6 Developer Guide An introduction to application development tools in Red Hat Enterprise Linux 6 Dave Brolley William Cohen Roland Grunberg Aldy Hernandez Karsten Hopp Jakub Jelinek Developer Guide Jeff Johnston Benjamin Kosnik Aleksander Kurtakov Chris Moller Phil Muldoon Andrew Overholt Charley Wang Kent Sebastian Red Hat Enterprise Linux 6 Developer Guide An introduction to application development tools in Red Hat Enterprise Linux 6 Edition 0 Author Dave Brolley [email protected] Author William Cohen [email protected] Author Roland Grunberg [email protected] Author Aldy Hernandez [email protected] Author Karsten Hopp [email protected] Author Jakub Jelinek [email protected] Author Jeff Johnston [email protected] Author Benjamin Kosnik [email protected] Author Aleksander Kurtakov [email protected] Author Chris Moller [email protected] Author Phil Muldoon [email protected] Author Andrew Overholt [email protected] Author Charley Wang [email protected] Author Kent Sebastian [email protected] Editor Don Domingo [email protected] Editor Jacquelynn East [email protected] Copyright © 2010 Red Hat, Inc. and others. The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
    [Show full text]
  • Using the GNU Compiler Collection (GCC)
    Using the GNU Compiler Collection (GCC) Using the GNU Compiler Collection by Richard M. Stallman and the GCC Developer Community Last updated 23 May 2004 for GCC 3.4.6 For GCC Version 3.4.6 Published by: GNU Press Website: www.gnupress.org a division of the General: [email protected] Free Software Foundation Orders: [email protected] 59 Temple Place Suite 330 Tel 617-542-5942 Boston, MA 02111-1307 USA Fax 617-542-2652 Last printed October 2003 for GCC 3.3.1. Printed copies are available for $45 each. Copyright c 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being \GNU General Public License" and \Funding Free Software", the Front-Cover texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled \GNU Free Documentation License". (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. i Short Contents Introduction ...................................... 1 1 Programming Languages Supported by GCC ............ 3 2 Language Standards Supported by GCC ............... 5 3 GCC Command Options .........................
    [Show full text]
  • Chapter 2 DIRECT METHODS—PART II
    Chapter 2 DIRECT METHODS—PART II If we use finite precision arithmetic, the results obtained by the use of direct methods are contaminated with roundoff error, which is not always negligible. 2.1 Finite Precision Computation 2.2 Residual vs. Error 2.3 Pivoting 2.4 Scaling 2.5 Iterative Improvement 2.1 Finite Precision Computation 2.1.1 Floating-point numbers decimal floating-point numbers The essence of floating-point numbers is best illustrated by an example, such as that of a 3-digit floating-point calculator which accepts numbers like the following: 123. 50.4 −0.62 −0.02 7.00 Any such number can be expressed as e ±d1.d2d3 × 10 where e ∈{0, 1, 2}. (2.1) Here 40 t := precision = 3, [L : U] := exponent range = [0 : 2]. The exponent range is rather limited. If the calculator display accommodates scientific notation, e g., 3.46 3 −1.56 −3 then we might use [L : U]=[−9 : 9]. Some numbers have multiple representations in form (2.1), e.g., 2.00 × 101 =0.20 × 102. Hence, there is a normalization: • choose smallest possible exponent, • choose + sign for zero, e.g., 0.52 × 102 → 5.20 × 101, 0.08 × 10−8 → 0.80 × 10−9, −0.00 × 100 → 0.00 × 10−9. −9 Nonzero numbers of form ±0.d2d3 × 10 are denormalized. But for large-scale scientific computation base 2 is preferred. binary floating-point numbers This is an important matter because numbers like 0.2 do not have finite representations in base 2: 0.2=(0.001100110011 ···)2.
    [Show full text]
  • Ethereal Developer's Guide Draft 0.0.2 (15684) for Ethereal 0.10.11
    Ethereal Developer's Guide Draft 0.0.2 (15684) for Ethereal 0.10.11 Ulf Lamping, Ethereal Developer's Guide: Draft 0.0.2 (15684) for Ethere- al 0.10.11 by Ulf Lamping Copyright © 2004-2005 Ulf Lamping Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation. All logos and trademarks in this document are property of their respective owner. Table of Contents Preface .............................................................................................................................. vii 1. Foreword ............................................................................................................... vii 2. Who should read this document? ............................................................................... viii 3. Acknowledgements ................................................................................................... ix 4. About this document .................................................................................................. x 5. Where to get the latest copy of this document? ............................................................... xi 6. Providing feedback about this document ...................................................................... xii I. Ethereal Build Environment ................................................................................................14 1. Introduction .............................................................................................................15
    [Show full text]
  • Latest X64dbg Version Supports Non-English Languges Through a Generic Algorithm That May Or May Not Work Well in Your Language
    x64dbg Documentation Release 0.1 x64dbg Jul 05, 2021 Contents 1 Suggested reads 1 1.1 What is x64dbg?.............................................1 1.2 Introduction...............................................1 1.3 GUI manual............................................... 15 1.4 Commands................................................ 31 1.5 Developers................................................ 125 1.6 Licenses................................................. 261 2 Indices and tables 277 i ii CHAPTER 1 Suggested reads If you came here because someone told you to read the manual, start by reading all sections of the introduction. Contents: 1.1 What is x64dbg? This is a x64/x32 debugger that is currently in active development. The debugger (currently) has three parts: • DBG • GUI • Bridge DBG is the debugging part of the debugger. It handles debugging (using TitanEngine) and will provide data for the GUI. GUI is the graphical part of the debugger. It is built on top of Qt and it provides the user interaction. Bridge is the communication library for the DBG and GUI part (and maybe in the future more parts). The bridge can be used to work on new features, without having to update the code of the other parts. 1.2 Introduction This section explains the basics of x64dbg. Make sure to fully read this! Contents: 1 x64dbg Documentation, Release 0.1 1.2.1 Features This program is currently under active development. It supports many basic and advanced features to ease debugging on Windows. Basic features • Full-featured debugging of DLL and EXE files (TitanEngine Community Edition) • 32-bit and 64-bit Windows support from Windows XP to Windows 10 • Built-in assembler (XEDParse/Keystone/asmjit) • Fast disassembler (Zydis) • C-like expression parser • Logging • Notes • Memory map view • Modules and symbols view • Source code view • Thread view • Content-sensitive register view • Call stack view • SEH view • Handles, privileges and TCP connections enumeration.
    [Show full text]
  • Memory Tagging and How It Improves C/C++ Memory Safety Kostya Serebryany, Evgenii Stepanov, Aleksey Shlyapnikov, Vlad Tsyrklevich, Dmitry Vyukov Google February 2018
    Memory Tagging and how it improves C/C++ memory safety Kostya Serebryany, Evgenii Stepanov, Aleksey Shlyapnikov, Vlad Tsyrklevich, Dmitry Vyukov Google February 2018 Introduction 2 Memory Safety in C/C++ 2 AddressSanitizer 2 Memory Tagging 3 SPARC ADI 4 AArch64 HWASAN 4 Compiler And Run-time Support 5 Overhead 5 RAM 5 CPU 6 Code Size 8 Usage Modes 8 Testing 9 Always-on Bug Detection In Production 9 Sampling In Production 10 Security Hardening 11 Strengths 11 Weaknesses 12 Legacy Code 12 Kernel 12 Uninitialized Memory 13 Possible Improvements 13 Precision Of Buffer Overflow Detection 13 Probability Of Bug Detection 14 Conclusion 14 Introduction Memory safety in C and C++ remains largely unresolved. A technique usually called “memory tagging” may dramatically improve the situation if implemented in hardware with reasonable overhead. This paper describes two existing implementations of memory tagging: one is the full hardware implementation in SPARC; the other is a partially hardware-assisted compiler-based tool for AArch64. We describe the basic idea, evaluate the two implementations, and explain how they improve memory safety. This paper is intended to initiate a wider discussion of memory tagging and to motivate the CPU and OS vendors to add support for it in the near future. Memory Safety in C/C++ C and C++ are well known for their performance and flexibility, but perhaps even more for their extreme memory unsafety. This year we are celebrating the 30th anniversary of the Morris Worm, one of the first known exploitations of a memory safety bug, and the problem is still not solved.
    [Show full text]
  • Statically Detecting Likely Buffer Overflow Vulnerabilities
    Statically Detecting Likely Buffer Overflow Vulnerabilities David Larochelle [email protected] University of Virginia, Department of Computer Science David Evans [email protected] University of Virginia, Department of Computer Science Abstract Buffer overflow attacks may be today’s single most important security threat. This paper presents a new approach to mitigating buffer overflow vulnerabilities by detecting likely vulnerabilities through an analysis of the program source code. Our approach exploits information provided in semantic comments and uses lightweight and efficient static analyses. This paper describes an implementation of our approach that extends the LCLint annotation-assisted static checking tool. Our tool is as fast as a compiler and nearly as easy to use. We present experience using our approach to detect buffer overflow vulnerabilities in two security-sensitive programs. 1. Introduction ed a prototype tool that does this by extending LCLint [Evans96]. Our work differs from other work on static detection of buffer overflows in three key ways: (1) we Buffer overflow attacks are an important and persistent exploit semantic comments added to source code to security problem. Buffer overflows account for enable local checking of interprocedural properties; (2) approximately half of all security vulnerabilities we focus on lightweight static checking techniques that [CWPBW00, WFBA00]. Richard Pethia of CERT have good performance and scalability characteristics, identified buffer overflow attacks as the single most im- but sacrifice soundness and completeness; and (3) we portant security problem at a recent software introduce loop heuristics, a simple approach for engineering conference [Pethia00]; Brian Snow of the efficiently analyzing many loops found in typical NSA predicted that buffer overflow attacks would still programs.
    [Show full text]
  • Toolchains Instructor: Prabal Dutta Date: October 2, 2012
    EECS 373: Design of Microprocessor-Based Systems Fall 2012 Lecture 3: Toolchains Instructor: Prabal Dutta Date: October 2, 2012 Note: Unless otherwise specified, these notes assume: (i) an ARM Cortex-M3 processor operating in little endian mode; (ii) the ARM EABI application binary interface; and (iii) the GNU GCC toolchain. Toolchains A complete software toolchain includes programs to convert source code into binary machine code, link together separately assembled/compiled code modules, disassemble the binaries, and convert their formats. Binary program file (.bin) Assembly Object Executable files (.s) files (.o) image file objcopy ld (linker) as objdump (assembler) Memory layout Disassembled Linker code (.lst) script (.ld) Figure 0.1: Assembler Toolchain. A typical GNU (GNU's Not Unix) assembler toolchain includes several programs that interact as shown in Figure 0.1 and perform the following functions: • as is the assembler and it converts human-readable assembly language programs into binary machine language code. It typically takes as input .s assembly files and outputs .o object files. • ld is the linker and it is used to combine multiple object files by resolving their external symbol references and relocating their data sections, and outputting a single executable file. It typically takes as input .o object files and .ld linker scripts and outputs .out executable files. • objcopy is a translation utility that copies and converts the contents of an object file from one format (e.g. .out) another (e.g. .bin). • objdump is a disassembler but it can also display various other information about object files. It is often used to disassemble binary files (e.g.
    [Show full text]