Update to latest rustc
This commit is contained in:
parent
cf4c629a2b
commit
a94d4d57de
@ -1,4 +1,4 @@
|
|||||||
use crate::spec::{base, PanicStrategy, Target, TargetMetadata};
|
use crate::spec::{PanicStrategy, Target, TargetMetadata, base};
|
||||||
|
|
||||||
pub(crate) fn target() -> Target {
|
pub(crate) fn target() -> Target {
|
||||||
let mut base = base::mikros::opts();
|
let mut base = base::mikros::opts();
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#![stable(feature = "mikros", since = "1.80.0")]
|
#![stable(feature = "mikros", since = "1.80.0")]
|
||||||
|
|
||||||
|
use elf::ElfBytes;
|
||||||
use elf::abi::{
|
use elf::abi::{
|
||||||
PT_DYNAMIC, PT_GNU_EH_FRAME, PT_GNU_RELRO, PT_GNU_STACK, PT_LOAD, PT_NULL, PT_PHDR,
|
PT_DYNAMIC, PT_GNU_EH_FRAME, PT_GNU_RELRO, PT_GNU_STACK, PT_LOAD, PT_NULL, PT_PHDR,
|
||||||
R_X86_64_RELATIVE, SHT_REL, SHT_RELA,
|
R_X86_64_RELATIVE, SHT_REL, SHT_RELA,
|
||||||
};
|
};
|
||||||
use elf::endian::AnyEndian;
|
use elf::endian::AnyEndian;
|
||||||
use elf::ElfBytes;
|
|
||||||
use x86_64::structures::paging::Page;
|
|
||||||
use x86_64::VirtAddr;
|
use x86_64::VirtAddr;
|
||||||
|
use x86_64::structures::paging::Page;
|
||||||
|
|
||||||
use super::address_space::AddressSpace;
|
use super::address_space::AddressSpace;
|
||||||
use crate::ptr;
|
use crate::ptr;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use core::alloc::Layout;
|
use core::alloc::Layout;
|
||||||
use core::mem;
|
use core::mem;
|
||||||
use core::mem::{align_of, size_of};
|
use core::mem::{align_of, size_of};
|
||||||
use core::ptr::{null_mut, NonNull};
|
use core::ptr::{NonNull, null_mut};
|
||||||
|
|
||||||
use super::{align_down_size, align_up, align_up_size};
|
use super::{align_down_size, align_up, align_up_size};
|
||||||
|
|
||||||
|
@ -32,7 +32,3 @@ pub fn decode_error_kind(_code: i32) -> crate::io::ErrorKind {
|
|||||||
pub fn abort_internal() -> ! {
|
pub fn abort_internal() -> ! {
|
||||||
core::intrinsics::abort();
|
core::intrinsics::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hashmap_random_keys() -> (u64, u64) {
|
|
||||||
(1, 2)
|
|
||||||
}
|
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
use super::syscalls;
|
use super::syscalls;
|
||||||
use crate::io;
|
use crate::io;
|
||||||
use crate::os::mikros::ipc::rpc;
|
use crate::os::mikros::ipc::rpc;
|
||||||
use crate::sync::atomic::AtomicUsize;
|
|
||||||
use crate::sync::OnceLock;
|
use crate::sync::OnceLock;
|
||||||
|
use crate::sync::atomic::AtomicUsize;
|
||||||
|
|
||||||
pub(crate) static STDIN_FD: OnceLock<Option<(u64, u64)>> = OnceLock::new();
|
pub(crate) static STDIN_FD: OnceLock<Option<(u64, u64)>> = OnceLock::new();
|
||||||
pub(crate) static STDOUT_FD: OnceLock<Option<(u64, u64)>> = OnceLock::new();
|
pub(crate) static STDOUT_FD: OnceLock<Option<(u64, u64)>> = OnceLock::new();
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
pub use zkvm::fill_bytes;
|
pub use zkvm::fill_bytes;
|
||||||
} else if #[cfg(any(
|
} else if #[cfg(any(
|
||||||
all(target_family = "wasm", target_os = "unknown"),
|
all(target_family = "wasm", target_os = "unknown"),
|
||||||
target_os = "xous",
|
target_os = "xous", target_os = "mikros",
|
||||||
))] {
|
))] {
|
||||||
// FIXME: finally remove std support for wasm32-unknown-unknown
|
// FIXME: finally remove std support for wasm32-unknown-unknown
|
||||||
// FIXME: add random data generation to xous
|
// FIXME: add random data generation to xous
|
||||||
@ -85,6 +85,7 @@
|
|||||||
target_os = "android",
|
target_os = "android",
|
||||||
all(target_family = "wasm", target_os = "unknown"),
|
all(target_family = "wasm", target_os = "unknown"),
|
||||||
target_os = "xous",
|
target_os = "xous",
|
||||||
|
target_os = "mikros",
|
||||||
)))]
|
)))]
|
||||||
pub fn hashmap_random_keys() -> (u64, u64) {
|
pub fn hashmap_random_keys() -> (u64, u64) {
|
||||||
let mut buf = [0; 16];
|
let mut buf = [0; 16];
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
extern crate quickcheck;
|
extern crate quickcheck;
|
||||||
|
|
||||||
use cobs::{
|
use cobs::{
|
||||||
decode, decode_vec, decode_vec_with_sentinel, encode, encode_vec, encode_vec_with_sentinel,
|
CobsDecoder, CobsEncoder, decode, decode_vec, decode_vec_with_sentinel, encode, encode_vec,
|
||||||
max_encoding_length, CobsDecoder, CobsEncoder,
|
encode_vec_with_sentinel, max_encoding_length,
|
||||||
};
|
};
|
||||||
use quickcheck::{quickcheck, TestResult};
|
use quickcheck::{TestResult, quickcheck};
|
||||||
|
|
||||||
fn test_pair(source: Vec<u8>, encoded: Vec<u8>) {
|
fn test_pair(source: Vec<u8>, encoded: Vec<u8>) {
|
||||||
let mut test_encoded = encoded.clone();
|
let mut test_encoded = encoded.clone();
|
||||||
|
@ -81,54 +81,38 @@ mod parse_tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_chdr32_lsb() {
|
fn parse_chdr32_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF32, CompressionHeader {
|
||||||
LittleEndian,
|
ch_type: 0x03020100,
|
||||||
Class::ELF32,
|
ch_size: 0x07060504,
|
||||||
CompressionHeader {
|
ch_addralign: 0x0B0A0908,
|
||||||
ch_type: 0x03020100,
|
});
|
||||||
ch_size: 0x07060504,
|
|
||||||
ch_addralign: 0x0B0A0908,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_chdr32_msb() {
|
fn parse_chdr32_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF32, CompressionHeader {
|
||||||
BigEndian,
|
ch_type: 0x00010203,
|
||||||
Class::ELF32,
|
ch_size: 0x04050607,
|
||||||
CompressionHeader {
|
ch_addralign: 0x08090A0B,
|
||||||
ch_type: 0x00010203,
|
});
|
||||||
ch_size: 0x04050607,
|
|
||||||
ch_addralign: 0x08090A0B,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_chdr64_lsb() {
|
fn parse_chdr64_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF64, CompressionHeader {
|
||||||
LittleEndian,
|
ch_type: 0x03020100,
|
||||||
Class::ELF64,
|
ch_size: 0x0F0E0D0C0B0A0908,
|
||||||
CompressionHeader {
|
ch_addralign: 0x1716151413121110,
|
||||||
ch_type: 0x03020100,
|
});
|
||||||
ch_size: 0x0F0E0D0C0B0A0908,
|
|
||||||
ch_addralign: 0x1716151413121110,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_chdr64_msb() {
|
fn parse_chdr64_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF64, CompressionHeader {
|
||||||
BigEndian,
|
ch_type: 0x00010203,
|
||||||
Class::ELF64,
|
ch_size: 0x08090A0B0C0D0E0F,
|
||||||
CompressionHeader {
|
ch_addralign: 0x1011121314151617,
|
||||||
ch_type: 0x00010203,
|
});
|
||||||
ch_size: 0x08090A0B0C0D0E0F,
|
|
||||||
ch_addralign: 0x1011121314151617,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -89,20 +89,18 @@ fn parse_dyn32_msb() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_dyn64_lsb() {
|
fn parse_dyn64_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF64, Dyn {
|
||||||
LittleEndian,
|
d_tag: 0x0706050403020100,
|
||||||
Class::ELF64,
|
d_un: 0x0F0E0D0C0B0A0908,
|
||||||
Dyn { d_tag: 0x0706050403020100, d_un: 0x0F0E0D0C0B0A0908 },
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_dyn64_msb() {
|
fn parse_dyn64_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF64, Dyn {
|
||||||
BigEndian,
|
d_tag: 0x0001020304050607,
|
||||||
Class::ELF64,
|
d_un: 0x08090A0B0C0D0E0F,
|
||||||
Dyn { d_tag: 0x0001020304050607, d_un: 0x08090A0B0C0D0E0F },
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
use crate::compression::CompressionHeader;
|
use crate::compression::CompressionHeader;
|
||||||
use crate::dynamic::{Dyn, DynamicTable};
|
use crate::dynamic::{Dyn, DynamicTable};
|
||||||
use crate::endian::EndianParse;
|
use crate::endian::EndianParse;
|
||||||
use crate::file::{parse_ident, Class, FileHeader};
|
use crate::file::{Class, FileHeader, parse_ident};
|
||||||
use crate::gnu_symver::{
|
use crate::gnu_symver::{
|
||||||
SymbolVersionTable, VerDefIterator, VerNeedIterator, VersionIndex, VersionIndexTable,
|
SymbolVersionTable, VerDefIterator, VerNeedIterator, VersionIndex, VersionIndexTable,
|
||||||
};
|
};
|
||||||
@ -807,19 +807,16 @@ fn segments() {
|
|||||||
|
|
||||||
let segments: Vec<ProgramHeader> =
|
let segments: Vec<ProgramHeader> =
|
||||||
file.segments().expect("File should have a segment table").iter().collect();
|
file.segments().expect("File should have a segment table").iter().collect();
|
||||||
assert_eq!(
|
assert_eq!(segments[0], ProgramHeader {
|
||||||
segments[0],
|
p_type: abi::PT_PHDR,
|
||||||
ProgramHeader {
|
p_offset: 64,
|
||||||
p_type: abi::PT_PHDR,
|
p_vaddr: 4194368,
|
||||||
p_offset: 64,
|
p_paddr: 4194368,
|
||||||
p_vaddr: 4194368,
|
p_filesz: 448,
|
||||||
p_paddr: 4194368,
|
p_memsz: 448,
|
||||||
p_filesz: 448,
|
p_flags: 5,
|
||||||
p_memsz: 448,
|
p_align: 8,
|
||||||
p_flags: 5,
|
});
|
||||||
p_align: 8,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -831,19 +828,16 @@ fn segments_phnum_in_shdr0() {
|
|||||||
|
|
||||||
let segments: Vec<ProgramHeader> =
|
let segments: Vec<ProgramHeader> =
|
||||||
file.segments().expect("File should have a segment table").iter().collect();
|
file.segments().expect("File should have a segment table").iter().collect();
|
||||||
assert_eq!(
|
assert_eq!(segments[0], ProgramHeader {
|
||||||
segments[0],
|
p_type: abi::PT_PHDR,
|
||||||
ProgramHeader {
|
p_offset: 92,
|
||||||
p_type: abi::PT_PHDR,
|
p_vaddr: 0,
|
||||||
p_offset: 92,
|
p_paddr: 0,
|
||||||
p_vaddr: 0,
|
p_filesz: 32,
|
||||||
p_paddr: 0,
|
p_memsz: 32,
|
||||||
p_filesz: 32,
|
p_flags: 0x20003,
|
||||||
p_memsz: 32,
|
p_align: 0x40000,
|
||||||
p_flags: 0x20003,
|
});
|
||||||
p_align: 0x40000,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -1034,14 +1028,18 @@ fn section_data_as_relas() {
|
|||||||
.expect("Failed to get rela shdr");
|
.expect("Failed to get rela shdr");
|
||||||
|
|
||||||
let mut relas = file.section_data_as_relas(&shdr).expect("Failed to read relas section");
|
let mut relas = file.section_data_as_relas(&shdr).expect("Failed to read relas section");
|
||||||
assert_eq!(
|
assert_eq!(relas.next().expect("Failed to get rela entry"), Rela {
|
||||||
relas.next().expect("Failed to get rela entry"),
|
r_offset: 6293704,
|
||||||
Rela { r_offset: 6293704, r_sym: 1, r_type: 7, r_addend: 0 }
|
r_sym: 1,
|
||||||
);
|
r_type: 7,
|
||||||
assert_eq!(
|
r_addend: 0
|
||||||
relas.next().expect("Failed to get rela entry"),
|
});
|
||||||
Rela { r_offset: 6293712, r_sym: 2, r_type: 7, r_addend: 0 }
|
assert_eq!(relas.next().expect("Failed to get rela entry"), Rela {
|
||||||
);
|
r_offset: 6293712,
|
||||||
|
r_sym: 2,
|
||||||
|
r_type: 7,
|
||||||
|
r_addend: 0
|
||||||
|
});
|
||||||
assert!(relas.next().is_none());
|
assert!(relas.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1106,14 +1104,14 @@ fn dynamic() {
|
|||||||
.expect("Failed to parse .dynamic")
|
.expect("Failed to parse .dynamic")
|
||||||
.expect("Failed to find .dynamic")
|
.expect("Failed to find .dynamic")
|
||||||
.iter();
|
.iter();
|
||||||
assert_eq!(
|
assert_eq!(dynamic.next().expect("Failed to get dyn entry"), Dyn {
|
||||||
dynamic.next().expect("Failed to get dyn entry"),
|
d_tag: abi::DT_NEEDED,
|
||||||
Dyn { d_tag: abi::DT_NEEDED, d_un: 1 }
|
d_un: 1
|
||||||
);
|
});
|
||||||
assert_eq!(
|
assert_eq!(dynamic.next().expect("Failed to get dyn entry"), Dyn {
|
||||||
dynamic.next().expect("Failed to get dyn entry"),
|
d_tag: abi::DT_INIT,
|
||||||
Dyn { d_tag: abi::DT_INIT, d_un: 4195216 }
|
d_un: 4195216
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -1128,17 +1126,14 @@ fn symbol_table() {
|
|||||||
.expect("Failed to read symbol table")
|
.expect("Failed to read symbol table")
|
||||||
.expect("Failed to find symbol table");
|
.expect("Failed to find symbol table");
|
||||||
let symbol = symtab.get(30).expect("Failed to get symbol");
|
let symbol = symtab.get(30).expect("Failed to get symbol");
|
||||||
assert_eq!(
|
assert_eq!(symbol, Symbol {
|
||||||
symbol,
|
st_name: 19,
|
||||||
Symbol {
|
st_value: 6293200,
|
||||||
st_name: 19,
|
st_size: 0,
|
||||||
st_value: 6293200,
|
st_shndx: 21,
|
||||||
st_size: 0,
|
st_info: 1,
|
||||||
st_shndx: 21,
|
st_other: 0,
|
||||||
st_info: 1,
|
});
|
||||||
st_other: 0,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
strtab.get(symbol.st_name as usize).expect("Failed to get name from strtab"),
|
strtab.get(symbol.st_name as usize).expect("Failed to get name from strtab"),
|
||||||
"__JCR_LIST__"
|
"__JCR_LIST__"
|
||||||
@ -1157,10 +1152,14 @@ fn dynamic_symbol_table() {
|
|||||||
.expect("Failed to read symbol table")
|
.expect("Failed to read symbol table")
|
||||||
.expect("Failed to find symbol table");
|
.expect("Failed to find symbol table");
|
||||||
let symbol = symtab.get(1).expect("Failed to get symbol");
|
let symbol = symtab.get(1).expect("Failed to get symbol");
|
||||||
assert_eq!(
|
assert_eq!(symbol, Symbol {
|
||||||
symbol,
|
st_name: 11,
|
||||||
Symbol { st_name: 11, st_value: 0, st_size: 0, st_shndx: 0, st_info: 18, st_other: 0 }
|
st_value: 0,
|
||||||
);
|
st_size: 0,
|
||||||
|
st_shndx: 0,
|
||||||
|
st_info: 18,
|
||||||
|
st_other: 0
|
||||||
|
});
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
strtab.get(symbol.st_name as usize).expect("Failed to get name from strtab"),
|
strtab.get(symbol.st_name as usize).expect("Failed to get name from strtab"),
|
||||||
"memset"
|
"memset"
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
use crate::compression::CompressionHeader;
|
use crate::compression::CompressionHeader;
|
||||||
use crate::dynamic::DynamicTable;
|
use crate::dynamic::DynamicTable;
|
||||||
use crate::endian::EndianParse;
|
use crate::endian::EndianParse;
|
||||||
use crate::file::{parse_ident, Class, FileHeader};
|
use crate::file::{Class, FileHeader, parse_ident};
|
||||||
use crate::gnu_symver::{
|
use crate::gnu_symver::{
|
||||||
SymbolVersionTable, VerDefIterator, VerNeedIterator, VersionIndex, VersionIndexTable,
|
SymbolVersionTable, VerDefIterator, VerNeedIterator, VersionIndex, VersionIndexTable,
|
||||||
};
|
};
|
||||||
@ -780,19 +780,16 @@ fn segments() {
|
|||||||
let file = ElfStream::<AnyEndian, _>::open_stream(io).expect("Open test1");
|
let file = ElfStream::<AnyEndian, _>::open_stream(io).expect("Open test1");
|
||||||
|
|
||||||
let segments = file.segments();
|
let segments = file.segments();
|
||||||
assert_eq!(
|
assert_eq!(segments[0], ProgramHeader {
|
||||||
segments[0],
|
p_type: abi::PT_PHDR,
|
||||||
ProgramHeader {
|
p_offset: 64,
|
||||||
p_type: abi::PT_PHDR,
|
p_vaddr: 4194368,
|
||||||
p_offset: 64,
|
p_paddr: 4194368,
|
||||||
p_vaddr: 4194368,
|
p_filesz: 448,
|
||||||
p_paddr: 4194368,
|
p_memsz: 448,
|
||||||
p_filesz: 448,
|
p_flags: 5,
|
||||||
p_memsz: 448,
|
p_align: 8,
|
||||||
p_flags: 5,
|
})
|
||||||
p_align: 8,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -801,19 +798,16 @@ fn segments_phnum_in_shdr0() {
|
|||||||
let io = std::fs::File::open(path).expect("Could not open file.");
|
let io = std::fs::File::open(path).expect("Could not open file.");
|
||||||
let file = ElfStream::<AnyEndian, _>::open_stream(io).expect("Open test1");
|
let file = ElfStream::<AnyEndian, _>::open_stream(io).expect("Open test1");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(file.segments()[0], ProgramHeader {
|
||||||
file.segments()[0],
|
p_type: abi::PT_PHDR,
|
||||||
ProgramHeader {
|
p_offset: 92,
|
||||||
p_type: abi::PT_PHDR,
|
p_vaddr: 0,
|
||||||
p_offset: 92,
|
p_paddr: 0,
|
||||||
p_vaddr: 0,
|
p_filesz: 32,
|
||||||
p_paddr: 0,
|
p_memsz: 32,
|
||||||
p_filesz: 32,
|
p_flags: 0x20003,
|
||||||
p_memsz: 32,
|
p_align: 0x40000,
|
||||||
p_flags: 0x20003,
|
});
|
||||||
p_align: 0x40000,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -827,17 +821,14 @@ fn symbol_table() {
|
|||||||
.expect("Failed to read symbol table")
|
.expect("Failed to read symbol table")
|
||||||
.expect("Failed to find symbol table");
|
.expect("Failed to find symbol table");
|
||||||
let symbol = symtab.get(30).expect("Failed to get symbol");
|
let symbol = symtab.get(30).expect("Failed to get symbol");
|
||||||
assert_eq!(
|
assert_eq!(symbol, Symbol {
|
||||||
symbol,
|
st_name: 19,
|
||||||
Symbol {
|
st_value: 6293200,
|
||||||
st_name: 19,
|
st_size: 0,
|
||||||
st_value: 6293200,
|
st_shndx: 21,
|
||||||
st_size: 0,
|
st_info: 1,
|
||||||
st_shndx: 21,
|
st_other: 0,
|
||||||
st_info: 1,
|
});
|
||||||
st_other: 0,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
strtab.get(symbol.st_name as usize).expect("Failed to get name from strtab"),
|
strtab.get(symbol.st_name as usize).expect("Failed to get name from strtab"),
|
||||||
"__JCR_LIST__"
|
"__JCR_LIST__"
|
||||||
@ -855,10 +846,14 @@ fn dynamic_symbol_table() {
|
|||||||
.expect("Failed to read symbol table")
|
.expect("Failed to read symbol table")
|
||||||
.expect("Failed to find symbol table");
|
.expect("Failed to find symbol table");
|
||||||
let symbol = symtab.get(1).expect("Failed to get symbol");
|
let symbol = symtab.get(1).expect("Failed to get symbol");
|
||||||
assert_eq!(
|
assert_eq!(symbol, Symbol {
|
||||||
symbol,
|
st_name: 11,
|
||||||
Symbol { st_name: 11, st_value: 0, st_size: 0, st_shndx: 0, st_info: 18, st_other: 0 }
|
st_value: 0,
|
||||||
);
|
st_size: 0,
|
||||||
|
st_shndx: 0,
|
||||||
|
st_info: 18,
|
||||||
|
st_other: 0
|
||||||
|
});
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
strtab.get(symbol.st_name as usize).expect("Failed to get name from strtab"),
|
strtab.get(symbol.st_name as usize).expect("Failed to get name from strtab"),
|
||||||
"memset"
|
"memset"
|
||||||
@ -876,14 +871,14 @@ fn dynamic() {
|
|||||||
.expect("Failed to parse .dynamic")
|
.expect("Failed to parse .dynamic")
|
||||||
.expect("Failed to find .dynamic")
|
.expect("Failed to find .dynamic")
|
||||||
.iter();
|
.iter();
|
||||||
assert_eq!(
|
assert_eq!(dynamic.next().expect("Failed to get dyn entry"), Dyn {
|
||||||
dynamic.next().expect("Failed to get dyn entry"),
|
d_tag: abi::DT_NEEDED,
|
||||||
Dyn { d_tag: abi::DT_NEEDED, d_un: 1 }
|
d_un: 1
|
||||||
);
|
});
|
||||||
assert_eq!(
|
assert_eq!(dynamic.next().expect("Failed to get dyn entry"), Dyn {
|
||||||
dynamic.next().expect("Failed to get dyn entry"),
|
d_tag: abi::DT_INIT,
|
||||||
Dyn { d_tag: abi::DT_INIT, d_un: 4195216 }
|
d_un: 4195216
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -904,14 +899,18 @@ fn section_data_as_relas() {
|
|||||||
|
|
||||||
let shdr = file.section_headers()[10];
|
let shdr = file.section_headers()[10];
|
||||||
let mut relas = file.section_data_as_relas(&shdr).expect("Failed to read relas section");
|
let mut relas = file.section_data_as_relas(&shdr).expect("Failed to read relas section");
|
||||||
assert_eq!(
|
assert_eq!(relas.next().expect("Failed to get rela entry"), Rela {
|
||||||
relas.next().expect("Failed to get rela entry"),
|
r_offset: 6293704,
|
||||||
Rela { r_offset: 6293704, r_sym: 1, r_type: 7, r_addend: 0 }
|
r_sym: 1,
|
||||||
);
|
r_type: 7,
|
||||||
assert_eq!(
|
r_addend: 0
|
||||||
relas.next().expect("Failed to get rela entry"),
|
});
|
||||||
Rela { r_offset: 6293712, r_sym: 2, r_type: 7, r_addend: 0 }
|
assert_eq!(relas.next().expect("Failed to get rela entry"), Rela {
|
||||||
);
|
r_offset: 6293712,
|
||||||
|
r_sym: 2,
|
||||||
|
r_type: 7,
|
||||||
|
r_addend: 0
|
||||||
|
});
|
||||||
assert!(relas.next().is_none());
|
assert!(relas.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,28 +368,25 @@ fn test_parse_ehdr32_works() {
|
|||||||
*elem = n as u8;
|
*elem = n as u8;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(FileHeader::parse_tail(ident, &tail).unwrap(), FileHeader {
|
||||||
FileHeader::parse_tail(ident, &tail).unwrap(),
|
class: Class::ELF32,
|
||||||
FileHeader {
|
endianness: AnyEndian::Little,
|
||||||
class: Class::ELF32,
|
version: 0x7060504,
|
||||||
endianness: AnyEndian::Little,
|
osabi: abi::ELFOSABI_LINUX,
|
||||||
version: 0x7060504,
|
abiversion: 7,
|
||||||
osabi: abi::ELFOSABI_LINUX,
|
e_type: 0x100,
|
||||||
abiversion: 7,
|
e_machine: 0x302,
|
||||||
e_type: 0x100,
|
e_entry: 0x0B0A0908,
|
||||||
e_machine: 0x302,
|
e_phoff: 0x0F0E0D0C,
|
||||||
e_entry: 0x0B0A0908,
|
e_shoff: 0x13121110,
|
||||||
e_phoff: 0x0F0E0D0C,
|
e_flags: 0x17161514,
|
||||||
e_shoff: 0x13121110,
|
e_ehsize: 0x1918,
|
||||||
e_flags: 0x17161514,
|
e_phentsize: 0x1B1A,
|
||||||
e_ehsize: 0x1918,
|
e_phnum: 0x1D1C,
|
||||||
e_phentsize: 0x1B1A,
|
e_shentsize: 0x1F1E,
|
||||||
e_phnum: 0x1D1C,
|
e_shnum: 0x2120,
|
||||||
e_shentsize: 0x1F1E,
|
e_shstrndx: 0x2322,
|
||||||
e_shnum: 0x2120,
|
});
|
||||||
e_shstrndx: 0x2322,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -415,28 +412,25 @@ fn test_parse_ehdr64_works() {
|
|||||||
*elem = n as u8;
|
*elem = n as u8;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(FileHeader::parse_tail(ident, &tail).unwrap(), FileHeader {
|
||||||
FileHeader::parse_tail(ident, &tail).unwrap(),
|
class: Class::ELF64,
|
||||||
FileHeader {
|
endianness: AnyEndian::Big,
|
||||||
class: Class::ELF64,
|
version: 0x04050607,
|
||||||
endianness: AnyEndian::Big,
|
osabi: abi::ELFOSABI_LINUX,
|
||||||
version: 0x04050607,
|
abiversion: 7,
|
||||||
osabi: abi::ELFOSABI_LINUX,
|
e_type: 0x0001,
|
||||||
abiversion: 7,
|
e_machine: 0x0203,
|
||||||
e_type: 0x0001,
|
e_entry: 0x08090A0B0C0D0E0F,
|
||||||
e_machine: 0x0203,
|
e_phoff: 0x1011121314151617,
|
||||||
e_entry: 0x08090A0B0C0D0E0F,
|
e_shoff: 0x18191A1B1C1D1E1F,
|
||||||
e_phoff: 0x1011121314151617,
|
e_flags: 0x20212223,
|
||||||
e_shoff: 0x18191A1B1C1D1E1F,
|
e_ehsize: 0x2425,
|
||||||
e_flags: 0x20212223,
|
e_phentsize: 0x2627,
|
||||||
e_ehsize: 0x2425,
|
e_phnum: 0x2829,
|
||||||
e_phentsize: 0x2627,
|
e_shentsize: 0x2A2B,
|
||||||
e_phnum: 0x2829,
|
e_shnum: 0x2C2D,
|
||||||
e_shentsize: 0x2A2B,
|
e_shstrndx: 0x2E2F,
|
||||||
e_shnum: 0x2C2D,
|
});
|
||||||
e_shstrndx: 0x2E2F,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -694,16 +694,13 @@ fn verneedaux_iter_one_entry() {
|
|||||||
let mut iter =
|
let mut iter =
|
||||||
VerNeedAuxIterator::new(LittleEndian, Class::ELF64, 1, 0x10, &GNU_VERNEED_DATA);
|
VerNeedAuxIterator::new(LittleEndian, Class::ELF64, 1, 0x10, &GNU_VERNEED_DATA);
|
||||||
let aux1 = iter.next().expect("Failed to parse");
|
let aux1 = iter.next().expect("Failed to parse");
|
||||||
assert_eq!(
|
assert_eq!(aux1, VerNeedAux {
|
||||||
aux1,
|
vna_hash: 0x0827e5c0,
|
||||||
VerNeedAux {
|
vna_flags: 0,
|
||||||
vna_hash: 0x0827e5c0,
|
vna_other: 0x0a,
|
||||||
vna_flags: 0,
|
vna_name: 0x01,
|
||||||
vna_other: 0x0a,
|
vna_next: 0
|
||||||
vna_name: 0x01,
|
});
|
||||||
vna_next: 0
|
|
||||||
}
|
|
||||||
);
|
|
||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -712,38 +709,29 @@ fn verneedaux_iter_multiple_entries() {
|
|||||||
let mut iter =
|
let mut iter =
|
||||||
VerNeedAuxIterator::new(LittleEndian, Class::ELF64, 3, 0x30, &GNU_VERNEED_DATA);
|
VerNeedAuxIterator::new(LittleEndian, Class::ELF64, 3, 0x30, &GNU_VERNEED_DATA);
|
||||||
let aux1 = iter.next().expect("Failed to parse");
|
let aux1 = iter.next().expect("Failed to parse");
|
||||||
assert_eq!(
|
assert_eq!(aux1, VerNeedAux {
|
||||||
aux1,
|
vna_hash: 0x0d696913,
|
||||||
VerNeedAux {
|
vna_flags: 0,
|
||||||
vna_hash: 0x0d696913,
|
vna_other: 0x0c,
|
||||||
vna_flags: 0,
|
vna_name: 0x0c,
|
||||||
vna_other: 0x0c,
|
vna_next: 0x10
|
||||||
vna_name: 0x0c,
|
});
|
||||||
vna_next: 0x10
|
|
||||||
}
|
|
||||||
);
|
|
||||||
let aux2 = iter.next().expect("Failed to parse");
|
let aux2 = iter.next().expect("Failed to parse");
|
||||||
assert_eq!(
|
assert_eq!(aux2, VerNeedAux {
|
||||||
aux2,
|
vna_hash: 0x069691b3,
|
||||||
VerNeedAux {
|
vna_flags: 0,
|
||||||
vna_hash: 0x069691b3,
|
vna_other: 0x0b,
|
||||||
vna_flags: 0,
|
vna_name: 0x17,
|
||||||
vna_other: 0x0b,
|
vna_next: 0x10
|
||||||
vna_name: 0x17,
|
});
|
||||||
vna_next: 0x10
|
|
||||||
}
|
|
||||||
);
|
|
||||||
let aux3 = iter.next().expect("Failed to parse");
|
let aux3 = iter.next().expect("Failed to parse");
|
||||||
assert_eq!(
|
assert_eq!(aux3, VerNeedAux {
|
||||||
aux3,
|
vna_hash: 0x06969194,
|
||||||
VerNeedAux {
|
vna_flags: 0,
|
||||||
vna_hash: 0x06969194,
|
vna_other: 0x09,
|
||||||
vna_flags: 0,
|
vna_name: 0x37,
|
||||||
vna_other: 0x09,
|
vna_next: 0
|
||||||
vna_name: 0x37,
|
});
|
||||||
vna_next: 0
|
|
||||||
}
|
|
||||||
);
|
|
||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -766,49 +754,37 @@ fn verneedaux_iter_two_lists_interspersed() {
|
|||||||
let mut iter2 = VerNeedAuxIterator::new(LittleEndian, Class::ELF64, 2, 0x10, &data);
|
let mut iter2 = VerNeedAuxIterator::new(LittleEndian, Class::ELF64, 2, 0x10, &data);
|
||||||
|
|
||||||
let aux1_1 = iter1.next().expect("Failed to parse");
|
let aux1_1 = iter1.next().expect("Failed to parse");
|
||||||
assert_eq!(
|
assert_eq!(aux1_1, VerNeedAux {
|
||||||
aux1_1,
|
vna_hash: 0x0827e5c0,
|
||||||
VerNeedAux {
|
vna_flags: 0,
|
||||||
vna_hash: 0x0827e5c0,
|
vna_other: 0x0a,
|
||||||
vna_flags: 0,
|
vna_name: 0x0ccc,
|
||||||
vna_other: 0x0a,
|
vna_next: 0x20,
|
||||||
vna_name: 0x0ccc,
|
});
|
||||||
vna_next: 0x20,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
let aux2_1 = iter2.next().expect("Failed to parse");
|
let aux2_1 = iter2.next().expect("Failed to parse");
|
||||||
assert_eq!(
|
assert_eq!(aux2_1, VerNeedAux {
|
||||||
aux2_1,
|
vna_hash: 0x0d696913,
|
||||||
VerNeedAux {
|
vna_flags: 0,
|
||||||
vna_hash: 0x0d696913,
|
vna_other: 0x0c,
|
||||||
vna_flags: 0,
|
vna_name: 0x0cd7,
|
||||||
vna_other: 0x0c,
|
vna_next: 0x20
|
||||||
vna_name: 0x0cd7,
|
});
|
||||||
vna_next: 0x20
|
|
||||||
}
|
|
||||||
);
|
|
||||||
let aux1_2 = iter1.next().expect("Failed to parse");
|
let aux1_2 = iter1.next().expect("Failed to parse");
|
||||||
assert_eq!(
|
assert_eq!(aux1_2, VerNeedAux {
|
||||||
aux1_2,
|
vna_hash: 0x069691b3,
|
||||||
VerNeedAux {
|
vna_flags: 0,
|
||||||
vna_hash: 0x069691b3,
|
vna_other: 0x0b,
|
||||||
vna_flags: 0,
|
vna_name: 0x0ce1,
|
||||||
vna_other: 0x0b,
|
vna_next: 0
|
||||||
vna_name: 0x0ce1,
|
});
|
||||||
vna_next: 0
|
|
||||||
}
|
|
||||||
);
|
|
||||||
let aux2_2 = iter2.next().expect("Failed to parse");
|
let aux2_2 = iter2.next().expect("Failed to parse");
|
||||||
assert_eq!(
|
assert_eq!(aux2_2, VerNeedAux {
|
||||||
aux2_2,
|
vna_hash: 0x06969194,
|
||||||
VerNeedAux {
|
vna_flags: 0,
|
||||||
vna_hash: 0x06969194,
|
vna_other: 0x09,
|
||||||
vna_flags: 0,
|
vna_name: 0x0cec,
|
||||||
vna_other: 0x09,
|
vna_next: 0
|
||||||
vna_name: 0x0cec,
|
});
|
||||||
vna_next: 0
|
|
||||||
}
|
|
||||||
);
|
|
||||||
assert!(iter1.next().is_none());
|
assert!(iter1.next().is_none());
|
||||||
assert!(iter2.next().is_none());
|
assert!(iter2.next().is_none());
|
||||||
}
|
}
|
||||||
@ -878,61 +854,58 @@ fn verdef_iter() {
|
|||||||
|
|
||||||
assert_eq!(entries.len(), 4);
|
assert_eq!(entries.len(), 4);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(entries, vec![
|
||||||
entries,
|
(
|
||||||
vec![
|
VerDef {
|
||||||
(
|
vd_flags: 1,
|
||||||
VerDef {
|
vd_ndx: 1,
|
||||||
vd_flags: 1,
|
vd_cnt: 1,
|
||||||
vd_ndx: 1,
|
vd_hash: 0x0B077AB0,
|
||||||
vd_cnt: 1,
|
vd_aux: 20,
|
||||||
vd_hash: 0x0B077AB0,
|
vd_next: 28,
|
||||||
vd_aux: 20,
|
},
|
||||||
vd_next: 28,
|
vec![VerDefAux { vda_name: 0x1, vda_next: 0 }]
|
||||||
},
|
),
|
||||||
vec![VerDefAux { vda_name: 0x1, vda_next: 0 }]
|
(
|
||||||
),
|
VerDef {
|
||||||
(
|
vd_flags: 0,
|
||||||
VerDef {
|
vd_ndx: 2,
|
||||||
vd_flags: 0,
|
vd_cnt: 1,
|
||||||
vd_ndx: 2,
|
vd_hash: 0x088f2f70,
|
||||||
vd_cnt: 1,
|
vd_aux: 20,
|
||||||
vd_hash: 0x088f2f70,
|
vd_next: 28,
|
||||||
vd_aux: 20,
|
},
|
||||||
vd_next: 28,
|
vec![VerDefAux { vda_name: 0xC, vda_next: 0 }]
|
||||||
},
|
),
|
||||||
vec![VerDefAux { vda_name: 0xC, vda_next: 0 }]
|
(
|
||||||
),
|
VerDef {
|
||||||
(
|
vd_flags: 0,
|
||||||
VerDef {
|
vd_ndx: 3,
|
||||||
vd_flags: 0,
|
vd_cnt: 2,
|
||||||
vd_ndx: 3,
|
vd_hash: 0x088f2f71,
|
||||||
vd_cnt: 2,
|
vd_aux: 20,
|
||||||
vd_hash: 0x088f2f71,
|
vd_next: 36,
|
||||||
vd_aux: 20,
|
},
|
||||||
vd_next: 36,
|
vec![VerDefAux { vda_name: 0x17, vda_next: 8 }, VerDefAux {
|
||||||
},
|
vda_name: 0xC,
|
||||||
vec![
|
vda_next: 0
|
||||||
VerDefAux { vda_name: 0x17, vda_next: 8 },
|
}]
|
||||||
VerDefAux { vda_name: 0xC, vda_next: 0 }
|
),
|
||||||
]
|
(
|
||||||
),
|
VerDef {
|
||||||
(
|
vd_flags: 0,
|
||||||
VerDef {
|
vd_ndx: 4,
|
||||||
vd_flags: 0,
|
vd_cnt: 2,
|
||||||
vd_ndx: 4,
|
vd_hash: 0x088f2f72,
|
||||||
vd_cnt: 2,
|
vd_aux: 20,
|
||||||
vd_hash: 0x088f2f72,
|
vd_next: 0,
|
||||||
vd_aux: 20,
|
},
|
||||||
vd_next: 0,
|
vec![VerDefAux { vda_name: 0xC, vda_next: 8 }, VerDefAux {
|
||||||
},
|
vda_name: 0x17,
|
||||||
vec![
|
vda_next: 0
|
||||||
VerDefAux { vda_name: 0xC, vda_next: 8 },
|
}]
|
||||||
VerDefAux { vda_name: 0x17, vda_next: 0 }
|
),
|
||||||
]
|
]);
|
||||||
),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -1041,31 +1014,25 @@ fn version_table() {
|
|||||||
.get_requirement(2)
|
.get_requirement(2)
|
||||||
.expect("Failed to parse definition")
|
.expect("Failed to parse definition")
|
||||||
.expect("Failed to find req");
|
.expect("Failed to find req");
|
||||||
assert_eq!(
|
assert_eq!(req1, SymbolRequirement {
|
||||||
req1,
|
file: "libc.so.6",
|
||||||
SymbolRequirement {
|
name: "GLIBC_2.3",
|
||||||
file: "libc.so.6",
|
hash: 0x6969194,
|
||||||
name: "GLIBC_2.3",
|
flags: 0,
|
||||||
hash: 0x6969194,
|
hidden: false
|
||||||
flags: 0,
|
});
|
||||||
hidden: false
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
let req2 = table
|
let req2 = table
|
||||||
.get_requirement(3)
|
.get_requirement(3)
|
||||||
.expect("Failed to parse definition")
|
.expect("Failed to parse definition")
|
||||||
.expect("Failed to find req");
|
.expect("Failed to find req");
|
||||||
assert_eq!(
|
assert_eq!(req2, SymbolRequirement {
|
||||||
req2,
|
file: "libz.so.1",
|
||||||
SymbolRequirement {
|
name: "ZLIB_1.2.0",
|
||||||
file: "libz.so.1",
|
hash: 0x827E5C0,
|
||||||
name: "ZLIB_1.2.0",
|
flags: 0,
|
||||||
hash: 0x827E5C0,
|
hidden: false
|
||||||
flags: 0,
|
});
|
||||||
hidden: false
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// The last version_index points to non-existent definitions. Maybe we should treat
|
// The last version_index points to non-existent definitions. Maybe we should treat
|
||||||
// this as a ParseError instead of returning an empty Option? This can only happen
|
// this as a ParseError instead of returning an empty Option? This can only happen
|
||||||
@ -1138,17 +1105,14 @@ fn parse_verdef32_lsb() {
|
|||||||
let entry = VerDef::parse_at(LittleEndian, Class::ELF32, &mut offset, data.as_ref())
|
let entry = VerDef::parse_at(LittleEndian, Class::ELF32, &mut offset, data.as_ref())
|
||||||
.expect("Failed to parse VerDef");
|
.expect("Failed to parse VerDef");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(entry, VerDef {
|
||||||
entry,
|
vd_flags: 0x0302,
|
||||||
VerDef {
|
vd_ndx: 0x0504,
|
||||||
vd_flags: 0x0302,
|
vd_cnt: 0x0706,
|
||||||
vd_ndx: 0x0504,
|
vd_hash: 0x0B0A0908,
|
||||||
vd_cnt: 0x0706,
|
vd_aux: 0x0F0E0D0C,
|
||||||
vd_hash: 0x0B0A0908,
|
vd_next: 0x13121110,
|
||||||
vd_aux: 0x0F0E0D0C,
|
});
|
||||||
vd_next: 0x13121110,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
assert_eq!(offset, ELFVERDEFSIZE);
|
assert_eq!(offset, ELFVERDEFSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1180,17 +1144,14 @@ fn parse_verdef64_msb() {
|
|||||||
let entry = VerDef::parse_at(BigEndian, Class::ELF64, &mut offset, data.as_ref())
|
let entry = VerDef::parse_at(BigEndian, Class::ELF64, &mut offset, data.as_ref())
|
||||||
.expect("Failed to parse VerDef");
|
.expect("Failed to parse VerDef");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(entry, VerDef {
|
||||||
entry,
|
vd_flags: 0x0203,
|
||||||
VerDef {
|
vd_ndx: 0x0405,
|
||||||
vd_flags: 0x0203,
|
vd_cnt: 0x0607,
|
||||||
vd_ndx: 0x0405,
|
vd_hash: 0x08090A0B,
|
||||||
vd_cnt: 0x0607,
|
vd_aux: 0x0C0D0E0F,
|
||||||
vd_hash: 0x08090A0B,
|
vd_next: 0x10111213,
|
||||||
vd_aux: 0x0C0D0E0F,
|
});
|
||||||
vd_next: 0x10111213,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
assert_eq!(offset, ELFVERDEFSIZE);
|
assert_eq!(offset, ELFVERDEFSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1229,38 +1190,34 @@ fn parse_verdef_bad_version_errors() {
|
|||||||
//
|
//
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_verdefaux32_lsb() {
|
fn parse_verdefaux32_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF32, VerDefAux {
|
||||||
LittleEndian,
|
vda_name: 0x03020100,
|
||||||
Class::ELF32,
|
vda_next: 0x07060504,
|
||||||
VerDefAux { vda_name: 0x03020100, vda_next: 0x07060504 },
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_verdefaux32_msb() {
|
fn parse_verdefaux32_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF32, VerDefAux {
|
||||||
BigEndian,
|
vda_name: 0x00010203,
|
||||||
Class::ELF32,
|
vda_next: 0x04050607,
|
||||||
VerDefAux { vda_name: 0x00010203, vda_next: 0x04050607 },
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_verdefaux64_lsb() {
|
fn parse_verdefaux64_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF64, VerDefAux {
|
||||||
LittleEndian,
|
vda_name: 0x03020100,
|
||||||
Class::ELF64,
|
vda_next: 0x07060504,
|
||||||
VerDefAux { vda_name: 0x03020100, vda_next: 0x07060504 },
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_verdefaux64_msb() {
|
fn parse_verdefaux64_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF64, VerDefAux {
|
||||||
BigEndian,
|
vda_name: 0x00010203,
|
||||||
Class::ELF64,
|
vda_next: 0x04050607,
|
||||||
VerDefAux { vda_name: 0x00010203, vda_next: 0x04050607 },
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -1299,15 +1256,12 @@ fn parse_verneed32_lsb() {
|
|||||||
let entry = VerNeed::parse_at(LittleEndian, Class::ELF32, &mut offset, data.as_ref())
|
let entry = VerNeed::parse_at(LittleEndian, Class::ELF32, &mut offset, data.as_ref())
|
||||||
.expect("Failed to parse VerNeed");
|
.expect("Failed to parse VerNeed");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(entry, VerNeed {
|
||||||
entry,
|
vn_cnt: 0x0302,
|
||||||
VerNeed {
|
vn_file: 0x07060504,
|
||||||
vn_cnt: 0x0302,
|
vn_aux: 0x0B0A0908,
|
||||||
vn_file: 0x07060504,
|
vn_next: 0x0F0E0D0C,
|
||||||
vn_aux: 0x0B0A0908,
|
});
|
||||||
vn_next: 0x0F0E0D0C,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
assert_eq!(offset, ELFVERNEEDSIZE);
|
assert_eq!(offset, ELFVERNEEDSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1339,15 +1293,12 @@ fn parse_verneed64_msb() {
|
|||||||
let entry = VerNeed::parse_at(BigEndian, Class::ELF64, &mut offset, data.as_ref())
|
let entry = VerNeed::parse_at(BigEndian, Class::ELF64, &mut offset, data.as_ref())
|
||||||
.expect("Failed to parse VerNeed");
|
.expect("Failed to parse VerNeed");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(entry, VerNeed {
|
||||||
entry,
|
vn_cnt: 0x0203,
|
||||||
VerNeed {
|
vn_file: 0x04050607,
|
||||||
vn_cnt: 0x0203,
|
vn_aux: 0x08090A0B,
|
||||||
vn_file: 0x04050607,
|
vn_next: 0x0C0D0E0F,
|
||||||
vn_aux: 0x08090A0B,
|
});
|
||||||
vn_next: 0x0C0D0E0F,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
assert_eq!(offset, ELFVERNEEDSIZE);
|
assert_eq!(offset, ELFVERNEEDSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1372,62 +1323,46 @@ fn parse_verneed64_fuzz_too_short() {
|
|||||||
//
|
//
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_verneedaux32_lsb() {
|
fn parse_verneedaux32_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF32, VerNeedAux {
|
||||||
LittleEndian,
|
vna_hash: 0x03020100,
|
||||||
Class::ELF32,
|
vna_flags: 0x0504,
|
||||||
VerNeedAux {
|
vna_other: 0x0706,
|
||||||
vna_hash: 0x03020100,
|
vna_name: 0x0B0A0908,
|
||||||
vna_flags: 0x0504,
|
vna_next: 0x0F0E0D0C,
|
||||||
vna_other: 0x0706,
|
});
|
||||||
vna_name: 0x0B0A0908,
|
|
||||||
vna_next: 0x0F0E0D0C,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_verneedaux32_msb() {
|
fn parse_verneedaux32_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF32, VerNeedAux {
|
||||||
BigEndian,
|
vna_hash: 0x00010203,
|
||||||
Class::ELF32,
|
vna_flags: 0x0405,
|
||||||
VerNeedAux {
|
vna_other: 0x0607,
|
||||||
vna_hash: 0x00010203,
|
vna_name: 0x08090A0B,
|
||||||
vna_flags: 0x0405,
|
vna_next: 0x0C0D0E0F,
|
||||||
vna_other: 0x0607,
|
});
|
||||||
vna_name: 0x08090A0B,
|
|
||||||
vna_next: 0x0C0D0E0F,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_verneedaux64_lsb() {
|
fn parse_verneedaux64_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF64, VerNeedAux {
|
||||||
LittleEndian,
|
vna_hash: 0x03020100,
|
||||||
Class::ELF64,
|
vna_flags: 0x0504,
|
||||||
VerNeedAux {
|
vna_other: 0x0706,
|
||||||
vna_hash: 0x03020100,
|
vna_name: 0x0B0A0908,
|
||||||
vna_flags: 0x0504,
|
vna_next: 0x0F0E0D0C,
|
||||||
vna_other: 0x0706,
|
});
|
||||||
vna_name: 0x0B0A0908,
|
|
||||||
vna_next: 0x0F0E0D0C,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_verneedaux64_msb() {
|
fn parse_verneedaux64_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF64, VerNeedAux {
|
||||||
BigEndian,
|
vna_hash: 0x00010203,
|
||||||
Class::ELF64,
|
vna_flags: 0x0405,
|
||||||
VerNeedAux {
|
vna_other: 0x0607,
|
||||||
vna_hash: 0x00010203,
|
vna_name: 0x08090A0B,
|
||||||
vna_flags: 0x0405,
|
vna_next: 0x0C0D0E0F,
|
||||||
vna_other: 0x0607,
|
});
|
||||||
vna_name: 0x08090A0B,
|
|
||||||
vna_next: 0x0C0D0E0F,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -316,38 +316,34 @@ mod sysv_parse_tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_sysvhdr32_lsb() {
|
fn parse_sysvhdr32_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF32, SysVHashHeader {
|
||||||
LittleEndian,
|
nbucket: 0x03020100,
|
||||||
Class::ELF32,
|
nchain: 0x07060504,
|
||||||
SysVHashHeader { nbucket: 0x03020100, nchain: 0x07060504 },
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_sysvhdr32_msb() {
|
fn parse_sysvhdr32_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF32, SysVHashHeader {
|
||||||
BigEndian,
|
nbucket: 0x00010203,
|
||||||
Class::ELF32,
|
nchain: 0x04050607,
|
||||||
SysVHashHeader { nbucket: 0x00010203, nchain: 0x04050607 },
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_sysvhdr64_lsb() {
|
fn parse_sysvhdr64_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF64, SysVHashHeader {
|
||||||
LittleEndian,
|
nbucket: 0x03020100,
|
||||||
Class::ELF64,
|
nchain: 0x07060504,
|
||||||
SysVHashHeader { nbucket: 0x03020100, nchain: 0x07060504 },
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_sysvhdr64_msb() {
|
fn parse_sysvhdr64_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF64, SysVHashHeader {
|
||||||
BigEndian,
|
nbucket: 0x00010203,
|
||||||
Class::ELF64,
|
nchain: 0x04050607,
|
||||||
SysVHashHeader { nbucket: 0x00010203, nchain: 0x04050607 },
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -388,58 +384,42 @@ fn gnu_hash_tests() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_gnuhdr32_lsb() {
|
fn parse_gnuhdr32_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF32, GnuHashHeader {
|
||||||
LittleEndian,
|
nbucket: 0x03020100,
|
||||||
Class::ELF32,
|
table_start_idx: 0x07060504,
|
||||||
GnuHashHeader {
|
nbloom: 0x0B0A0908,
|
||||||
nbucket: 0x03020100,
|
nshift: 0x0F0E0D0C,
|
||||||
table_start_idx: 0x07060504,
|
});
|
||||||
nbloom: 0x0B0A0908,
|
|
||||||
nshift: 0x0F0E0D0C,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_gnuhdr32_msb() {
|
fn parse_gnuhdr32_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF32, GnuHashHeader {
|
||||||
BigEndian,
|
nbucket: 0x00010203,
|
||||||
Class::ELF32,
|
table_start_idx: 0x04050607,
|
||||||
GnuHashHeader {
|
nbloom: 0x008090A0B,
|
||||||
nbucket: 0x00010203,
|
nshift: 0x0C0D0E0F,
|
||||||
table_start_idx: 0x04050607,
|
});
|
||||||
nbloom: 0x008090A0B,
|
|
||||||
nshift: 0x0C0D0E0F,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_gnuhdr64_lsb() {
|
fn parse_gnuhdr64_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF64, GnuHashHeader {
|
||||||
LittleEndian,
|
nbucket: 0x03020100,
|
||||||
Class::ELF64,
|
table_start_idx: 0x07060504,
|
||||||
GnuHashHeader {
|
nbloom: 0x0B0A0908,
|
||||||
nbucket: 0x03020100,
|
nshift: 0x0F0E0D0C,
|
||||||
table_start_idx: 0x07060504,
|
});
|
||||||
nbloom: 0x0B0A0908,
|
|
||||||
nshift: 0x0F0E0D0C,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_gnuhdr64_msb() {
|
fn parse_gnuhdr64_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF64, GnuHashHeader {
|
||||||
BigEndian,
|
nbucket: 0x00010203,
|
||||||
Class::ELF64,
|
table_start_idx: 0x04050607,
|
||||||
GnuHashHeader {
|
nbloom: 0x008090A0B,
|
||||||
nbucket: 0x00010203,
|
nshift: 0x0C0D0E0F,
|
||||||
table_start_idx: 0x04050607,
|
});
|
||||||
nbloom: 0x008090A0B,
|
|
||||||
nshift: 0x0C0D0E0F,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -473,46 +473,38 @@ fn parse_note_32_lsb_with_no_desc() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_nhdr32_lsb() {
|
fn parse_nhdr32_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF32, NoteHeader {
|
||||||
LittleEndian,
|
n_namesz: 0x03020100,
|
||||||
Class::ELF32,
|
n_descsz: 0x07060504,
|
||||||
NoteHeader { n_namesz: 0x03020100, n_descsz: 0x07060504, n_type: 0x0B0A0908 },
|
n_type: 0x0B0A0908,
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_nhdr32_msb() {
|
fn parse_nhdr32_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF32, NoteHeader {
|
||||||
BigEndian,
|
n_namesz: 0x00010203,
|
||||||
Class::ELF32,
|
n_descsz: 0x04050607,
|
||||||
NoteHeader { n_namesz: 0x00010203, n_descsz: 0x04050607, n_type: 0x08090A0B },
|
n_type: 0x08090A0B,
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_nhdr64_lsb() {
|
fn parse_nhdr64_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF64, NoteHeader {
|
||||||
LittleEndian,
|
n_namesz: 0x0706050403020100,
|
||||||
Class::ELF64,
|
n_descsz: 0x0F0E0D0C0B0A0908,
|
||||||
NoteHeader {
|
n_type: 0x1716151413121110,
|
||||||
n_namesz: 0x0706050403020100,
|
});
|
||||||
n_descsz: 0x0F0E0D0C0B0A0908,
|
|
||||||
n_type: 0x1716151413121110,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_nhdr64_msb() {
|
fn parse_nhdr64_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF64, NoteHeader {
|
||||||
BigEndian,
|
n_namesz: 0x0001020304050607,
|
||||||
Class::ELF64,
|
n_descsz: 0x08090A0B0C0D0E0F,
|
||||||
NoteHeader {
|
n_type: 0x1011121314151617,
|
||||||
n_namesz: 0x0001020304050607,
|
});
|
||||||
n_descsz: 0x08090A0B0C0D0E0F,
|
|
||||||
n_type: 0x1011121314151617,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -142,38 +142,38 @@ mod parse_tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_rel32_lsb() {
|
fn parse_rel32_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF32, Rel {
|
||||||
LittleEndian,
|
r_offset: 0x03020100,
|
||||||
Class::ELF32,
|
r_sym: 0x00070605,
|
||||||
Rel { r_offset: 0x03020100, r_sym: 0x00070605, r_type: 0x00000004 },
|
r_type: 0x00000004,
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_rel32_msb() {
|
fn parse_rel32_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF32, Rel {
|
||||||
BigEndian,
|
r_offset: 0x00010203,
|
||||||
Class::ELF32,
|
r_sym: 0x00040506,
|
||||||
Rel { r_offset: 0x00010203, r_sym: 0x00040506, r_type: 0x00000007 },
|
r_type: 0x00000007,
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_rel64_lsb() {
|
fn parse_rel64_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF64, Rel {
|
||||||
LittleEndian,
|
r_offset: 0x0706050403020100,
|
||||||
Class::ELF64,
|
r_sym: 0x0F0E0D0C,
|
||||||
Rel { r_offset: 0x0706050403020100, r_sym: 0x0F0E0D0C, r_type: 0x0B0A0908 },
|
r_type: 0x0B0A0908,
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_rel64_msb() {
|
fn parse_rel64_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF64, Rel {
|
||||||
BigEndian,
|
r_offset: 0x0001020304050607,
|
||||||
Class::ELF64,
|
r_sym: 0x08090A0B,
|
||||||
Rel { r_offset: 0x0001020304050607, r_sym: 0x08090A0B, r_type: 0x0C0D0E0F },
|
r_type: 0x0C0D0E0F,
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -198,58 +198,42 @@ fn parse_rel64_msb_fuzz_too_short() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_rela32_lsb() {
|
fn parse_rela32_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF32, Rela {
|
||||||
LittleEndian,
|
r_offset: 0x03020100,
|
||||||
Class::ELF32,
|
r_sym: 0x00070605,
|
||||||
Rela {
|
r_type: 0x00000004,
|
||||||
r_offset: 0x03020100,
|
r_addend: 0x0B0A0908,
|
||||||
r_sym: 0x00070605,
|
});
|
||||||
r_type: 0x00000004,
|
|
||||||
r_addend: 0x0B0A0908,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_rela32_msb() {
|
fn parse_rela32_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF32, Rela {
|
||||||
BigEndian,
|
r_offset: 0x00010203,
|
||||||
Class::ELF32,
|
r_sym: 0x00040506,
|
||||||
Rela {
|
r_type: 0x00000007,
|
||||||
r_offset: 0x00010203,
|
r_addend: 0x08090A0B,
|
||||||
r_sym: 0x00040506,
|
});
|
||||||
r_type: 0x00000007,
|
|
||||||
r_addend: 0x08090A0B,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_rela64_lsb() {
|
fn parse_rela64_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF64, Rela {
|
||||||
LittleEndian,
|
r_offset: 0x0706050403020100,
|
||||||
Class::ELF64,
|
r_sym: 0x0F0E0D0C,
|
||||||
Rela {
|
r_type: 0x0B0A0908,
|
||||||
r_offset: 0x0706050403020100,
|
r_addend: 0x1716151413121110,
|
||||||
r_sym: 0x0F0E0D0C,
|
});
|
||||||
r_type: 0x0B0A0908,
|
|
||||||
r_addend: 0x1716151413121110,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_rela64_msb() {
|
fn parse_rela64_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF64, Rela {
|
||||||
BigEndian,
|
r_offset: 0x0001020304050607,
|
||||||
Class::ELF64,
|
r_sym: 0x08090A0B,
|
||||||
Rela {
|
r_type: 0x0C0D0E0F,
|
||||||
r_offset: 0x0001020304050607,
|
r_addend: 0x1011121314151617,
|
||||||
r_sym: 0x08090A0B,
|
});
|
||||||
r_type: 0x0C0D0E0F,
|
|
||||||
r_addend: 0x1011121314151617,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -131,82 +131,66 @@ mod parse_tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_shdr32_lsb() {
|
fn parse_shdr32_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF32, SectionHeader {
|
||||||
LittleEndian,
|
sh_name: 0x03020100,
|
||||||
Class::ELF32,
|
sh_type: 0x07060504,
|
||||||
SectionHeader {
|
sh_flags: 0xB0A0908,
|
||||||
sh_name: 0x03020100,
|
sh_addr: 0x0F0E0D0C,
|
||||||
sh_type: 0x07060504,
|
sh_offset: 0x13121110,
|
||||||
sh_flags: 0xB0A0908,
|
sh_size: 0x17161514,
|
||||||
sh_addr: 0x0F0E0D0C,
|
sh_link: 0x1B1A1918,
|
||||||
sh_offset: 0x13121110,
|
sh_info: 0x1F1E1D1C,
|
||||||
sh_size: 0x17161514,
|
sh_addralign: 0x23222120,
|
||||||
sh_link: 0x1B1A1918,
|
sh_entsize: 0x27262524,
|
||||||
sh_info: 0x1F1E1D1C,
|
});
|
||||||
sh_addralign: 0x23222120,
|
|
||||||
sh_entsize: 0x27262524,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_shdr32_msb() {
|
fn parse_shdr32_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF32, SectionHeader {
|
||||||
BigEndian,
|
sh_name: 0x00010203,
|
||||||
Class::ELF32,
|
sh_type: 0x04050607,
|
||||||
SectionHeader {
|
sh_flags: 0x08090A0B,
|
||||||
sh_name: 0x00010203,
|
sh_addr: 0x0C0D0E0F,
|
||||||
sh_type: 0x04050607,
|
sh_offset: 0x10111213,
|
||||||
sh_flags: 0x08090A0B,
|
sh_size: 0x14151617,
|
||||||
sh_addr: 0x0C0D0E0F,
|
sh_link: 0x18191A1B,
|
||||||
sh_offset: 0x10111213,
|
sh_info: 0x1C1D1E1F,
|
||||||
sh_size: 0x14151617,
|
sh_addralign: 0x20212223,
|
||||||
sh_link: 0x18191A1B,
|
sh_entsize: 0x24252627,
|
||||||
sh_info: 0x1C1D1E1F,
|
});
|
||||||
sh_addralign: 0x20212223,
|
|
||||||
sh_entsize: 0x24252627,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_shdr64_lsb() {
|
fn parse_shdr64_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF64, SectionHeader {
|
||||||
LittleEndian,
|
sh_name: 0x03020100,
|
||||||
Class::ELF64,
|
sh_type: 0x07060504,
|
||||||
SectionHeader {
|
sh_flags: 0x0F0E0D0C0B0A0908,
|
||||||
sh_name: 0x03020100,
|
sh_addr: 0x1716151413121110,
|
||||||
sh_type: 0x07060504,
|
sh_offset: 0x1F1E1D1C1B1A1918,
|
||||||
sh_flags: 0x0F0E0D0C0B0A0908,
|
sh_size: 0x2726252423222120,
|
||||||
sh_addr: 0x1716151413121110,
|
sh_link: 0x2B2A2928,
|
||||||
sh_offset: 0x1F1E1D1C1B1A1918,
|
sh_info: 0x2F2E2D2C,
|
||||||
sh_size: 0x2726252423222120,
|
sh_addralign: 0x3736353433323130,
|
||||||
sh_link: 0x2B2A2928,
|
sh_entsize: 0x3F3E3D3C3B3A3938,
|
||||||
sh_info: 0x2F2E2D2C,
|
});
|
||||||
sh_addralign: 0x3736353433323130,
|
|
||||||
sh_entsize: 0x3F3E3D3C3B3A3938,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_shdr64_msb() {
|
fn parse_shdr64_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF64, SectionHeader {
|
||||||
BigEndian,
|
sh_name: 0x00010203,
|
||||||
Class::ELF64,
|
sh_type: 0x04050607,
|
||||||
SectionHeader {
|
sh_flags: 0x08090A0B0C0D0E0F,
|
||||||
sh_name: 0x00010203,
|
sh_addr: 0x1011121314151617,
|
||||||
sh_type: 0x04050607,
|
sh_offset: 0x18191A1B1C1D1E1F,
|
||||||
sh_flags: 0x08090A0B0C0D0E0F,
|
sh_size: 0x2021222324252627,
|
||||||
sh_addr: 0x1011121314151617,
|
sh_link: 0x28292A2B,
|
||||||
sh_offset: 0x18191A1B1C1D1E1F,
|
sh_info: 0x2C2D2E2F,
|
||||||
sh_size: 0x2021222324252627,
|
sh_addralign: 0x3031323334353637,
|
||||||
sh_link: 0x28292A2B,
|
sh_entsize: 0x38393A3B3C3D3E3F,
|
||||||
sh_info: 0x2C2D2E2F,
|
});
|
||||||
sh_addralign: 0x3031323334353637,
|
|
||||||
sh_entsize: 0x38393A3B3C3D3E3F,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -131,74 +131,58 @@ mod parse_tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_phdr32_lsb() {
|
fn parse_phdr32_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF32, ProgramHeader {
|
||||||
LittleEndian,
|
p_type: 0x03020100,
|
||||||
Class::ELF32,
|
p_offset: 0x07060504,
|
||||||
ProgramHeader {
|
p_vaddr: 0xB0A0908,
|
||||||
p_type: 0x03020100,
|
p_paddr: 0x0F0E0D0C,
|
||||||
p_offset: 0x07060504,
|
p_filesz: 0x13121110,
|
||||||
p_vaddr: 0xB0A0908,
|
p_memsz: 0x17161514,
|
||||||
p_paddr: 0x0F0E0D0C,
|
p_flags: 0x1B1A1918,
|
||||||
p_filesz: 0x13121110,
|
p_align: 0x1F1E1D1C,
|
||||||
p_memsz: 0x17161514,
|
});
|
||||||
p_flags: 0x1B1A1918,
|
|
||||||
p_align: 0x1F1E1D1C,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_phdr32_msb() {
|
fn parse_phdr32_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF32, ProgramHeader {
|
||||||
BigEndian,
|
p_type: 0x00010203,
|
||||||
Class::ELF32,
|
p_offset: 0x04050607,
|
||||||
ProgramHeader {
|
p_vaddr: 0x08090A0B,
|
||||||
p_type: 0x00010203,
|
p_paddr: 0x0C0D0E0F,
|
||||||
p_offset: 0x04050607,
|
p_filesz: 0x10111213,
|
||||||
p_vaddr: 0x08090A0B,
|
p_memsz: 0x14151617,
|
||||||
p_paddr: 0x0C0D0E0F,
|
p_flags: 0x18191A1B,
|
||||||
p_filesz: 0x10111213,
|
p_align: 0x1C1D1E1F,
|
||||||
p_memsz: 0x14151617,
|
});
|
||||||
p_flags: 0x18191A1B,
|
|
||||||
p_align: 0x1C1D1E1F,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_phdr64_lsb() {
|
fn parse_phdr64_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF64, ProgramHeader {
|
||||||
LittleEndian,
|
p_type: 0x03020100,
|
||||||
Class::ELF64,
|
p_offset: 0x0F0E0D0C0B0A0908,
|
||||||
ProgramHeader {
|
p_vaddr: 0x1716151413121110,
|
||||||
p_type: 0x03020100,
|
p_paddr: 0x1F1E1D1C1B1A1918,
|
||||||
p_offset: 0x0F0E0D0C0B0A0908,
|
p_filesz: 0x2726252423222120,
|
||||||
p_vaddr: 0x1716151413121110,
|
p_memsz: 0x2F2E2D2C2B2A2928,
|
||||||
p_paddr: 0x1F1E1D1C1B1A1918,
|
p_flags: 0x07060504,
|
||||||
p_filesz: 0x2726252423222120,
|
p_align: 0x3736353433323130,
|
||||||
p_memsz: 0x2F2E2D2C2B2A2928,
|
});
|
||||||
p_flags: 0x07060504,
|
|
||||||
p_align: 0x3736353433323130,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_phdr64_msb() {
|
fn parse_phdr64_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF64, ProgramHeader {
|
||||||
BigEndian,
|
p_type: 0x00010203,
|
||||||
Class::ELF64,
|
p_offset: 0x08090A0B0C0D0E0F,
|
||||||
ProgramHeader {
|
p_vaddr: 0x1011121314151617,
|
||||||
p_type: 0x00010203,
|
p_paddr: 0x18191A1B1C1D1E1F,
|
||||||
p_offset: 0x08090A0B0C0D0E0F,
|
p_filesz: 0x2021222324252627,
|
||||||
p_vaddr: 0x1011121314151617,
|
p_memsz: 0x28292A2B2C2D2E2F,
|
||||||
p_paddr: 0x18191A1B1C1D1E1F,
|
p_flags: 0x04050607,
|
||||||
p_filesz: 0x2021222324252627,
|
p_align: 0x3031323334353637,
|
||||||
p_memsz: 0x28292A2B2C2D2E2F,
|
});
|
||||||
p_flags: 0x04050607,
|
|
||||||
p_align: 0x3031323334353637,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -168,66 +168,50 @@ mod parse_tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_sym32_lsb() {
|
fn parse_sym32_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF32, Symbol {
|
||||||
LittleEndian,
|
st_name: 0x03020100,
|
||||||
Class::ELF32,
|
st_value: 0x07060504,
|
||||||
Symbol {
|
st_size: 0x0B0A0908,
|
||||||
st_name: 0x03020100,
|
st_shndx: 0x0F0E,
|
||||||
st_value: 0x07060504,
|
st_info: 0x0C,
|
||||||
st_size: 0x0B0A0908,
|
st_other: 0x0D,
|
||||||
st_shndx: 0x0F0E,
|
});
|
||||||
st_info: 0x0C,
|
|
||||||
st_other: 0x0D,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_sym32_msb() {
|
fn parse_sym32_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF32, Symbol {
|
||||||
BigEndian,
|
st_name: 0x00010203,
|
||||||
Class::ELF32,
|
st_value: 0x04050607,
|
||||||
Symbol {
|
st_size: 0x08090A0B,
|
||||||
st_name: 0x00010203,
|
st_shndx: 0x0E0F,
|
||||||
st_value: 0x04050607,
|
st_info: 0x0C,
|
||||||
st_size: 0x08090A0B,
|
st_other: 0x0D,
|
||||||
st_shndx: 0x0E0F,
|
});
|
||||||
st_info: 0x0C,
|
|
||||||
st_other: 0x0D,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_sym64_lsb() {
|
fn parse_sym64_lsb() {
|
||||||
test_parse_for(
|
test_parse_for(LittleEndian, Class::ELF64, Symbol {
|
||||||
LittleEndian,
|
st_name: 0x03020100,
|
||||||
Class::ELF64,
|
st_value: 0x0F0E0D0C0B0A0908,
|
||||||
Symbol {
|
st_size: 0x1716151413121110,
|
||||||
st_name: 0x03020100,
|
st_shndx: 0x0706,
|
||||||
st_value: 0x0F0E0D0C0B0A0908,
|
st_info: 0x04,
|
||||||
st_size: 0x1716151413121110,
|
st_other: 0x05,
|
||||||
st_shndx: 0x0706,
|
});
|
||||||
st_info: 0x04,
|
|
||||||
st_other: 0x05,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_sym64_msb() {
|
fn parse_sym64_msb() {
|
||||||
test_parse_for(
|
test_parse_for(BigEndian, Class::ELF64, Symbol {
|
||||||
BigEndian,
|
st_name: 0x00010203,
|
||||||
Class::ELF64,
|
st_value: 0x08090A0B0C0D0E0F,
|
||||||
Symbol {
|
st_size: 0x1011121314151617,
|
||||||
st_name: 0x00010203,
|
st_shndx: 0x0607,
|
||||||
st_value: 0x08090A0B0C0D0E0F,
|
st_info: 0x04,
|
||||||
st_size: 0x1011121314151617,
|
st_other: 0x05,
|
||||||
st_shndx: 0x0607,
|
});
|
||||||
st_info: 0x04,
|
|
||||||
st_other: 0x05,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -19,8 +19,8 @@ mod musl_reference_tests {
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::{env, fs};
|
use std::{env, fs};
|
||||||
|
|
||||||
use rand::seq::SliceRandom;
|
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
use rand::seq::SliceRandom;
|
||||||
|
|
||||||
// Number of tests to generate for each function
|
// Number of tests to generate for each function
|
||||||
const NTESTS: usize = 500;
|
const NTESTS: usize = 500;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
use core::ptr::read_volatile;
|
use core::ptr::read_volatile;
|
||||||
|
|
||||||
use super::fenv::{
|
use super::fenv::{
|
||||||
feclearexcept, fegetround, feraiseexcept, fetestexcept, FE_INEXACT, FE_TONEAREST, FE_UNDERFLOW,
|
FE_INEXACT, FE_TONEAREST, FE_UNDERFLOW, feclearexcept, fegetround, feraiseexcept, fetestexcept,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -221,10 +221,10 @@ macro_rules! llvm_intrinsically_optimized {
|
|||||||
pub use self::erf::{erf, erfc};
|
pub use self::erf::{erf, erfc};
|
||||||
pub use self::erff::{erfcf, erff};
|
pub use self::erff::{erfcf, erff};
|
||||||
pub use self::exp::exp;
|
pub use self::exp::exp;
|
||||||
pub use self::exp10::exp10;
|
|
||||||
pub use self::exp10f::exp10f;
|
|
||||||
pub use self::exp2::exp2;
|
pub use self::exp2::exp2;
|
||||||
pub use self::exp2f::exp2f;
|
pub use self::exp2f::exp2f;
|
||||||
|
pub use self::exp10::exp10;
|
||||||
|
pub use self::exp10f::exp10f;
|
||||||
pub use self::expf::expf;
|
pub use self::expf::expf;
|
||||||
pub use self::expm1::expm1;
|
pub use self::expm1::expm1;
|
||||||
pub use self::expm1f::expm1f;
|
pub use self::expm1f::expm1f;
|
||||||
@ -261,12 +261,12 @@ macro_rules! llvm_intrinsically_optimized {
|
|||||||
pub use self::lgammaf::lgammaf;
|
pub use self::lgammaf::lgammaf;
|
||||||
pub use self::lgammaf_r::lgammaf_r;
|
pub use self::lgammaf_r::lgammaf_r;
|
||||||
pub use self::log::log;
|
pub use self::log::log;
|
||||||
pub use self::log10::log10;
|
|
||||||
pub use self::log10f::log10f;
|
|
||||||
pub use self::log1p::log1p;
|
pub use self::log1p::log1p;
|
||||||
pub use self::log1pf::log1pf;
|
pub use self::log1pf::log1pf;
|
||||||
pub use self::log2::log2;
|
pub use self::log2::log2;
|
||||||
pub use self::log2f::log2f;
|
pub use self::log2f::log2f;
|
||||||
|
pub use self::log10::log10;
|
||||||
|
pub use self::log10f::log10f;
|
||||||
pub use self::logf::logf;
|
pub use self::logf::logf;
|
||||||
pub use self::modf::modf;
|
pub use self::modf::modf;
|
||||||
pub use self::modff::modff;
|
pub use self::modff::modff;
|
||||||
|
@ -42,32 +42,28 @@ pub enum Error {
|
|||||||
impl Display for Error {
|
impl Display for Error {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
|
||||||
use Error::*;
|
use Error::*;
|
||||||
write!(
|
write!(f, "{}", match self {
|
||||||
f,
|
WontImplement => "This is a feature that PostCard will never implement",
|
||||||
"{}",
|
NotYetImplemented => {
|
||||||
match self {
|
"This is a feature that Postcard intends to support, but does not yet"
|
||||||
WontImplement => "This is a feature that PostCard will never implement",
|
|
||||||
NotYetImplemented => {
|
|
||||||
"This is a feature that Postcard intends to support, but does not yet"
|
|
||||||
}
|
|
||||||
SerializeBufferFull => "The serialize buffer is full",
|
|
||||||
SerializeSeqLengthUnknown => "The length of a sequence must be known",
|
|
||||||
DeserializeUnexpectedEnd => "Hit the end of buffer, expected more data",
|
|
||||||
DeserializeBadVarint => {
|
|
||||||
"Found a varint that didn't terminate. Is the usize too big for this platform?"
|
|
||||||
}
|
|
||||||
DeserializeBadBool => "Found a bool that wasn't 0 or 1",
|
|
||||||
DeserializeBadChar => "Found an invalid unicode char",
|
|
||||||
DeserializeBadUtf8 => "Tried to parse invalid utf-8",
|
|
||||||
DeserializeBadOption => "Found an Option discriminant that wasn't 0 or 1",
|
|
||||||
DeserializeBadEnum => "Found an enum discriminant that was > u32::max_value()",
|
|
||||||
DeserializeBadEncoding => "The original data was not well encoded",
|
|
||||||
DeserializeBadCrc => "Bad CRC while deserializing",
|
|
||||||
SerdeSerCustom => "Serde Serialization Error",
|
|
||||||
SerdeDeCustom => "Serde Deserialization Error",
|
|
||||||
CollectStrError => "Error while processing `collect_str` during serialization",
|
|
||||||
}
|
}
|
||||||
)
|
SerializeBufferFull => "The serialize buffer is full",
|
||||||
|
SerializeSeqLengthUnknown => "The length of a sequence must be known",
|
||||||
|
DeserializeUnexpectedEnd => "Hit the end of buffer, expected more data",
|
||||||
|
DeserializeBadVarint => {
|
||||||
|
"Found a varint that didn't terminate. Is the usize too big for this platform?"
|
||||||
|
}
|
||||||
|
DeserializeBadBool => "Found a bool that wasn't 0 or 1",
|
||||||
|
DeserializeBadChar => "Found an invalid unicode char",
|
||||||
|
DeserializeBadUtf8 => "Tried to parse invalid utf-8",
|
||||||
|
DeserializeBadOption => "Found an Option discriminant that wasn't 0 or 1",
|
||||||
|
DeserializeBadEnum => "Found an enum discriminant that was > u32::max_value()",
|
||||||
|
DeserializeBadEncoding => "The original data was not well encoded",
|
||||||
|
DeserializeBadCrc => "Bad CRC while deserializing",
|
||||||
|
SerdeSerCustom => "Serde Serialization Error",
|
||||||
|
SerdeDeCustom => "Serde Deserialization Error",
|
||||||
|
CollectStrError => "Error while processing `collect_str` during serialization",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use core::num::{
|
use core::num::{
|
||||||
NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize, NonZeroU128,
|
NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI128, NonZeroIsize, NonZeroU8,
|
||||||
NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize,
|
NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::varint::varint_max;
|
use crate::varint::varint_max;
|
||||||
|
@ -556,7 +556,7 @@ pub mod crc {
|
|||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
use super::alloc;
|
use super::alloc;
|
||||||
use super::{Flavor, Slice};
|
use super::{Flavor, Slice};
|
||||||
use crate::{serialize_with_flavor, Result};
|
use crate::{Result, serialize_with_flavor};
|
||||||
|
|
||||||
/// Manages CRC modifications as a flavor.
|
/// Manages CRC modifications as a flavor.
|
||||||
pub struct CrcModifier<'a, B, W>
|
pub struct CrcModifier<'a, B, W>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use serde::{ser, Serialize};
|
use serde::{Serialize, ser};
|
||||||
|
|
||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
use crate::ser::flavors::Flavor;
|
use crate::ser::flavors::Flavor;
|
||||||
|
@ -2425,11 +2425,11 @@ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
let (start, end) = tri!(deserializer.deserialize_struct(
|
let (start, end) =
|
||||||
"Range",
|
tri!(deserializer.deserialize_struct("Range", range::FIELDS, range::RangeVisitor {
|
||||||
range::FIELDS,
|
expecting: "struct Range",
|
||||||
range::RangeVisitor { expecting: "struct Range", phantom: PhantomData },
|
phantom: PhantomData
|
||||||
));
|
},));
|
||||||
Ok(start..end)
|
Ok(start..end)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use self::private::{First, Second};
|
use self::private::{First, Second};
|
||||||
use crate::de::{self, size_hint, Deserializer, Expected, IntoDeserializer, SeqAccess, Visitor};
|
use crate::de::{self, Deserializer, Expected, IntoDeserializer, SeqAccess, Visitor, size_hint};
|
||||||
use crate::lib::*;
|
use crate::lib::*;
|
||||||
use crate::ser;
|
use crate::ser;
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ mod core {
|
|||||||
pub use std::sync::atomic::Ordering;
|
pub use std::sync::atomic::Ordering;
|
||||||
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
|
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
|
||||||
pub use std::sync::atomic::{
|
pub use std::sync::atomic::{
|
||||||
AtomicBool, AtomicI16, AtomicI32, AtomicI8, AtomicIsize, AtomicU16, AtomicU32, AtomicU8,
|
AtomicBool, AtomicI8, AtomicI16, AtomicI32, AtomicIsize, AtomicU8, AtomicU16, AtomicU32,
|
||||||
AtomicUsize, Ordering,
|
AtomicUsize, Ordering,
|
||||||
};
|
};
|
||||||
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "8"))]
|
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "8"))]
|
||||||
@ -256,8 +256,8 @@ mod core {
|
|||||||
pub use self::core::ops::{Bound, Range, RangeFrom, RangeInclusive, RangeTo};
|
pub use self::core::ops::{Bound, Range, RangeFrom, RangeInclusive, RangeTo};
|
||||||
pub use self::core::time::Duration;
|
pub use self::core::time::Duration;
|
||||||
pub use self::core::{
|
pub use self::core::{
|
||||||
clone, convert, default, f32, f64, i16, i32, i64, i8, isize, iter, num, option, ptr,
|
clone, convert, default, f32, f64, i8, i16, i32, i64, isize, iter, num, option, ptr,
|
||||||
result, str, u16, u32, u64, u8, usize,
|
result, str, u8, u16, u32, u64, usize,
|
||||||
};
|
};
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub use self::core::{cmp, mem, slice};
|
pub use self::core::{cmp, mem, slice};
|
||||||
|
@ -200,8 +200,8 @@ mod content {
|
|||||||
use crate::actually_private;
|
use crate::actually_private;
|
||||||
use crate::de::value::{MapDeserializer, SeqDeserializer};
|
use crate::de::value::{MapDeserializer, SeqDeserializer};
|
||||||
use crate::de::{
|
use crate::de::{
|
||||||
self, size_hint, Deserialize, DeserializeSeed, Deserializer, EnumAccess, Expected,
|
self, Deserialize, DeserializeSeed, Deserializer, EnumAccess, Expected, IgnoredAny,
|
||||||
IgnoredAny, MapAccess, SeqAccess, Unexpected, Visitor,
|
MapAccess, SeqAccess, Unexpected, Visitor, size_hint,
|
||||||
};
|
};
|
||||||
use crate::lib::*;
|
use crate::lib::*;
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
use core::arch::asm;
|
use core::arch::asm;
|
||||||
|
|
||||||
use crate::registers::model_specific::{FsBase, GsBase, Msr};
|
|
||||||
pub use crate::registers::segmentation::{Segment, Segment64, CS, DS, ES, FS, GS, SS};
|
|
||||||
use crate::structures::gdt::SegmentSelector;
|
|
||||||
use crate::VirtAddr;
|
use crate::VirtAddr;
|
||||||
|
use crate::registers::model_specific::{FsBase, GsBase, Msr};
|
||||||
|
pub use crate::registers::segmentation::{CS, DS, ES, FS, GS, SS, Segment, Segment64};
|
||||||
|
use crate::structures::gdt::SegmentSelector;
|
||||||
|
|
||||||
macro_rules! get_reg_impl {
|
macro_rules! get_reg_impl {
|
||||||
($name:literal) => {
|
($name:literal) => {
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
use core::arch::asm;
|
use core::arch::asm;
|
||||||
|
|
||||||
use crate::structures::gdt::SegmentSelector;
|
|
||||||
pub use crate::structures::DescriptorTablePointer;
|
|
||||||
use crate::VirtAddr;
|
use crate::VirtAddr;
|
||||||
|
pub use crate::structures::DescriptorTablePointer;
|
||||||
|
use crate::structures::gdt::SegmentSelector;
|
||||||
|
|
||||||
/// Load a GDT.
|
/// Load a GDT.
|
||||||
///
|
///
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
use bit_field::BitField;
|
use bit_field::BitField;
|
||||||
|
|
||||||
use crate::instructions::segmentation::{Segment, CS};
|
use crate::instructions::segmentation::{CS, Segment};
|
||||||
use crate::structures::paging::page::{NotGiantPageSize, PageRange};
|
use crate::structures::paging::page::{NotGiantPageSize, PageRange};
|
||||||
use crate::structures::paging::{Page, PageSize, Size2MiB, Size4KiB};
|
use crate::structures::paging::{Page, PageSize, Size2MiB, Size4KiB};
|
||||||
use crate::{PrivilegeLevel, VirtAddr};
|
use crate::{PrivilegeLevel, VirtAddr};
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#![allow(elided_lifetimes_in_paths)]
|
#![allow(elided_lifetimes_in_paths)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
pub use crate::addr::{align_down, align_up, PhysAddr, VirtAddr};
|
pub use crate::addr::{PhysAddr, VirtAddr, align_down, align_up};
|
||||||
|
|
||||||
pub mod addr;
|
pub mod addr;
|
||||||
pub mod instructions;
|
pub mod instructions;
|
||||||
|
@ -164,17 +164,17 @@ mod x86_64 {
|
|||||||
use bit_field::BitField;
|
use bit_field::BitField;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::PrivilegeLevel;
|
||||||
use crate::addr::VirtAddr;
|
use crate::addr::VirtAddr;
|
||||||
use crate::registers::rflags::RFlags;
|
use crate::registers::rflags::RFlags;
|
||||||
// imports for intra doc links
|
// imports for intra doc links
|
||||||
#[cfg(doc)]
|
#[cfg(doc)]
|
||||||
use crate::registers::{
|
use crate::registers::{
|
||||||
control::Cr4Flags,
|
control::Cr4Flags,
|
||||||
segmentation::{Segment, Segment64, CS, SS},
|
segmentation::{CS, SS, Segment, Segment64},
|
||||||
};
|
};
|
||||||
use crate::structures::gdt::SegmentSelector;
|
use crate::structures::gdt::SegmentSelector;
|
||||||
use crate::structures::paging::{Page, Size4KiB};
|
use crate::structures::paging::{Page, Size4KiB};
|
||||||
use crate::PrivilegeLevel;
|
|
||||||
|
|
||||||
impl Msr {
|
impl Msr {
|
||||||
/// Read 64 bits msr register.
|
/// Read 64 bits msr register.
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
use bit_field::BitField;
|
use bit_field::BitField;
|
||||||
|
|
||||||
use super::model_specific::Msr;
|
use super::model_specific::Msr;
|
||||||
|
use crate::{PrivilegeLevel, VirtAddr};
|
||||||
// imports for intra doc links
|
// imports for intra doc links
|
||||||
#[cfg(doc)]
|
#[cfg(doc)]
|
||||||
use crate::{
|
use crate::{
|
||||||
registers::control::Cr4Flags,
|
registers::control::Cr4Flags,
|
||||||
structures::gdt::{Descriptor, DescriptorFlags, GlobalDescriptorTable},
|
structures::gdt::{Descriptor, DescriptorFlags, GlobalDescriptorTable},
|
||||||
};
|
};
|
||||||
use crate::{PrivilegeLevel, VirtAddr};
|
|
||||||
|
|
||||||
/// An x86 segment
|
/// An x86 segment
|
||||||
///
|
///
|
||||||
|
@ -9,12 +9,12 @@
|
|||||||
#[cfg(not(feature = "instructions"))]
|
#[cfg(not(feature = "instructions"))]
|
||||||
use u64 as EntryValue;
|
use u64 as EntryValue;
|
||||||
|
|
||||||
|
use crate::PrivilegeLevel;
|
||||||
pub use crate::registers::segmentation::SegmentSelector;
|
pub use crate::registers::segmentation::SegmentSelector;
|
||||||
// imports for intra-doc links
|
// imports for intra-doc links
|
||||||
#[cfg(doc)]
|
#[cfg(doc)]
|
||||||
use crate::registers::segmentation::{Segment, CS, SS};
|
use crate::registers::segmentation::{CS, SS, Segment};
|
||||||
use crate::structures::tss::TaskStateSegment;
|
use crate::structures::tss::TaskStateSegment;
|
||||||
use crate::PrivilegeLevel;
|
|
||||||
|
|
||||||
/// 8-byte entry in a descriptor table.
|
/// 8-byte entry in a descriptor table.
|
||||||
///
|
///
|
||||||
|
@ -788,7 +788,7 @@ pub const fn missing() -> Self {
|
|||||||
#[cfg(feature = "instructions")]
|
#[cfg(feature = "instructions")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn set_handler_addr(&mut self, addr: VirtAddr) -> &mut EntryOptions {
|
pub unsafe fn set_handler_addr(&mut self, addr: VirtAddr) -> &mut EntryOptions {
|
||||||
use crate::instructions::segmentation::{Segment, CS};
|
use crate::instructions::segmentation::{CS, Segment};
|
||||||
|
|
||||||
let addr = addr.as_u64();
|
let addr = addr.as_u64();
|
||||||
self.pointer_low = addr as u16;
|
self.pointer_low = addr as u16;
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
use core::ops::{Add, AddAssign, Sub, SubAssign};
|
use core::ops::{Add, AddAssign, Sub, SubAssign};
|
||||||
|
|
||||||
use super::page::AddressNotAligned;
|
use super::page::AddressNotAligned;
|
||||||
use crate::structures::paging::page::{PageSize, Size4KiB};
|
|
||||||
use crate::PhysAddr;
|
use crate::PhysAddr;
|
||||||
|
use crate::structures::paging::page::{PageSize, Size4KiB};
|
||||||
|
|
||||||
/// A physical memory frame.
|
/// A physical memory frame.
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::VirtAddr;
|
||||||
use crate::registers::control::Cr3;
|
use crate::registers::control::Cr3;
|
||||||
use crate::structures::paging::frame_alloc::FrameAllocator;
|
use crate::structures::paging::frame_alloc::FrameAllocator;
|
||||||
use crate::structures::paging::page::{AddressNotAligned, NotGiantPageSize, PageRangeInclusive};
|
use crate::structures::paging::page::{AddressNotAligned, NotGiantPageSize, PageRangeInclusive};
|
||||||
@ -12,7 +13,6 @@
|
|||||||
use crate::structures::paging::{
|
use crate::structures::paging::{
|
||||||
FrameDeallocator, Page, PageSize, PageTableIndex, PhysFrame, Size1GiB, Size2MiB, Size4KiB,
|
FrameDeallocator, Page, PageSize, PageTableIndex, PhysFrame, Size1GiB, Size2MiB, Size4KiB,
|
||||||
};
|
};
|
||||||
use crate::VirtAddr;
|
|
||||||
|
|
||||||
/// A recursive page table is a last level page table with an entry mapped to the table itself.
|
/// A recursive page table is a last level page table with an entry mapped to the table itself.
|
||||||
///
|
///
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use core::ops::{Add, AddAssign, Sub, SubAssign};
|
use core::ops::{Add, AddAssign, Sub, SubAssign};
|
||||||
|
|
||||||
use crate::sealed::Sealed;
|
|
||||||
use crate::structures::paging::page_table::PageTableLevel;
|
|
||||||
use crate::structures::paging::PageTableIndex;
|
|
||||||
use crate::VirtAddr;
|
use crate::VirtAddr;
|
||||||
|
use crate::sealed::Sealed;
|
||||||
|
use crate::structures::paging::PageTableIndex;
|
||||||
|
use crate::structures::paging::page_table::PageTableLevel;
|
||||||
|
|
||||||
/// Trait for abstracting over the three possible page sizes on x86_64, 4KiB, 2MiB, 1GiB.
|
/// Trait for abstracting over the three possible page sizes on x86_64, 4KiB, 2MiB, 1GiB.
|
||||||
pub trait PageSize: Copy + Eq + PartialOrd + Ord + Sealed {
|
pub trait PageSize: Copy + Eq + PartialOrd + Ord + Sealed {
|
||||||
|
@ -87,27 +87,31 @@ fn new_cc_build(build: &Build, target: TargetSelection) -> cc::Build {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn find(build: &Build) {
|
pub fn find(build: &Build) {
|
||||||
let targets: HashSet<_> = match build.config.cmd {
|
// Commit 94fbe141558b94fbe141558b is just wrong. This breaks fmt for mikros, so undo it.
|
||||||
// We don't need to check cross targets for these commands.
|
//let targets: HashSet<_> = match build.config.cmd {
|
||||||
crate::Subcommand::Clean { .. }
|
// // We don't need to check cross targets for these commands.
|
||||||
| crate::Subcommand::Suggest { .. }
|
// crate::Subcommand::Clean { .. }
|
||||||
| crate::Subcommand::Format { .. }
|
// | crate::Subcommand::Suggest { .. }
|
||||||
| crate::Subcommand::Setup { .. } => {
|
// | crate::Subcommand::Format { .. }
|
||||||
build.hosts.iter().cloned().chain(iter::once(build.build)).collect()
|
// | crate::Subcommand::Setup { .. } => {
|
||||||
}
|
// build.hosts.iter().cloned().chain(iter::once(build.build)).collect()
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// _ => {
|
||||||
|
// // For all targets we're going to need a C compiler for building some shims
|
||||||
|
// // and such as well as for being a linker for Rust code.
|
||||||
|
// build
|
||||||
|
// .targets
|
||||||
|
// .iter()
|
||||||
|
// .chain(&build.hosts)
|
||||||
|
// .cloned()
|
||||||
|
// .chain(iter::once(build.build))
|
||||||
|
// .collect()
|
||||||
|
// }
|
||||||
|
//};
|
||||||
|
|
||||||
_ => {
|
let targets: HashSet<_> =
|
||||||
// For all targets we're going to need a C compiler for building some shims
|
build.targets.iter().chain(&build.hosts).cloned().chain(iter::once(build.build)).collect();
|
||||||
// and such as well as for being a linker for Rust code.
|
|
||||||
build
|
|
||||||
.targets
|
|
||||||
.iter()
|
|
||||||
.chain(&build.hosts)
|
|
||||||
.cloned()
|
|
||||||
.chain(iter::once(build.build))
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for target in targets.into_iter() {
|
for target in targets.into_iter() {
|
||||||
find_target(build, target);
|
find_target(build, target);
|
||||||
|
Loading…
Reference in New Issue
Block a user