Performance Characterization of Prelinking and Preloading for Embedded Systems ∗

Total Page:16

File Type:pdf, Size:1020Kb

Performance Characterization of Prelinking and Preloading for Embedded Systems ∗ Performance Characterization of Prelinking and Preloading for Embedded Systems ∗ Changhee Jung Duk-Kyun Woo Kanghee Kim Embedded Software Research Embedded Software Research Mobile Communication Division Division Division ETRI ETRI Telecommunication Network Daejon, 305-700, Korea Daejon, 305-700, Korea Business [email protected] [email protected] Samsung Electronics Co., LTD. [email protected] Sung-Soo Lim School of Computer Science Kookmin University Seongbuk-gu, Seoul, Korea 136-702 [email protected] ABSTRACT are reduced up to 71% and relocation counts are reduced up Application launching times in embedded systems are more to 91% in the benchmark programs we used. crucial than in general-purpose systems since the response times of embedded applications are significantly affected by Categories and Subject Descriptors the launching times. As general-purpose operating systems D.3.4 [Programming Languages]: Processors—compil- are increasingly used in embedded systems, reducing appli- ers, run-time environment;D.4[Operating Systems]: Or- cation launching times are one of the most influential factors ganization and Design—real-time systems and embedded sys- for performance improvement. In order to reduce the appli- tems cation launching times, three factors should be considered at the same time: relocation time, symbol resolution time, and binary loading time. In this paper, we propose a new ap- General Terms plication execution model using a combination of prelinking Design, Performance and preloading to reduce the relocation, symbol resolution, and binary load overheads at the same time. Such applica- tion execution model is realized using fork and dlopen exe- Keywords cution model instead of traditional fork and exec execution embedded systems, prelinking, preloading, application launch- model. We evaluate the performance effect of the proposed ing fork and dlopen application execution model on a Linux- based embedded system using XScale processor. By apply- ing the proposed application execution model using both 1. INTRODUCTION prelinking and preloading, the application launching times Dynamically linked applications have been increasingly used in embedded systems as general purpose operating sys- ∗ This work was supported in part by the IT R&D program of tems are adopted in embedded systems. As more diverse ap- MIC/IITA [2006-S-038-02, Development of Device-Adaptive plications with significant sizes are installed for such embed- Embedded Operating System for Mobile Convergence Com- ded systems, the portion of dynamically linked applications puting], in part by No. 379 from the Basic Research Pro- increase accordingly. Therefore, the shared library process- gram of KOSEF, and in part by the MIC, Korea under the ITRC (Information Technology Research Center) support ing times including relocation, symbol resolution, and li- program supervised by the IITA (IITA-2006-C1090-0603- brary image loading steps have substantial impact on the 0045). overall application execution performance. For example, in [1], the GNOME startup time analysis results show that the most of the IO operations are due to shared library oper- ations and around 65 % of non-contiguous IOs come from Permission to make digital or hard copies of all or part of this work for library accesses. personal or classroom use is granted without fee provided that copies are Application launching overhead is more crucial in embed- not made or distributed for profit or commercial advantage and that copies ded systems since the hardware performance of the embed- bear this notice and the full citation on the first page. To copy otherwise, to ded systems is not comparable to the performance of general republish, to post on servers or to redistribute to lists, requires prior specific purpose systems. Moreover, the prolonged launching times permission and/or a fee. EMSOFT’07, September 30–October 3, 2007, Salzburg, Austria. could not be accepted in user-interactive consumer electron- Copyright 2007 ACM 978-1-59593-825-1/07/0009 ...$5.00. ics products since the response times of applications would 213 directly affect the values of the products (i.e., the launch- number of issues in application execution performance. Ef- ing time of HTML or WAP browser in mobile phones, the ficient dynamic linking has been discussed and implemented launching time of document viewer in PDAs and phones). in single-address-space operating systems such as Mungi [5, Optimizing such application launching times through effi- 3] and Nemesis [12] and the dynamic linking scheme has cient handling of dynamically linked applications is neces- been used in Iguana project [4] which is a modified version sary in the products. of Mungi and used for commercialized systems. Most of In this paper, we propose an application execution model the issues in dynamic linking in single address space have to reduce the handling cost of dynamically linked applica- been discussed in [5, 3, 12] and those discussions could be tions in launching applications: we perform relocation, sym- well considered in general purpose operating systems. In bol resolution, and shared library binary loading in advance this paper, we aim at devising and evaluating a method for before application execution. The prelinking (i.e., reloca- efficient dynamic linking that could be practically used for tion and symbol resolution before application execution) and general purpose operating systems such as Linux. preloading (i.e., shared library binary loading before execu- Prelinking [8] is an ELF image translation to speed up tion) techniques are combined in an application execution dynamic linking of ELF programs. It tries to remove sym- environment by modification of the existing dynamic linker. bol resolutions of ELF programs by incorporating the simple In order to apply the combined techniques to the exist- philosophy of the a.out binary format into the ELF format ing general purpose OS-based systems, the fork and dlopen without compromising its flexibility. That is, it assigns a model is used for application execution instead of fork and base address to which every shared library in the system exec model. In the fork and dlopen model, the applications should be mapped, and according to the base addresses, are launched as shared objects by an application launcher performs all symbol resolutions at link time. If there exists and the shared libraries needed to execute the applications a case where the base address assigned to a prelinked shared are prelinked and preloaded by the launcher. library is already occupied by another shared library (e.g., The fork and dlopen application execution model with pre- when a non-prelinked library is already loaded to the base linking and preloading naturally gives a number of restric- address), all symbol resolutions performed at link time for tions in launching and running applications. First, as we the prelinked library are cancelled at load time of the li- mentioned above, the applications need to be changed to brary, and the library is handled as a normal non-prelinked shared objects and launched through dlopen. Second, most ELF library; that is, the base address is dynamically de- of the applications in a system need to be covered by pre- termined by the system, and the symbol resolutions occur determined set of shared libraries so that additional shared during the run time of the program. To make an effective library loading would not be needed at run-time. Though use of prelinking, it is important to cover as many shared the factors mentioned above seem to impair the flexibility libraries as possible in system design phase, thus reducing of the system, the consumer electronics embedded systems the possibility of non-prelinked libraries in system operating could well accept the application execution model due to phase. their characteristics. The consumer electronics products On the other hand, fixed-up image caching [11] is an op- such as smartphones, portable media players, and set-top erating system level technique developed in Spring OS to boxes normally have a centralized application launcher who speed up dynamic linking. The basic idea is to maintain a controls the launching and termination of other applications. cached copy of application executables and shared libraries, In addition, the shared libraries used by the applications once the corresponding applications are launched and ter- could be well predetermined since most of the applications minated. If an application has to be launched later, the are fixed from factory configuration and additional applica- cached copy of the associated executable and shared libraries tions would also utilize the already installed shared libraries. is used. In this approach, it is important to assign a unique Moreover, once the products boot and start to run, the prod- base address to each shared library, in order not to main- ucts are rarely rebooted, but typically woken-up from sus- tain multiple copies of a single shared library due to different pended modes. This would hide the launching time of the base addresses. Since the approach requires large memory application launcher itself and preloading times of shared space for image caching, it is not adequate for embedded libraries since these are performed at boot time. Especially systems with no swap. for mobile phones, the system boot is normally accompanied One final resort to completely avoid relocation, symbol by subscriber registration process and thus the prolonged resolutions, and library loading is to come back to static launching time would not affect the user perception. linking. In [2], static linking is revisited as an alternative We implemented the application execution model in a to dynamic linking, which is combined with a notion called Linux-based embedded system with modification of dynamic message digests to reduce the space overhead imposed by linker in GCC. We evaluated the performance improvement static linking in terms of both memory and disk. However, of the fork and dlopen application execution model with the the space overhead of 40% relative to dynamic linking is too previous fork and exec model using a number of benchmark high for general purpose OS-based embedded systems we programs.
Recommended publications
  • 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]
  • Improving Security Through Egalitarian Binary Recompilation
    Improving Security Through Egalitarian Binary Recompilation David Williams-King Submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy under the Executive Committee of the Graduate School of Arts and Sciences COLUMBIA UNIVERSITY 2021 © 2021 David Williams-King All Rights Reserved Abstract Improving Security Through Egalitarian Binary Recompilation David Williams-King In this thesis, we try to bridge the gap between which program transformations are possible at source-level and which are possible at binary-level. While binaries are typically seen as opaque artifacts, our binary recompiler Egalito (ASPLOS 2020) enables users to parse and modify stripped binaries on existing systems. Our technique of binary recompilation is not robust to errors in disassembly, but with an accurate analysis, provides near-zero transformation overhead. We wrote several demonstration security tools with Egalito, including code randomization, control-flow integrity, retpoline insertion, and a fuzzing backend. We also wrote Nibbler (ACSAC 2019, DTRAP 2020), which detects unused code and removes it. Many of these features, including Nibbler, can be combined with other defenses resulting in multiplicatively stronger or more effective hardening. Enabled by our recompiler, an overriding theme of this thesis is our focus on deployable software transformation. Egalito has been tested by collaborators across tens of thousands of Debian programs and libraries. We coined this term egalitarian in the context of binary security. Simply put, an egalitarian analysis or security mechanism is one that can operate on itself (and is usually more deployable as a result). As one demonstration of this idea, we created a strong, deployable defense against code reuse attacks.
    [Show full text]
  • Chapter 1. Origins of Mac OS X
    1 Chapter 1. Origins of Mac OS X "Most ideas come from previous ideas." Alan Curtis Kay The Mac OS X operating system represents a rather successful coming together of paradigms, ideologies, and technologies that have often resisted each other in the past. A good example is the cordial relationship that exists between the command-line and graphical interfaces in Mac OS X. The system is a result of the trials and tribulations of Apple and NeXT, as well as their user and developer communities. Mac OS X exemplifies how a capable system can result from the direct or indirect efforts of corporations, academic and research communities, the Open Source and Free Software movements, and, of course, individuals. Apple has been around since 1976, and many accounts of its history have been told. If the story of Apple as a company is fascinating, so is the technical history of Apple's operating systems. In this chapter,[1] we will trace the history of Mac OS X, discussing several technologies whose confluence eventually led to the modern-day Apple operating system. [1] This book's accompanying web site (www.osxbook.com) provides a more detailed technical history of all of Apple's operating systems. 1 2 2 1 1.1. Apple's Quest for the[2] Operating System [2] Whereas the word "the" is used here to designate prominence and desirability, it is an interesting coincidence that "THE" was the name of a multiprogramming system described by Edsger W. Dijkstra in a 1968 paper. It was March 1988. The Macintosh had been around for four years.
    [Show full text]
  • CIS Ubuntu Linux 18.04 LTS Benchmark
    CIS Ubuntu Linux 18.04 LTS Benchmark v1.0.0 - 08-13-2018 Terms of Use Please see the below link for our current terms of use: https://www.cisecurity.org/cis-securesuite/cis-securesuite-membership-terms-of-use/ 1 | P a g e Table of Contents Terms of Use ........................................................................................................................................................... 1 Overview ............................................................................................................................................................... 12 Intended Audience ........................................................................................................................................ 12 Consensus Guidance ..................................................................................................................................... 13 Typographical Conventions ...................................................................................................................... 14 Scoring Information ..................................................................................................................................... 14 Profile Definitions ......................................................................................................................................... 15 Acknowledgements ...................................................................................................................................... 17 Recommendations ............................................................................................................................................
    [Show full text]
  • Linux Fundamentals Paul Cobbaut Linux Fundamentals Paul Cobbaut
    Linux Fundamentals Paul Cobbaut Linux Fundamentals Paul Cobbaut Publication date 2015-05-24 CEST Abstract This book is meant to be used in an instructor-led training. For self-study, the intent is to read this book next to a working Linux computer so you can immediately do every subject, practicing each command. This book is aimed at novice Linux system administrators (and might be interesting and useful for home users that want to know a bit more about their Linux system). However, this book is not meant as an introduction to Linux desktop applications like text editors, browsers, mail clients, multimedia or office applications. More information and free .pdf available at http://linux-training.be . Feel free to contact the author: • Paul Cobbaut: [email protected], http://www.linkedin.com/in/cobbaut Contributors to the Linux Training project are: • Serge van Ginderachter: [email protected], build scripts and infrastructure setup • Ywein Van den Brande: [email protected], license and legal sections • Hendrik De Vloed: [email protected], buildheader.pl script We'd also like to thank our reviewers: • Wouter Verhelst: [email protected], http://grep.be • Geert Goossens: [email protected], http://www.linkedin.com/in/ geertgoossens • Elie De Brauwer: [email protected], http://www.de-brauwer.be • Christophe Vandeplas: [email protected], http://christophe.vandeplas.com • Bert Desmet: [email protected], http://blog.bdesmet.be • Rich Yonts: [email protected], Copyright 2007-2015 Netsec BVBA, Paul Cobbaut Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
    [Show full text]
  • [Improving System Performance Using Application-Level Hints]
    Improving System Performance using Application-Level Hints Björn Döbel Technische Universität Dresden, Department of Computer Science, Operating Systems Group 8th June 2005 Supervising professor: Prof. Dr. Hermann Härtig Supervisor: Dipl.-Inf. Martin Pohlack Selbständigkeitserklärung Hiermit erkläre ich, die vorliegende Arbeit selbständig verfasst zu haben. Ich habe keine anderen als die im Quellenverzeichnis angegebenen Literaturhilfsmittel verwendet. Dresden, 08.06.2005 Björn Döbel 2 Contents 1 Introduction 5 1.1 State of the art .................................. 6 1.1.1 Monitoring ............................... 7 1.1.2 Resource management ......................... 8 1.1.3 Linux kernel modules ......................... 9 1.1.4 Caches in Linux ............................ 10 1.1.5 Using prefetching to increase application performance ........ 11 1.2 Related work .................................. 14 1.2.1 Transparent Informed Prefetch ..................... 14 1.2.2 Speculative Hinting ........................... 15 1.2.3 Integrating prefetching and caching .................. 16 2 Design 19 2.1 Disk accesses and application startup ...................... 19 2.2 Design goals ................................... 20 2.3 Design decisions ................................ 21 2.3.1 Collecting data ............................. 21 2.3.2 Modifying the Linux kernel ...................... 23 2.3.3 HintMod - the kernel module ...................... 24 2.3.4 HintGen - the hint generator ...................... 25 2.3.5 Application of hints .........................
    [Show full text]
  • CIS Red Hat Enterprise Linux 7 Benchmark
    CIS Red Hat Enterprise Linux 7 Benchmark v2.1.1 - 01-31-2017 This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License. The link to the license terms can be found at https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode To further clarify the Creative Commons license related to CIS Benchmark content, you are authorized to copy and redistribute the content for use by you, within your organization and outside your organization for non-commercial purposes only, provided that (i) appropriate credit is given to CIS, (ii) a link to the license is provided. Additionally, if you remix, transform or build upon the CIS Benchmark(s), you may only distribute the modified materials if they are subject to the same license terms as the original Benchmark license and your derivative will no longer be a CIS Benchmark. Commercial use of CIS Benchmarks is subject to the prior approval of the Center for Internet Security. 1 | P a g e Table of Contents Overview ............................................................................................................................................................... 12 Intended Audience ........................................................................................................................................ 12 Consensus Guidance ..................................................................................................................................... 12 Typographical Conventions .....................................................................................................................
    [Show full text]
  • Reducing Memory Usage at Shard Library Use on Embedded Devices
    Reducing Memory Usage at Shard Library Use on Embedded Devices 2007.02.22 Tetsuji Yamamoto, Matsushita Electric Industrial Co., Ltd. Masashige Mizuyama, Panasonic Mobile Communications Co., Ltd. [translated by Takao Ikoma] Table of Contents Background Analysis Method discussed Lazy Loading (overview, idea, implementation) Results Issues CE Linux Forum Japan Regional Technical Jamboree #13 2007/02/22 Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd. 2 Background(1) In embedded systems such as cellular phones, features of applications have grown up, so more dynamic libraries are getting linked (in some cases, dozens of libraries are linked) dependency among dynamic libraries gets complicated, unnecessary library for the application, or library required only for a specific feature, must be linked CASE1 app libA.so libD.so main(){ funcA(){ funcD(){ funcA(); } } funcB(); funcC(){ } funcD(); } libB.so funcB(){ } For the dependency shown above, lib A, B and D should be linked; but libD.so is not actually used, thus the memory for the library is wasted. CE Linux Forum Japan Regional Technical Jamboree #13 2007/02/22 Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd. 3 Background(2) CASE2: app libA.so libD.so funcA(bool X){ funcD(){ main(){ if(X){ } funcA(FALSE); func D(); funcB(); } else { } func B(); } libB.so funcB(){ } For the structure shown above, funcD() is never called at runtime, but should be linked. → To handle this with dynamic loading (dlopen(), dlsym()), both the application and the libraries should be restructured, which would cost a lot Would like to save this memory overhead for which unused library is loaded. CE Linux Forum Japan Regional Technical Jamboree #13 2007/02/22 Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd.
    [Show full text]
  • Red Hat Enterprise Linux 7 Migration Planning Guide
    Red Hat Enterprise Linux 7 Migration Planning Guide Migrating to Red Hat Enterprise Linux 7 Laura Bailey Red Hat Enterprise Linux 7 Migration Planning Guide Migrating to Red Hat Enterprise Linux 7 Laura Bailey Legal Notice Copyright © 2014 Red Hat, Inc. This document is licensed by Red Hat under the Creative Commons Attribution-ShareAlike 3.0 Unported License. If you distribute this document, or a modified version of it, you must provide attribution to Red Hat, Inc. and provide a link to the original. If the document is modified, all Red Hat trademarks must be removed. 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. Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries. Linux ® is the registered trademark of Linus Torvalds in the United States and other countries. Java ® is a registered trademark of Oracle and/or its affiliates. XFS ® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries. MySQL ® is a registered trademark of MySQL AB in the United States, the European Union and other countries. Node.js ® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project. The OpenStack ® Word Mark and OpenStack Logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission.
    [Show full text]
  • Roberto Agostino Vitillo (LBNL)
    SHARING C++ OBJECTS IN LINUX Roberto Agostino Vitillo (LBNL) 1 EXAMPLE USE CASE Database of objects in shared memory (simplified view...) object object Process A object Process B object Physical Memory Virtual MemoryB VirtualMemory A 2 OBJECT SHARING • Objects can be allocated in shared memory segments (e.g. custom allocators) • Assumptions: ‣ GCC ≥ 3 (Itanium C++ ABI) ‣ Linux ≥ 2.6.12 (Address Space Layout Randomization) ‣ Changing the default visibility of symbols, with visibility pragmas or linker scripts for example, is not considered ‣ Binding references to global symbols to the definition within a shared library (e.g. ld’s -Bsymbolic option) is not considered • Issues: ‣ Static data ‣ Pointers and references ‣ Virtual functions ‣ Virtual inheritance 3 STATIC DATA • Static data members have external linkage; each process has its own copy • Non-const static data members reside in the object file’s .data section: changes are not shared between the processes • Const static members reside in the object’s file .rodata section and their semantic is not altered • Same argument applies to local static variables 4 POINTERS AND REFERENCES • Pointers and references can be shared only when pointing to objects within shared segments that are mapped at the same virtual base address in all processes ‣ allocate needed shared segments before forking ‣ allocate shared segments at the same virtual base address in all processes ‣ use “slow” offset pointers 5 VIRTUAL TABLES • A class that has virtual Virtual Table Layout (Itanium ABI) methods or virtual bases
    [Show full text]
  • Optimize Embedded Linux Boot Time Performance
    Optimize Embedded Linux Boot Time Performance WHITE PAPER TABLE OF CONTENTS Abstract ............................................................................................. 3 What is “Embedded Linux”? ............................................................. 4 What does Embedded Linux offer? .................................................. 4 What is Boot Time? ........................................................................... 5 Boot Sequence .................................................................................. 6 Optimizing Boot Time in an Embedded Linux System ...................... 6 Reducing Kernel Boot Time Thereby Increasing Speed ................... 7 Increasing System Startup Time and Application Speed .................. 8 Reducing the Disk Footprint and RAM Size of the Linux Kernel ....... 9 Reducing Application Size and RAM Usage..................................... 10 Reducing Power Consumption ........................................................ 10 Conclusion ....................................................................................... 11 Reference ........................................................................................ 12 Author Info .................................................................................... 112 ©2014, HCL Technologies. Reproduction Prohibited. This document is protected under Copyright by the Author. All rights reserved. Abstract Almost everyone has heard of Linux. It is open source, and has been much in discussion in the software development
    [Show full text]
  • Dynamic Linking with the ARM Compiler Toolchain Application Note 242
    Dynamic Linking with the ARM Compiler toolchain Application Note 242 Copyright © 2010 ARM. All rights reserved. ARM DAI 0242A (ID011411) Dynamic Linking with the ARM Compiler toolchain Application Note 242 Copyright © 2010 ARM. All rights reserved. Release Information The following changes have been made to this book. Change History Date Issue Confidentiality Change December 2010 A Non-Confidential First release Proprietary Notice Words and logos marked with or are registered trademarks or trademarks of ARM in the EU and other countries, except as otherwise stated below in this proprietary notice. Other brands and names mentioned herein may be the trademarks of their respective owners. Neither the whole nor any part of the information contained in, or the product described in, this document may be adapted or reproduced in any material form except with the prior written permission of the copyright holder. The product described in this document is subject to continuous developments and improvements. All particulars of the product and its use contained in this document are given by ARM in good faith. However, all warranties implied or expressed, including but not limited to implied warranties of merchantability, or fitness for purpose, are excluded. This document is intended only to assist the reader in the use of the product. ARM shall not be liable for any loss or damage arising from the use of any information in this document, or any error or omission in such information, or any incorrect use of the product. Where the term ARM is used it means "ARM or any of its subsidiaries as appropriate".
    [Show full text]