Dynamic Linker and Debugging/Tracing Interface for Helenos

Dynamic Linker and Debugging/Tracing Interface for Helenos

Charles University in Prague Faculty of Mathematics and Physics MASTER THESIS Jiří Svoboda Dynamic linker and debugging/tracing interface for HelenOS Department of Software Engineering Supervisor: Mgr. Martin Děcký Study program: Computer science, Software systems 2 I would like to thank my supervisor Mgr. Martin Děcký for reading through the preliminary versions of this document, for valuable suggestions and for kind words of support. I am also indebted to him for introducing me to HelenOS. I would also like to thank Jakub Jermář for countless hours of discussion, for all his advice, constant encouragement and for persuading me to find better solutions to problems. I also owe him for implementing VFS just in time for me to use it and for conceiving HelenOS in the first place. Last, but certainly not least, I must thank Jakub for being a great friend. Thank you. I hereby declare that I have written this thesis myself, on my own and solely using the cited sources. I give permission to loan this document. Prohlašuji, že jsem svou diplomovou práci napsal samostatně a výhradně s použitím citovaných pramenů. Souhlasím se zapůjčováním práce. V Praze dne 11. 12. 2008 Jiří Svoboda .............. 3 4 Contents Cover Page 1 Contents 8 List of Tables .................................. 9 List of Figures .................................. 9 1 Introduction 11 1.1 Motivation ................................. 11 1.2 Goals .................................... 11 1.3 Getting the Source Code ......................... 12 1.4 How to Read This Document ...................... 13 1.4.1 Organization of This Document ................. 13 1.4.2 Conventions Used in This Document .............. 13 2 HelenOS Overview 15 2.1 History of SPARTAN and HelenOS ................... 15 2.2 Multiprocessing Support ......................... 15 2.2.1 Scheduling ............................. 15 2.2.2 Synchronization .......................... 16 2.3 Memory Management ........................... 17 2.4 User-Space Tasks ............................. 17 2.4.1 Creation of a Task ........................ 17 2.4.2 Creating New Tasks from User Space .............. 18 2.4.3 Identifying Kernel Resources ................... 18 2.5 IPC Subsystem .............................. 18 2.5.1 Low-Level IPC .......................... 18 2.5.2 System-Call IPC Layer ...................... 19 2.5.3 Message Processing ........................ 19 2.5.4 Asynchronous Library ...................... 20 2.5.5 Connections and the Naming Service .............. 21 2.6 Further Reading .............................. 21 2.7 SMC Coherency .............................. 21 2.7.1 Why Self-Modifying Code? .................... 21 2.7.2 Contemporary Memory Architecture .............. 22 2.7.3 Coherency Problems ....................... 22 2.7.4 Instruction Memory Barriers ................... 23 2.7.5 SMC Coherency in HelenOS ................... 23 5 3 Debugging and Tracing Overview 27 3.1 Bugs and Observability .......................... 27 3.1.1 Hunting Bugs ........................... 27 3.1.2 Observability ........................... 27 3.1.3 Impact ............................... 27 3.1.4 Common Debugging Methods .................. 28 3.1.5 Common Techniques ....................... 28 3.1.6 Debugging Software ........................ 29 3.1.7 Data for Post-Mortem Analysis ................. 30 3.1.8 Methods for Static Analysis ................... 30 3.2 Breakpoint Debugging Support in Processors .............. 30 3.3 Network Packet Analysis ......................... 31 4 Debugging and Tracing Design and Implementation 33 4.1 Design Overview ............................. 33 4.2 Supported Architectures ......................... 34 4.3 Udebug Interface ............................. 34 4.3.1 Interface Form .......................... 34 4.3.2 Connecting ............................ 34 4.3.3 Debugging Message Format ................... 35 4.3.4 Debugging Methods ....................... 35 4.3.5 Typical Debugging Session .................... 37 4.3.6 Events ............................... 38 4.4 Udebug Implementation ......................... 39 4.4.1 Implementation Overview .................... 39 4.4.2 Suspending and Resuming Threads ............... 40 4.4.3 Hooks ............................... 43 4.4.4 Task Memory Access ....................... 44 4.4.5 Kbox Thread Benefits ...................... 46 4.4.6 Register State Access ....................... 46 4.4.7 Synchronization and State Management ............ 48 4.5 System Call/IPC Tracer ......................... 51 4.5.1 Overview ............................. 51 4.5.2 End-User Perspective ....................... 51 4.5.3 Under the Hood .......................... 52 4.6 Breakpoint Debugger ........................... 53 4.6.1 Overview ............................. 53 4.6.2 End-User Perspective ....................... 53 4.6.3 Under the Hood .......................... 54 4.7 Future Work ................................ 55 5 Dynamic Linking Overview 57 5.1 Basic Concepts .............................. 57 5.1.1 Separate Compilation ....................... 57 5.1.2 Symbols .............................. 57 5.1.3 Object Files ............................ 58 5.1.4 Sections .............................. 59 5.1.5 Executable Files ......................... 59 5.1.6 Loader ............................... 59 6 5.1.7 Linker ............................... 59 5.1.8 Libraries .............................. 59 5.1.9 Dynamically-Linked Libraries .................. 60 5.1.10 Loading a Library at Run Time ................. 60 5.1.11 ELF and the System V ABI ................... 61 5.1.12 Library ABI and Versioning ................... 61 5.1.13 Thread-Local Storage ....................... 62 5.2 Executable and Linking Format (ELF) ................. 63 5.2.1 Features .............................. 63 5.2.2 File Structure Overview ..................... 63 5.2.3 ELF Header ............................ 63 5.2.4 Sections .............................. 63 5.2.5 Segments ............................. 64 5.2.6 String Table ............................ 64 5.2.7 Symbol Table ........................... 65 5.2.8 Relocation Table ......................... 65 5.3 ELF Dynamic Linking .......................... 65 5.3.1 Base Address ........................... 65 5.3.2 Program Interpreter ....................... 66 5.3.3 Dynamic Section ......................... 66 5.3.4 Shared Library Dependencies .................. 66 5.3.5 Global Offset Table ........................ 67 5.3.6 Procedure Linkage Table ..................... 67 5.3.7 Hash Table ............................ 68 5.3.8 Initialization and Termination Functions ............ 68 5.4 GNU Linker ................................ 69 5.5 ELF Thread-Local Storage ........................ 69 6 Dynamic Linking Design and Implementation 71 6.1 Overview .................................. 71 6.2 Supported Architectures ......................... 71 6.3 Building .................................. 71 6.4 Program Loader .............................. 72 6.4.1 Interim Solution .......................... 72 6.4.2 Cracking the Chicken and Egg Problem ............. 72 6.4.3 Kernel Infrastructure ....................... 74 6.4.4 Entry-Point Interface ....................... 74 6.4.5 Program Control Block ...................... 75 6.4.6 IPC Communication Protocol .................. 75 6.4.7 Library API ............................ 76 6.4.8 Program Loader Implementation ................ 77 6.4.9 SMC Coherency .......................... 77 6.5 Dynamic Linker .............................. 77 6.5.1 The Big Picture .......................... 77 6.5.2 Design Considerations ...................... 78 6.5.3 Source Code Structure ...................... 80 6.5.4 Dynamic Linker Operation in a Nutshell ............ 82 6.5.5 Building the Shared C Library .................. 84 6.5.6 Trying out the Dynamic Linker ................. 85 7 6.5.7 Future Work ............................ 85 7 Related Work 87 7.1 Debugging on UNIX System V ..................... 87 7.2 Debugging on Microsoft Windows .................... 87 7.3 Dynamic Linking on UNIX Systems ................... 88 7.4 Dynamic Linking on Windows ...................... 88 7.5 Debugging on Linux and Solaris ..................... 88 7.6 QNX Neutrino .............................. 89 7.7 OKL4 ................................... 89 7.8 MINIX ................................... 89 7.9 GNU Hurd ................................. 90 8 Conclusion 91 8.1 Achievements ............................... 91 8.2 Contributions ............................... 91 8.3 Perspectives ................................ 91 Bibliography 93 8 List of Tables 4.1 Debugging Request Structure ...................... 35 4.2 Debugging Reply Structure ....................... 35 4.3 Debugging Methods ............................ 36 4.4 Debugging Event Message Structure ................... 38 4.5 Debugger Commands ........................... 54 6.1 Loader Low-Level Library API ...................... 76 6.2 Implemented IA-32 Relocation Types .................. 83 6.3 Implemented PowerPC Relocation Types ................ 83 List of Figures 2.1 IPC Message Processing ......................... 20 4.1 Debugging-Session Management Example ................ 43 4.2 Debugging State Transitions ....................... 49 5.1 Thread-Local Storage Data Structures ................. 70 6.1 Debugging-Session Management Example ................ 73 6.2 Task Address-Space Layout with Loader Present ............ 73 6.3 Task Address-Space Layout with Loader and Linker .........

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    94 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us