39 Commits

Author SHA1 Message Date
9f36ba0ffa Fix builds in no_std environments 2023-07-19 17:50:05 +03:00
1436aab797 Add no-std ElfStream support 2023-07-19 17:13:56 +03:00
Christopher Cole
c2799a1d75
Bump crate version to 0.7.2
New Features:
* Implement core::error::Error for ParsingError accessible via a new non-default "nightly" cargo feature
* Add abi constants for note descriptor types (n_type)
* Add C-style struct definitions for various abi structs (Elf[32|64]_Ehdr etc). These aren't used by the parser, but are useful definitions for folks wanting to manually muck with elf bytes.

Bug Fixes:
* Fix an 'attempt to shift right with overflow' panic in the GnuHashTable if nshift is wider than the bloom filter word size

Misc Improvements:
* Add doc comments for EM_* abi constants
* Tweak formatting and update language for various doc comments
2023-02-15 15:39:24 -08:00
Christopher Cole
b1883750b1
Add comment explaining what the nightly cargo feature provides 2023-01-21 12:01:38 -08:00
jlxip
bddf58a950
Implement core::error::Error for ParsingError 2023-01-11 02:57:24 +01:00
Christopher Cole
da1e25f338
Bump crate version to v0.7.1
Bug Fixes:
* Fix a divide by zero panic in GnuHashTable.find() for tables with nbloom = 0
2023-01-08 14:28:58 -08:00
Christopher Cole
9f552d85f1
Bump crate version to v0.7.0
New Features:
* Add new ElfBytes type with better ergonomics for parsing from a &[u8]
* Add GnuHashTable which interprets the contents of a SHT_GNU_HASH section
* Add convenience method section_header_by_name to ElfBytes and ElfStream
* Add GnuBuildIdNote and parsing for NT_GNU_BUILD_ID note contents
* Add GnuAbiTagNote and parsing for NT_GNU_ABI_TAG note contents
* Add ElfBytes::symbol_version_table() to get the GNU extension symbol version table.
* Add ElfBytes::find_common_data() to efficiently discover common ELF structures
* Add a new endian-aware integer parsing trait impl
* Add ParsingTable.is_empty()
* Add abi constants for powerpc and powerpc64
* Add abi constants for RISC-V
* Add abi constants for x86_64
* Add abi constants for ARM32 and ARM64 (AARCH64)
* Add abi constant for GNU-extension ELF note name ELF_NOTE_GNU
* Add abi constant for PT_GNU_PROPERTY
* Add abi constants for SHN_ABS and SHN_COMMON
* Add elf::to_str::d_tag_to_str()
* Add elf::to_str::note_abi_tag_os_to_str()

Changed Interfaces:
* Rename elf::File -> elf::ElfStream and make it specific to the Read + Seek interface
* Rename gabi -> abi since it also includes extension constants
* Make ELF structures generic across the new endian-aware integer parsing trait EndianParse
* Refactor parsed Note type to be a typed enum
* Rename ElfStream::dynamic_section() -> dynamic() to match ElfBytes
* Change ElfStream::dynamic() to yield a DynamicTable just like in ElfBytes
* Standardize ElfBytes' interfaces for the .dynamic contents to return a DynamicTable
* Export the parsing utilities ParsingTable, ParsingIterator in the public interface
* Refactor section_headers_with_strtab to work with files that have shdrs but no shstrtab
* Remove redundant hash arg from SysVHashTable.find()
* Expose Class in the public interface alongside FileHeader
* Remove opinionated Display impl for file::Class
* Remove section_data_as_symbol_table() from public ElfBytes interface
* Change SymbolVersionTable::new() to take Options instead of Default-empty iterators
* Change ElfStream to parse out the ProgramHeaders into an allocated vec as part of ElfStream::open_stream()
* Change ElfStream to parse out the SectionHeaders into an allocated Vec as part of ElfStream::open_stream()

Bug Fixes:
* Properly parse program header table when ehdr.e_phnum > 0xffff
* Fix OOM in ElfStream parsing when parsing corrupted files
* Fix a divide by zero panic in SysVHashTable.find() for empty tables

