Skip to content

Commit

Permalink
Use offset_of! instead of hardcoded value
Browse files Browse the repository at this point in the history
It was stabilised in Rust 1.77
  • Loading branch information
mati865 authored and davidlattimore committed Jan 7, 2025
1 parent c7bbada commit 4452614
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libwild/src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use object::read::elf::SectionHeader as _;
use object::LittleEndian;
use std::borrow::Cow;
use std::io::Read as _;
use std::mem::offset_of;
use std::sync::atomic::Ordering;

/// Our starting address in memory when linking non-relocatable executables. We can start memory
Expand Down Expand Up @@ -296,8 +297,7 @@ pub(crate) struct EhFrameHdr {
pub(crate) entry_count: u32,
}

// TODO: Use offset-of once it's stable.
pub(crate) const FRAME_POINTER_FIELD_OFFSET: usize = 4;
pub(crate) const FRAME_POINTER_FIELD_OFFSET: usize = offset_of!(EhFrameHdr, frame_pointer);

/// The offset of the offset within the structure passed to __tls_get_addr.
pub(crate) const TLS_OFFSET_OFFSET: u64 = 8;
Expand Down

0 comments on commit 4452614

Please sign in to comment.