Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learn LLVM 12

You're reading from   Learn LLVM 12 A beginner's guide to learning LLVM compiler tools and core libraries with C++

Arrow left icon
Product type Paperback
Published in May 2021
Publisher Packt
ISBN-13 9781839213502
Length 392 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Kai Nacke Kai Nacke
Author Profile Icon Kai Nacke
Kai Nacke
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Section 1 – The Basics of Compiler Construction with LLVM
2. Chapter 1: Installing LLVM FREE CHAPTER 3. Chapter 2: Touring the LLVM Source 4. Chapter 3: The Structure of a Compiler 5. Section 2 – From Source to Machine Code Generation
6. Chapter 4: Turning the Source File into an Abstract Syntax Tree 7. Chapter 5: Basics of IR Code Generation 8. Chapter 6: IR Generation for High-Level Language Constructs 9. Chapter 7: Advanced IR Generation 10. Chapter 8: Optimizing IR 11. Section 3 –Taking LLVM to the Next Level
12. Chapter 9: Instruction Selection 13. Chapter 10: JIT Compilation 14. Chapter 11: Debugging Using LLVM Tools 15. Chapter 12: Create Your Own Backend 16. Other Books You May Enjoy

Extending the ELF file format definition in LLVM

The ELF file format is one of the binary object file formats that LLVM has support for to read and write. ELF itself is defined for many CPU architectures, and there is also a definition for the M88k architecture. All we need to do is to add the definition of the relocations and some flags. The relocations are given in Chapter 4, Object Files, of the System V ABI M88k Processor supplement book:

  1. We need to type the following into the llvm/include/llvm/BinaryFormat/ELFRelocs/M88k.def file:
    #ifndef ELF_RELOC
    #error "ELF_RELOC must be defined"
    #endif
    ELF_RELOC(R_88K_NONE, 0)
    ELF_RELOC(R_88K_COPY, 1)
    // Many more…
  2. We also add some flags to the llvm/include/llvm/BinaryFormat/ELF.h file and include the relocation definitions:
    // M88k Specific e_flags
    enum : unsigned {
      EF_88K_NABI = 0x80000000,   // Not ABI compliant
      EF_88K_M88110 = 0x00000004  // File uses 88110-
    &...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime