# Relocations

Published articles for Relocations.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Adding a new target/object backend to LLVM JITLink

DevFeed: [Adding a new target/object backend to LLVM JITLink](<https://devfeed.tech/articles/adding-a-new-target-object-backend-to-llvm-jitlink-43093.md>)

Original publisher: [Read original article](<https://blog.llvm.org/posts/2023-03-16-adding-new-llvm-jitlink-target-object-backend/>)

Author: Kshitij Jain

Published: 2023-03-28T00:00:00Z

Content type: article

Language: en

Sources: [LLVM Project](<https://devfeed.tech/sources/the-llvm-project-blog.md>)

Topics: [LLVM](<https://devfeed.tech/topics/llvm.md>), [linker](<https://devfeed.tech/topics/linker.md>), [JIT](<https://devfeed.tech/topics/jit.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [C](<https://devfeed.tech/topics/c.md>), [static linking](<https://devfeed.tech/topics/static-linking.md>), [Assembly](<https://devfeed.tech/topics/assembly.md>), [Hardware](<https://devfeed.tech/topics/hardware.md>)

Tags: [c](<https://devfeed.tech/tags/c.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [elf](<https://devfeed.tech/tags/elf.md>), [hardware](<https://devfeed.tech/tags/hardware.md>), [i386](<https://devfeed.tech/tags/i386.md>), [jit](<https://devfeed.tech/tags/jit.md>), [jitlink](<https://devfeed.tech/tags/jitlink.md>), [linker](<https://devfeed.tech/tags/linker.md>), [linking](<https://devfeed.tech/tags/linking.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [relocations](<https://devfeed.tech/tags/relocations.md>), [static-linking](<https://devfeed.tech/tags/static-linking.md>)

### AI overview

This article documents the addition of a new target/object backend to LLVM JITLink. It explains linking fundamentals, contrasts static and just-in-time linking, and describes the goal of linking 32-bit ELF objects with i386 relocations into a 32-bit process.

### Source excerpt

Motivation For the last year, I have been contributing to LLVM JITLink. This post aims todoubly serve as a summary of my work and documentation for future contributors looking to add a new target/objectbackend to LLVM JITLink. We will start by establishing some background and definitions of relevant concepts. Then, we will talk about whatthe project actually entailed. Finally, we will go over the execution details of the project. The end goal of the project was to make LLVM JITLink capable of linking a 32-bit ELF object file, with i386specific relocations, into a 32-bit process on the i386 hardware architecture. If the goal of the project already makes sense to you and you are looking to get started with adding a newtarget/object backend to LLVM JITLink yourself, you can skip to the "Recap and conveniences"section. BackgroundLinking Our code often relies on external dependencies. For example, even a simple hello-world program written in C dependson the C stdlib for the printf function. These external dependencies are expressed as symbolic references, which Iwill henceforth refer to as just symbols. Symbols are names of data or functions that have unknown addresses andare resolved or fixed up during the linking process. In chronological order - The compiler converts source code to machine code. The assembler converts machine code to object files (ELF, MachO, COFF etc.) The linker links one or more object files (fixing up symbolic references along the way) and produces anexecutable or a shared library (also called shared object or dylib). For the purposes of this discussion we will focus on executables, but the points that will be made hold for sharedobjects as well. JIT linking Unlike static linking, JIT (Just-in-time) linking is performed at runtime. While a static linker producesexecutables that are stored on disk, a JIT linker produces an in-memory image of the executable - essentiallyready to execute bytes in memory. JIT linking a C program may feel very much lik