3. Adding a New Backend to ELD
3.1. Overview
ELD is a modular linker framework supporting multiple target architectures. The Template backend (eld/lib/Target/Template) is a minimal reference implementation you can copy and adapt for new architectures.
A complete ELD backend consists of three main components:
Backend - Core linking logic (relocations, GOT/PLT, symbol resolution)
Driver - Command-line interface and option parsing (optional)
Wrapper - Plugin API for extending the linker (optional)
This guide focuses on the backend implementation. The driver and wrapper are optional for basic functionality.
3.2. Quick Start
Copy the Template backend directory to your new target name
Rename all
Template*files and classes to your target nameImplement the key methods in each component
Register your backend in the target registry
(Optional) Create a driver for command-line support
(Optional) Implement wrapper hooks for plugin support
3.3. Template Backend Structure
The Template backend contains the minimum necessary hooks:
Template/
├── TemplateInfo.h/cpp # Target machine type and flags
├── TemplateLDBackend.h/cpp # Core linker backend
├── TemplateRelocator.h/cpp # Relocation processing
├── TemplateGOT.h/cpp # Global Offset Table
├── TemplatePLT.h/cpp # Procedure Linkage Table
├── TemplateELFDynamic.h/cpp # Dynamic section
├── TemplateRelocationInfo.h # Relocation type definitions
├── TemplateRelocationFunctions.h # Relocation helpers
├── TemplateRelocationCompute.cpp # Relocation implementations
└── TargetInfo/TemplateTargetInfo.cpp # Target registration
3.4. Available Hooks
The Template backend implements the minimum necessary hooks. Additional hooks are available in base classes:
eld/Target/GNULDBackend.h- Backend base classeld/Target/Relocator.h- Relocator base classeld/Target/TargetInfo.h- Target info base classeld/Fragment/GOT.h- GOT base classeld/Fragment/PLT.h- PLT base classeld/Target/ELFDynamic.h- Dynamic section base class
Refer to these headers for advanced functionality.
3.5. References
Your target’s ABI specification
Template backend:
eld/lib/Target/Template/Driver:
eld/include/eld/Driver/Wrapper:
eld/lib/LinkerWrapper/