Misc Improvements:
* Add more fuzz testing
* Add some simple parsing smoke tests for the various sample architecture objects
* Add sample object and testing with > 0xff00 section headers
* Add a lot more doc comments to each of the modules
2022-11-14 12:22:56 -08:00
Christopher Cole
4df35c65ca
Exclude .gitignore, .github/ and sample-objects/ from packaged crate 2022-11-09 16:33:10 -08:00
Christopher Cole
aa41e552ed
Bump crate version to v0.6.0
New Features:
* Add fuzz targets for parts of our ELF parsing interface via cargo-fuzz
* Add SysVHashTable which interprets the contents of a SHT_HASH section
* Add StringTable::get_raw() to get an uninterpreted &[u8]
* Add ParsingTable.len() method to get the number of elements in the table
* Add some note n_type constants for GNU extension notes.
* Add default "to_str" feature to get &str for gabi constant names

Changed Interfaces:
* Change File::segments() to return a ParsingTable instead of just a ParsingIterator
* Change File's SectionHeader interfaces to provide a ParsingTable instead of just a ParsingIterator
* Remove deprecated File::section_data_for_header() in favor of File::section_data()
* Remove FileHeader wrapper types OSABI, Architecture, and ObjectFileType
* Remove ProgramHeader wrapper types ProgType and ProgFlag
* Remove Symbol wrapper types SymbolType SymbolBind SymbolVis
* Remove wrapper type SectionType
* Remove unhelpful SectionFlag wrapper type
* Remove Display impl for FileHeader, SectionHeader, ProgramHeader, Symbol
* Remove ParseError::UnsupportedElfVersion in favor of more general ParseError::UnsupportedVersion

Bug Fixes:
* Fix divide by zero panic when parsing a note with alignment of 0 (Error instead of panic)
* Use checked integer math all over the parsing code (Error instead of panic or overflow)
* Fix note parsing for 8-byte aligned .note.gnu.property sections (Successfully parse instead of Erroring)
* Add size validation when parsing tables with entsizes (Error instead of panic)
2022-11-01 16:54:08 -07:00
Christopher Cole
be60cccbf9
Add to_str feature which exports to_str and Display impls for gabi constants
This has a few motivations:
* Move the big blocks of code dedicated to providing human readable strings for
  gabi constants out of the way. This code can be long and distracting from the actual
  parsing functionality.
* Allow users to opt out of this functionality if they don't need it. The big blocks
  of &'static str definitions can add a fair amount to the resulting library size. For
  users who are trying to optimize for library size, these to_str methods are often unneeded.
* The to_str method's Option return value allows users to decide how they want to display
  unknown values.
2022-10-30 14:26:07 -07:00
Christopher Cole
8771fbbff5
Bump crate version to v0.5.0
New interfaces:
* Add File::symbol_version_table() interface to get the GNU extension symbol versioning table
* Add Symbol.is_undefined() helper to check if a symbol is defined in this object
* Add File::section_data() which opportunistically parses the CompressionHeader if present

Bug fixes:
* Fix StringTable to return a ParseError on index out of bounds instead of panicking
* Fix File::section_data_as_rels to properly parse Rels (not Relas)
2022-10-30 12:35:39 -07:00
Christopher Cole
f44860bfc5
Bump crate version to v0.4.0
New Features:
* .note section and segment parsing
* .dynamic section and segment parsing
* .rel and .rela section parsing
* File::section_headers_with_strtab to get both a header iter and strtab concurrently.
  This is useful if you want to iterate over shdrs and get their names at the same time.

