Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xoofx/libobjectfile
LibObjectFile is a .NET library to read, manipulate and write linker and executable object files (e.g ELF, PE, DWARF, ar...)
https://github.com/xoofx/libobjectfile
csharp debugging dotnet dwarf elf elf-parser linker pe-file
Last synced: 8 days ago
JSON representation
LibObjectFile is a .NET library to read, manipulate and write linker and executable object files (e.g ELF, PE, DWARF, ar...)
- Host: GitHub
- URL: https://github.com/xoofx/libobjectfile
- Owner: xoofx
- License: bsd-2-clause
- Created: 2019-11-16T09:45:58.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-15T20:36:58.000Z (29 days ago)
- Last Synced: 2024-10-17T06:17:55.633Z (27 days ago)
- Topics: csharp, debugging, dotnet, dwarf, elf, elf-parser, linker, pe-file
- Language: C#
- Homepage:
- Size: 3.12 MB
- Stars: 156
- Watchers: 8
- Forks: 11
- Open Issues: 9
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: license.txt
Awesome Lists containing this project
README
# LibObjectFile [![ci](https://github.com/xoofx/LibObjectFile/actions/workflows/CI.yml/badge.svg)](https://github.com/xoofx/LibObjectFile/actions/workflows/CI.yml) [![NuGet](https://img.shields.io/nuget/v/LibObjectFile.svg)](https://www.nuget.org/packages/LibObjectFile/)
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
```C#
// 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](doc/readme.md) explains how the library is designed and can be used.
## Download
LibObjectFile is available as a NuGet package: [![NuGet](https://img.shields.io/nuget/v/LibObjectFile.svg)](https://www.nuget.org/packages/LibObjectFile/)
## Build
In order to build LibObjectFile, you need to have installed the [.NET 8 SDK](https://dotnet.microsoft.com/en-us/download).
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](https://github.com/xoofx/LibObjectFile/blob/master/license.txt).
## Author
Alexandre MUTEL aka [xoofx](https://xoofx.github.io)
## Supporters
Supports this project with a monthly donation and help me continue improving it. \[[Become a supporter](https://github.com/sponsors/xoofx)\]
[](https://github.com/bruno-garcia)