LibObjectFile
LibObjectFile is a .NET library to read, manipulate and write linker and executable object files (e.g ELF, PE, DWARF, ar...)
Install / Use
/learn @xoofx/LibObjectFileREADME
LibObjectFile

<img align="right" width="200px" height="200px" src="https://raw.githubusercontent.com/xoofx/LibObjectFile/master/img/libobjectfile.png">
LibObjectFile is a .NET library to read, manipulate and write linker and executable object files (e.g ELF, ar, DWARF, PE...)
NOTE: Currently LibObjectFile supports the following file format:
- PE image file format (Portable Executable / DLL)
- ELF object-file format
- DWARF debugging format (version 4)
- Archive
arfile format (Common, GNU and BSD variants)There is a longer term plan to support other file formats (e.g COFF, MACH-O, .lib) but as I don't have a need for them right now, it is left as an exercise for PR contributors! ;)
Usage
// Reads an ELF file
using var inStream = File.OpenRead("helloworld");
var elf = ElfFile.Read(inStream);
foreach(var section in elf.Sections)
{
Console.WriteLine(section.Name);
}
// Print the content of the ELF as readelf output
elf.Print(Console.Out);
// Write the ElfFile to another file on the disk
using var outStream = File.OpenWrite("helloworld2");
elf.Write(outStream);
Features
- Full support of Archive
arfile format including Common, GNU and BSD variants. - Full support for the PE file format
- Support byte-to-byte roundtrip
- Read and write from/to a
System.IO.Stream - All PE Directories are supported
PEFile.Relocateto relocate the image base of a PE filePEFile.Printto print the content of a PE file to a textual representation- Support for calculating the checksum of a PE file
- Good support for the ELF file format:
- Support byte-to-byte roundtrip
- Read and write from/to a
System.IO.Stream - Handling of LSB/MSB
- Support the following sections:
- String Table
- Symbol Table
- Relocation Table: supported I386, X86_64, ARM and AARCH64 relocations (others can be exposed by adding some mappings)
- Note Table
- Other sections fallback to
ElfCustomSection
- Program headers with or without sections
- Print with
readelfsimilar output
- Support for DWARF debugging format:
- Partial support of Version 4 (currently still the default for GCC)
- Support for the sections:
.debug_info,.debug_line,.debug_aranges,.debug_abbrevand.debug_str - Support for Dwarf expressions
- High level interface, automatic layout/offsets between sections.
- Integration with ELF to support easy reading/writing back
- Support for relocatable sections
- Use of a Diagnostics API to validate file format (on read/before write)
- Library requiring
net8.0- If you are looking for
netstandard2.1support you will need to use0.4.0version
- If you are looking for
Documentation
The doc/readme.md explains how the library is designed and can be used.
Download
LibObjectFile is available as a NuGet package:
Build
In order to build LibObjectFile, you need to have installed the .NET 8 SDK.
Running the tests require Ubuntu 22.04. dotnet test will work on Windows (via WSL) and on that version of Ubuntu.
If you're using macOS or another Linux, there's a Dockerfile and a helper script under src to run tests in the right OS version.
License
This software is released under the BSD-Clause 2 license.
Author
Alexandre MUTEL aka xoofx
Supporters
Supports this project with a monthly donation and help me continue improving it. [Become a supporter]
Related Skills
node-connect
346.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
