xoofx / LibObjectFile

LibObjectFile is a .NET library to read, manipulate and write linker and executable object files (e.g ELF, PE, DWARF, ar...)
BSD 2-Clause "Simplified" License
159 stars 11 forks source link
csharp debugging dotnet dwarf elf elf-parser linker pe-file

LibObjectFile ci NuGet

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 ar file 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

Documentation

The doc/readme.md explains how the library is designed and can be used.

Download

LibObjectFile is available as a NuGet package: NuGet

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]

bruno-garcia