This is a study project implementing a basic ELF linker in Julia for educational purposes. The project aims to understand how dynamic linking works by building a simplified version of an ELF linker with comprehensive mathematical documentation.
Note: This project is AI-driven and developed for learning purposes. We are unable to accept pull requests at this time.
This linker is documented using Mathematical-Driven AI Development methodology with humble, appropriate mathematical notations:
- Complete Mathematical Specification - Comprehensive mathematical framework
- Mathematical-Driven Development Guide - Documentation structure and methodology
This is a mathematically-documented implementation of an ELF (Executable and Linkable Format) linker written in Julia. It demonstrates:
Algorithmic Components (Mathematical Expression):
- ELF parsing algorithms with mathematical transformations:
$\Pi_{parse}: \text{BinaryFile} \to \mathcal{E}_{structured}$ - Symbol resolution using set theory: $\delta_{resolve}: \mathcal{S}{undefined} \times \mathcal{S}{global} \to (\mathcal{S}{resolved}, \mathcal{S}{unresolved})$
- Memory allocation with spatial mathematics: $\phi_{allocate}: \mathcal{S}{sections} \to \mathcal{M}{regions}$
- Relocation processing with address computation: $\rho_{relocate}: \mathcal{R}{entries} \to \mathcal{M}{patched}$
Structural Components (Direct Julia):
- Command-line interface with LLD/GCC compatibility
- File I/O and system interactions
- Configuration and error handling
- Library support and system integration
Complete Linking Pipeline:
- Clone the repository:
git clone https://github.com/nyanrus/mini-elf-linker-jl.git
cd mini-elf-linker-jl
- Install Julia dependencies:
julia --project=.
- In the Julia REPL:
using Pkg
Pkg.instantiate()
using MiniElfLinker
- Run tests to verify everything works:
julia --project=. test/runtests.jl
The linker provides a command-line interface with the following options:
USAGE:
mini-elf-linker [OPTIONS] <input-files>...
OPTIONS:
-o, --output <file> Write output to <file>
-L <dir> Add directory to library search path
-l <lib> Link against library <lib>
-e, --entry <symbol> Set entry point symbol (default: main)
--Ttext <addr> Set text segment base address (hex)
-shared Create shared library
-static Force static linking, disable system libraries
--no-system-libs Disable automatic system library linking
-v, --verbose Verbose output
-h, --help Show this help message
--version Show version information
EXAMPLES:
mini-elf-linker file.o # Link single object
mini-elf-linker -o program file.o # Specify output name
mini-elf-linker -lm -lpthread file.o # Link with math and pthread
mini-elf-linker -L/opt/lib -lmath file.o # Custom library path
mini-elf-linker --entry start file.o # Custom entry point
mini-elf-linker --Ttext 0x800000 file.o # Custom base address
You can also use the linker programmatically in Julia:
using MiniElfLinker
# Link object files to create an executable
link_to_executable(["main.o"], "my_program")
# Link multiple objects with custom settings
link_to_executable(["file1.o", "file2.o"], "program",
base_address=0x400000,
entry_symbol="main")
This repository includes an AI Playground directory (ai-playground/
) containing AI-generated test files, experimental scripts, and development iterations. This space allows for:
- AI-assisted development experiments
- Testing new features and approaches
- Learning from previous development iterations
- Safe experimentation without cluttering the main repository
All files in the AI playground (except the README) are gitignored, making it a perfect space for AI development work while keeping the main project structure clean and focused.
Have a nice day!