Interface changes:
The ReadBytesAt trait was changed to be implemented for an owned CachedReadBytes.
This means that File::open_stream now expects to move-own the CachedReadBytes
as opposed to taking a mutable reference.
2022-10-24 14:42:43 -07:00
Christopher Cole
2332a54a29
Bump crate version to v0.3.1
This picks up the fixes to section table parsing for large table sizes,
and provides the new File::section_data_for_header() method.
2022-10-21 13:49:37 -07:00
Christopher Cole
dd2685a864
Add some categories to Cargo.toml 2022-10-21 13:48:10 -07:00
Christopher Cole
5a4e556d68
Bump crate version to v0.3.0
This fully moves the parser over to the lazy zero-alloc approach which enables
a no_std option.
2022-10-20 23:17:10 -07:00
Christopher Cole
1be248c4bb
Add default std feature to allow no_std use-cases
This addresses the ask in #19
2022-10-20 23:00:57 -07:00
Christopher Cole
bab7e10ca4
Bump crate version to 0.2.0 2022-10-20 14:13:39 -07:00
Christopher Cole
bb1b4e0b6e
Bump crate version to 0.1.0 2022-10-13 16:41:18 -07:00
Christopher Cole
8fc5901f7e
Add a few more keywords to Cargo.toml
After all, why not?
2022-10-13 00:13:12 -07:00
Christopher Cole
11b7addf97 Specify edition 2021 and fix it up
```
$ cargo fix --edition
    Checking elf v0.0.12 (/Users/chris/code/rust-elf)
   Migrating src/lib.rs from 2015 edition to 2018
       Fixed src/lib.rs (1 fix)
       Fixed src/file.rs (3 fixes)
       Fixed src/parse.rs (1 fix)
       Fixed src/section.rs (4 fixes)
       Fixed src/segment.rs (4 fixes)
       Fixed src/utils.rs (3 fixes)
       Fixed src/segment.rs (4 fixes)
       Fixed src/lib.rs (1 fix)
       Fixed src/section.rs (4 fixes)
       Fixed src/file.rs (3 fixes)
    Finished dev [unoptimized + debuginfo] target(s) in 0.47s
```
2022-10-06 13:49:07 -07:00
Christopher Cole
4965746e79 Update Cargo.toml documentation link to point to docs.rs 2022-10-03 17:57:45 -07:00
Christopher Cole
6a4bd829cf Bump crate version to 0.0.12 to remove byteorder dependency 2022-10-03 17:44:47 -07:00
Christopher Cole
9b152e99de Replace byteorder crate dependency with safe transmute methods from std:: integer types 2022-10-03 17:38:22 -07:00
Christopher Cole
ce65abaecc Update byteorder to 1.x and bump our crate version now that this builds on rust 1.64.0 2022-10-02 23:19:44 -07:00
Christopher Cole
4141543ed9 Bump version to 0.0.10 2016-09-22 21:28:42 -07:00
Christopher Cole
e45bb844f6 Bump version to 0.0.9 2016-04-20 21:55:34 -07:00
Christopher Cole
2810b1b803 Move rust-readelf out into its own package 2016-04-20 21:03:18 -07:00
Christopher Cole
0a9f684c9b Bump version to 0.0.8 2016-04-06 14:01:13 -07:00
Christopher Cole
e10b5fbbb8 Bump version to 0.0.7 2016-04-05 02:51:24 +00:00
Christopher Cole
7398e3e083 Bump version to 0.0.6 2016-01-12 03:51:08 +00:00
Christopher Cole
f4232021d9 Restrict byteorder dependency to 0.*
The simple "*" wildcard dependency is misleading and discouraged
by crates.io. Updating to a more realistic "0.*".
2016-01-12 03:49:56 +00:00
Christopher Cole
723532d61d Relicense under dual MIT/Apache-2.0
The Robigalia project wants to include rust-elf. Relicensing at
their behest.
2016-01-12 03:43:15 +00:00
Christopher Cole
265c6b076e Bump version to 0.0.5 2015-07-24 05:30:21 +00:00
Richard Diamond
e5e60e6199 Update for newer Rust. 2015-06-29 05:38:59 -05:00
Christopher Cole
9726de2591 Bump version to 0.0.4 and add documentation link 2015-02-03 22:15:48 -08:00
Christopher Cole
01ca1e7483 Bump version to 0.0.3 2015-01-31 23:08:09 -08:00
Christopher Cole
592e165e34 Bump version to 0.0.2 2015-01-28 23:07:58 -08:00
Christopher Cole
2ba9481c14 Add travis-ci build badge to README.md 2015-01-26 21:50:21 -08:00
Christopher Cole
64e2e1ffe8 Add initial cargo packaging 2015-01-25 07:11:08 +00:00