LibObjectFile 2.0.0

dotnet add package LibObjectFile --version 2.0.0                
NuGet\Install-Package LibObjectFile -Version 2.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LibObjectFile" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LibObjectFile --version 2.0.0                
#r "nuget: LibObjectFile, 2.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install LibObjectFile as a Cake Addin
#addin nuget:?package=LibObjectFile&version=2.0.0

// Install LibObjectFile as a Cake Tool
#tool nuget:?package=LibObjectFile&version=2.0.0                

LibObjectFile ci NuGet

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

  • Full support of Archive ar file 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.Relocate to relocate the image base of a PE file
    • PEFile.Print to 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 readelf similar 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_abbrev and .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.1 support you will need to use 0.4.0 version

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]

<img src="https://github.com/bruno-garcia.png?size=200" width="64px;" style="border-radius: 50%" alt="bruno-garcia"/>

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 114 10/15/2024
1.1.1 99 10/13/2024
1.1.0 103 10/2/2024
1.0.0 107 10/1/2024
0.6.0 436 12/9/2023
0.5.0 225 10/14/2023
0.4.0 1,222 10/21/2022
0.3.6 702 3/6/2022
0.3.5 943 2/11/2020
0.3.4 531 1/4/2020
0.3.3 459 12/24/2019
0.3.2 502 12/22/2019
0.3.1 485 12/19/2019
0.3.0 497 12/18/2019
0.2.1 485 11/19/2019
0.2.0 475 11/17/2019
0.1.0 488 11/16/2019