LibObjectFile is a .NET library to read, manipulate and write linker and executable object files (e.g ELF, ar, DWARF, COFF...)
$ dotnet add package LibObjectFile
LibObjectFile is a .NET library to read, manipulate and write linker and executable object files (e.g ELF, ar, DWARF, COFF...)
NOTE: Currently LibObjectFile supports only the following file format:
- 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! ;)
// Reads an ELF file
using var inStream = File.OpenRead("helloworld");
var elf = ElfObjectFile.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 ElfObjectFile to another file on the disk
using var outStream = File.OpenWrite("helloworld2");
elf.Write(outStream);
ar file format including Common, GNU and BSD variants.System.IO.StreamElfCustomSectionreadelf similar output.debug_info, .debug_line, .debug_aranges, .debug_abbrev and .debug_strnet7.0
netstandard2.1 support you will need to use 0.4.0 versionThe doc/readme.md explains how the library is designed and can be used.
PR Welcome if you are willing to contribute to one of these issues:
There are still a few missing implementation of ElfSection for completeness:
SHT_DYNAMIC)SHT_VERSYM)SHT_VERNEED)These sections are currently loaded as ElfCustomSection but should have their own ElfXXXTable (e.g ElfDynamicLinkingTable, ElfVersionSymbolTable...)
.debug_types, .debug_frame, .debug_loc, .debug_ranges, .debug_pubnames, .debug_pubtypes, .debug_macinfo sectionIn a future version I would like to implement the following file format:
In order to build LibObjectFile, you need to have installed the .NET Core 3.0 SDK.
Running the tests require Ubuntu 18.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.
This software is released under the BSD-Clause 2 license.
Alexandre MUTEL aka xoofx
Supports this project with a monthly donation and help me continue improving it. [Become a supporter]