Skip to content

Commit f428f83

Browse files
committed
Ignore ELF header OS byte
The OS byte changed from System V (0) to GNU (3) in Rust 1.89
1 parent 27734a9 commit f428f83

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ where
8888
const ET_EXEC: u16 = 0x0002;
8989
/// Standard ELF magic header
9090
const ELF_MAGIC: u32 = 0x7F454C46;
91-
/// 32-bit, little-endian, version 1, SysV
91+
/// 32-bit, little-endian, version 1, low OS byte ignored.
9292
const DESIRED_ELF_VERSION: u32 = 0x01010100;
9393

9494
/// Make a new loader
@@ -98,7 +98,8 @@ where
9898
// File doesn't start 0x7F E L F
9999
return Err(Error::NotAnElfFile);
100100
}
101-
let class_endian_version_abi = data_source.read_u32_be(0x04)?;
101+
// Mask out the OS byte which varies between Rust compiler versions.
102+
let class_endian_version_abi = data_source.read_u32_be(0x04)? & 0xffffff00;
102103
if class_endian_version_abi != Self::DESIRED_ELF_VERSION {
103104
return Err(Error::WrongElfFile);
104105
}

0 commit comments

Comments
 (0)