Update to latest rustc

This commit is contained in:
pjht 2024-09-27 18:23:56 -05:00
parent cf4c629a2b
commit a94d4d57de
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E
42 changed files with 692 additions and 878 deletions

View File

@ -1,4 +1,4 @@
use crate::spec::{base, PanicStrategy, Target, TargetMetadata};
use crate::spec::{PanicStrategy, Target, TargetMetadata, base};
pub(crate) fn target() -> Target {
let mut base = base::mikros::opts();

View File

@ -1,13 +1,13 @@
#![stable(feature = "mikros", since = "1.80.0")]
use elf::ElfBytes;
use elf::abi::{
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,
};
use elf::endian::AnyEndian;
use elf::ElfBytes;
use x86_64::structures::paging::Page;
use x86_64::VirtAddr;
use x86_64::structures::paging::Page;
use super::address_space::AddressSpace;
use crate::ptr;

View File

@ -1,7 +1,7 @@
use core::alloc::Layout;
use core::mem;
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};

View File

@ -32,7 +32,3 @@ pub fn decode_error_kind(_code: i32) -> crate::io::ErrorKind {
pub fn abort_internal() -> ! {
core::intrinsics::abort();
}
pub fn hashmap_random_keys() -> (u64, u64) {
(1, 2)
}

View File

@ -3,8 +3,8 @@
use super::syscalls;
use crate::io;
use crate::os::mikros::ipc::rpc;
use crate::sync::atomic::AtomicUsize;
use crate::sync::OnceLock;
use crate::sync::atomic::AtomicUsize;
pub(crate) static STDIN_FD: OnceLock<Option<(u64, u64)>> = OnceLock::new();
pub(crate) static STDOUT_FD: OnceLock<Option<(u64, u64)>> = OnceLock::new();

View File

@ -71,7 +71,7 @@
pub use zkvm::fill_bytes;
} else if #[cfg(any(
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: add random data generation to xous
@ -85,6 +85,7 @@
target_os = "android",
all(target_family = "wasm", target_os = "unknown"),
target_os = "xous",
target_os = "mikros",
)))]
pub fn hashmap_random_keys() -> (u64, u64) {
let mut buf = [0; 16];

View File

@ -2,10 +2,10 @@
extern crate quickcheck;
use cobs::{
decode, decode_vec, decode_vec_with_sentinel, encode, encode_vec, encode_vec_with_sentinel,
max_encoding_length, CobsDecoder, CobsEncoder,
CobsDecoder, CobsEncoder, decode, decode_vec, decode_vec_with_sentinel, encode, encode_vec,
encode_vec_with_sentinel, max_encoding_length,
};
use quickcheck::{quickcheck, TestResult};
use quickcheck::{TestResult, quickcheck};
fn test_pair(source: Vec<u8>, encoded: Vec<u8>) {
let mut test_encoded = encoded.clone();

View File

@ -81,54 +81,38 @@ mod parse_tests {
#[test]
fn parse_chdr32_lsb() {
test_parse_for(
LittleEndian,
Class::ELF32,
CompressionHeader {
ch_type: 0x03020100,
ch_size: 0x07060504,
ch_addralign: 0x0B0A0908,
},
);
test_parse_for(LittleEndian, Class::ELF32, CompressionHeader {
ch_type: 0x03020100,
ch_size: 0x07060504,
ch_addralign: 0x0B0A0908,
});
}
#[test]
fn parse_chdr32_msb() {
test_parse_for(
BigEndian,
Class::ELF32,
CompressionHeader {
ch_type: 0x00010203,
ch_size: 0x04050607,
ch_addralign: 0x08090A0B,
},
);
test_parse_for(BigEndian, Class::ELF32, CompressionHeader {
ch_type: 0x00010203,
ch_size: 0x04050607,
ch_addralign: 0x08090A0B,
});
}
#[test]
fn parse_chdr64_lsb() {
test_parse_for(
LittleEndian,
Class::ELF64,
CompressionHeader {
ch_type: 0x03020100,
ch_size: 0x0F0E0D0C0B0A0908,
ch_addralign: 0x1716151413121110,
},
);
test_parse_for(LittleEndian, Class::ELF64, CompressionHeader {
ch_type: 0x03020100,
ch_size: 0x0F0E0D0C0B0A0908,
ch_addralign: 0x1716151413121110,
});
}
#[test]
fn parse_chdr64_msb() {
test_parse_for(
BigEndian,
Class::ELF64,
CompressionHeader {
ch_type: 0x00010203,
ch_size: 0x08090A0B0C0D0E0F,
ch_addralign: 0x1011121314151617,
},
);
test_parse_for(BigEndian, Class::ELF64, CompressionHeader {
ch_type: 0x00010203,
ch_size: 0x08090A0B0C0D0E0F,
ch_addralign: 0x1011121314151617,
});
}
#[test]

View File

@ -89,20 +89,18 @@ fn parse_dyn32_msb() {
#[test]
fn parse_dyn64_lsb() {
test_parse_for(
LittleEndian,
Class::ELF64,
Dyn { d_tag: 0x0706050403020100, d_un: 0x0F0E0D0C0B0A0908 },
);
test_parse_for(LittleEndian, Class::ELF64, Dyn {
d_tag: 0x0706050403020100,
d_un: 0x0F0E0D0C0B0A0908,
});
}
#[test]
fn parse_dyn64_msb() {
test_parse_for(
BigEndian,
Class::ELF64,
Dyn { d_tag: 0x0001020304050607, d_un: 0x08090A0B0C0D0E0F },
);
test_parse_for(BigEndian, Class::ELF64, Dyn {
d_tag: 0x0001020304050607,
d_un: 0x08090A0B0C0D0E0F,
});
}
#[test]

View File

@ -2,7 +2,7 @@
use crate::compression::CompressionHeader;
use crate::dynamic::{Dyn, DynamicTable};
use crate::endian::EndianParse;
use crate::file::{parse_ident, Class, FileHeader};
use crate::file::{Class, FileHeader, parse_ident};
use crate::gnu_symver::{
SymbolVersionTable, VerDefIterator, VerNeedIterator, VersionIndex, VersionIndexTable,
};
@ -807,19 +807,16 @@ fn segments() {
let segments: Vec<ProgramHeader> =
file.segments().expect("File should have a segment table").iter().collect();
assert_eq!(
segments[0],
ProgramHeader {
p_type: abi::PT_PHDR,
p_offset: 64,
p_vaddr: 4194368,
p_paddr: 4194368,
p_filesz: 448,
p_memsz: 448,
p_flags: 5,
p_align: 8,
}
);
assert_eq!(segments[0], ProgramHeader {
p_type: abi::PT_PHDR,
p_offset: 64,
p_vaddr: 4194368,
p_paddr: 4194368,
p_filesz: 448,
p_memsz: 448,
p_flags: 5,
p_align: 8,
});
}
#[test]
@ -831,19 +828,16 @@ fn segments_phnum_in_shdr0() {
let segments: Vec<ProgramHeader> =
file.segments().expect("File should have a segment table").iter().collect();
assert_eq!(
segments[0],
ProgramHeader {
p_type: abi::PT_PHDR,
p_offset: 92,
p_vaddr: 0,
p_paddr: 0,
p_filesz: 32,
p_memsz: 32,
p_flags: 0x20003,
p_align: 0x40000,
}
);
assert_eq!(segments[0], ProgramHeader {
p_type: abi::PT_PHDR,
p_offset: 92,
p_vaddr: 0,
p_paddr: 0,
p_filesz: 32,
p_memsz: 32,
p_flags: 0x20003,
p_align: 0x40000,
});
}
#[test]
@ -1034,14 +1028,18 @@ fn section_data_as_relas() {
.expect("Failed to get rela shdr");
let mut relas = file.section_data_as_relas(&shdr).expect("Failed to read relas section");
assert_eq!(
relas.next().expect("Failed to get rela entry"),
Rela { r_offset: 6293704, r_sym: 1, 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_eq!(relas.next().expect("Failed to get rela entry"), Rela {
r_offset: 6293704,
r_sym: 1,
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());
}
@ -1106,14 +1104,14 @@ fn dynamic() {
.expect("Failed to parse .dynamic")
.expect("Failed to find .dynamic")
.iter();
assert_eq!(
dynamic.next().expect("Failed to get dyn entry"),
Dyn { d_tag: abi::DT_NEEDED, d_un: 1 }
);
assert_eq!(
dynamic.next().expect("Failed to get dyn entry"),
Dyn { d_tag: abi::DT_INIT, d_un: 4195216 }
);
assert_eq!(dynamic.next().expect("Failed to get dyn entry"), Dyn {
d_tag: abi::DT_NEEDED,
d_un: 1
});
assert_eq!(dynamic.next().expect("Failed to get dyn entry"), Dyn {
d_tag: abi::DT_INIT,
d_un: 4195216
});
}
#[test]
@ -1128,17 +1126,14 @@ fn symbol_table() {
.expect("Failed to read symbol table")
.expect("Failed to find symbol table");
let symbol = symtab.get(30).expect("Failed to get symbol");
assert_eq!(
symbol,
Symbol {
st_name: 19,
st_value: 6293200,
st_size: 0,
st_shndx: 21,
st_info: 1,
st_other: 0,
}
);
assert_eq!(symbol, Symbol {
st_name: 19,
st_value: 6293200,
st_size: 0,
st_shndx: 21,
st_info: 1,
st_other: 0,
});
assert_eq!(
strtab.get(symbol.st_name as usize).expect("Failed to get name from strtab"),
"__JCR_LIST__"
@ -1157,10 +1152,14 @@ fn dynamic_symbol_table() {
.expect("Failed to read symbol table")
.expect("Failed to find symbol table");
let symbol = symtab.get(1).expect("Failed to get symbol");
assert_eq!(
symbol,
Symbol { st_name: 11, st_value: 0, st_size: 0, st_shndx: 0, st_info: 18, st_other: 0 }
);
assert_eq!(symbol, Symbol {
st_name: 11,
st_value: 0,
st_size: 0,
st_shndx: 0,
st_info: 18,
st_other: 0
});
assert_eq!(
strtab.get(symbol.st_name as usize).expect("Failed to get name from strtab"),
"memset"

View File

@ -6,7 +6,7 @@
use crate::compression::CompressionHeader;
use crate::dynamic::DynamicTable;
use crate::endian::EndianParse;
use crate::file::{parse_ident, Class, FileHeader};
use crate::file::{Class, FileHeader, parse_ident};
use crate::gnu_symver::{
SymbolVersionTable, VerDefIterator, VerNeedIterator, VersionIndex, VersionIndexTable,
};
@ -780,19 +780,16 @@ fn segments() {
let file = ElfStream::<AnyEndian, _>::open_stream(io).expect("Open test1");
let segments = file.segments();
assert_eq!(
segments[0],
ProgramHeader {
p_type: abi::PT_PHDR,
p_offset: 64,
p_vaddr: 4194368,
p_paddr: 4194368,
p_filesz: 448,
p_memsz: 448,
p_flags: 5,
p_align: 8,
}
)
assert_eq!(segments[0], ProgramHeader {
p_type: abi::PT_PHDR,
p_offset: 64,
p_vaddr: 4194368,
p_paddr: 4194368,
p_filesz: 448,
p_memsz: 448,
p_flags: 5,
p_align: 8,
})
}
#[test]
@ -801,19 +798,16 @@ fn segments_phnum_in_shdr0() {
let io = std::fs::File::open(path).expect("Could not open file.");
let file = ElfStream::<AnyEndian, _>::open_stream(io).expect("Open test1");
assert_eq!(
file.segments()[0],
ProgramHeader {
p_type: abi::PT_PHDR,
p_offset: 92,
p_vaddr: 0,
p_paddr: 0,
p_filesz: 32,
p_memsz: 32,
p_flags: 0x20003,
p_align: 0x40000,
}
);
assert_eq!(file.segments()[0], ProgramHeader {
p_type: abi::PT_PHDR,
p_offset: 92,
p_vaddr: 0,
p_paddr: 0,
p_filesz: 32,
p_memsz: 32,
p_flags: 0x20003,
p_align: 0x40000,
});
}
#[test]
@ -827,17 +821,14 @@ fn symbol_table() {
.expect("Failed to read symbol table")
.expect("Failed to find symbol table");
let symbol = symtab.get(30).expect("Failed to get symbol");
assert_eq!(
symbol,
Symbol {
st_name: 19,
st_value: 6293200,
st_size: 0,
st_shndx: 21,
st_info: 1,
st_other: 0,
}
);
assert_eq!(symbol, Symbol {
st_name: 19,
st_value: 6293200,
st_size: 0,
st_shndx: 21,
st_info: 1,
st_other: 0,
});
assert_eq!(
strtab.get(symbol.st_name as usize).expect("Failed to get name from strtab"),
"__JCR_LIST__"
@ -855,10 +846,14 @@ fn dynamic_symbol_table() {
.expect("Failed to read symbol table")
.expect("Failed to find symbol table");
let symbol = symtab.get(1).expect("Failed to get symbol");
assert_eq!(
symbol,
Symbol { st_name: 11, st_value: 0, st_size: 0, st_shndx: 0, st_info: 18, st_other: 0 }
);
assert_eq!(symbol, Symbol {
st_name: 11,
st_value: 0,
st_size: 0,
st_shndx: 0,
st_info: 18,
st_other: 0
});
assert_eq!(
strtab.get(symbol.st_name as usize).expect("Failed to get name from strtab"),
"memset"
@ -876,14 +871,14 @@ fn dynamic() {
.expect("Failed to parse .dynamic")
.expect("Failed to find .dynamic")
.iter();
assert_eq!(
dynamic.next().expect("Failed to get dyn entry"),
Dyn { d_tag: abi::DT_NEEDED, d_un: 1 }
);
assert_eq!(
dynamic.next().expect("Failed to get dyn entry"),
Dyn { d_tag: abi::DT_INIT, d_un: 4195216 }
);
assert_eq!(dynamic.next().expect("Failed to get dyn entry"), Dyn {
d_tag: abi::DT_NEEDED,
d_un: 1
});
assert_eq!(dynamic.next().expect("Failed to get dyn entry"), Dyn {
d_tag: abi::DT_INIT,
d_un: 4195216
});
}
#[test]
@ -904,14 +899,18 @@ fn section_data_as_relas() {
let shdr = file.section_headers()[10];
let mut relas = file.section_data_as_relas(&shdr).expect("Failed to read relas section");
assert_eq!(
relas.next().expect("Failed to get rela entry"),
Rela { r_offset: 6293704, r_sym: 1, 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_eq!(relas.next().expect("Failed to get rela entry"), Rela {
r_offset: 6293704,
r_sym: 1,
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());
}

View File

@ -368,28 +368,25 @@ fn test_parse_ehdr32_works() {
*elem = n as u8;
}
assert_eq!(
FileHeader::parse_tail(ident, &tail).unwrap(),
FileHeader {
class: Class::ELF32,
endianness: AnyEndian::Little,
version: 0x7060504,
osabi: abi::ELFOSABI_LINUX,
abiversion: 7,
e_type: 0x100,
e_machine: 0x302,
e_entry: 0x0B0A0908,
e_phoff: 0x0F0E0D0C,
e_shoff: 0x13121110,
e_flags: 0x17161514,
e_ehsize: 0x1918,
e_phentsize: 0x1B1A,
e_phnum: 0x1D1C,
e_shentsize: 0x1F1E,
e_shnum: 0x2120,
e_shstrndx: 0x2322,
}
);
assert_eq!(FileHeader::parse_tail(ident, &tail).unwrap(), FileHeader {
class: Class::ELF32,
endianness: AnyEndian::Little,
version: 0x7060504,
osabi: abi::ELFOSABI_LINUX,
abiversion: 7,
e_type: 0x100,
e_machine: 0x302,
e_entry: 0x0B0A0908,
e_phoff: 0x0F0E0D0C,
e_shoff: 0x13121110,
e_flags: 0x17161514,
e_ehsize: 0x1918,
e_phentsize: 0x1B1A,
e_phnum: 0x1D1C,
e_shentsize: 0x1F1E,
e_shnum: 0x2120,
e_shstrndx: 0x2322,
});
}
#[test]
@ -415,28 +412,25 @@ fn test_parse_ehdr64_works() {
*elem = n as u8;
}
assert_eq!(
FileHeader::parse_tail(ident, &tail).unwrap(),
FileHeader {
class: Class::ELF64,
endianness: AnyEndian::Big,
version: 0x04050607,
osabi: abi::ELFOSABI_LINUX,
abiversion: 7,
e_type: 0x0001,
e_machine: 0x0203,
e_entry: 0x08090A0B0C0D0E0F,
e_phoff: 0x1011121314151617,
e_shoff: 0x18191A1B1C1D1E1F,
e_flags: 0x20212223,
e_ehsize: 0x2425,
e_phentsize: 0x2627,
e_phnum: 0x2829,
e_shentsize: 0x2A2B,
e_shnum: 0x2C2D,
e_shstrndx: 0x2E2F,
}
);
assert_eq!(FileHeader::parse_tail(ident, &tail).unwrap(), FileHeader {
class: Class::ELF64,
endianness: AnyEndian::Big,
version: 0x04050607,
osabi: abi::ELFOSABI_LINUX,
abiversion: 7,
e_type: 0x0001,
e_machine: 0x0203,
e_entry: 0x08090A0B0C0D0E0F,
e_phoff: 0x1011121314151617,
e_shoff: 0x18191A1B1C1D1E1F,
e_flags: 0x20212223,
e_ehsize: 0x2425,
e_phentsize: 0x2627,
e_phnum: 0x2829,
e_shentsize: 0x2A2B,
e_shnum: 0x2C2D,
e_shstrndx: 0x2E2F,
});
}
#[test]

View File

@ -694,16 +694,13 @@ fn verneedaux_iter_one_entry() {
let mut iter =
VerNeedAuxIterator::new(LittleEndian, Class::ELF64, 1, 0x10, &GNU_VERNEED_DATA);
let aux1 = iter.next().expect("Failed to parse");
assert_eq!(
aux1,
VerNeedAux {
vna_hash: 0x0827e5c0,
vna_flags: 0,
vna_other: 0x0a,
vna_name: 0x01,
vna_next: 0
}
);
assert_eq!(aux1, VerNeedAux {
vna_hash: 0x0827e5c0,
vna_flags: 0,
vna_other: 0x0a,
vna_name: 0x01,
vna_next: 0
});
assert!(iter.next().is_none());
}
@ -712,38 +709,29 @@ fn verneedaux_iter_multiple_entries() {
let mut iter =
VerNeedAuxIterator::new(LittleEndian, Class::ELF64, 3, 0x30, &GNU_VERNEED_DATA);
let aux1 = iter.next().expect("Failed to parse");
assert_eq!(
aux1,
VerNeedAux {
vna_hash: 0x0d696913,
vna_flags: 0,
vna_other: 0x0c,
vna_name: 0x0c,
vna_next: 0x10
}
);
assert_eq!(aux1, VerNeedAux {
vna_hash: 0x0d696913,
vna_flags: 0,
vna_other: 0x0c,
vna_name: 0x0c,
vna_next: 0x10
});
let aux2 = iter.next().expect("Failed to parse");
assert_eq!(
aux2,
VerNeedAux {
vna_hash: 0x069691b3,
vna_flags: 0,
vna_other: 0x0b,
vna_name: 0x17,
vna_next: 0x10
}
);
assert_eq!(aux2, VerNeedAux {
vna_hash: 0x069691b3,
vna_flags: 0,
vna_other: 0x0b,
vna_name: 0x17,
vna_next: 0x10
});
let aux3 = iter.next().expect("Failed to parse");
assert_eq!(
aux3,
VerNeedAux {
vna_hash: 0x06969194,
vna_flags: 0,
vna_other: 0x09,
vna_name: 0x37,
vna_next: 0
}
);
assert_eq!(aux3, VerNeedAux {
vna_hash: 0x06969194,
vna_flags: 0,
vna_other: 0x09,
vna_name: 0x37,
vna_next: 0
});
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 aux1_1 = iter1.next().expect("Failed to parse");
assert_eq!(
aux1_1,
VerNeedAux {
vna_hash: 0x0827e5c0,
vna_flags: 0,
vna_other: 0x0a,
vna_name: 0x0ccc,
vna_next: 0x20,
}
);
assert_eq!(aux1_1, VerNeedAux {
vna_hash: 0x0827e5c0,
vna_flags: 0,
vna_other: 0x0a,
vna_name: 0x0ccc,
vna_next: 0x20,
});
let aux2_1 = iter2.next().expect("Failed to parse");
assert_eq!(
aux2_1,
VerNeedAux {
vna_hash: 0x0d696913,
vna_flags: 0,
vna_other: 0x0c,
vna_name: 0x0cd7,
vna_next: 0x20
}
);
assert_eq!(aux2_1, VerNeedAux {
vna_hash: 0x0d696913,
vna_flags: 0,
vna_other: 0x0c,
vna_name: 0x0cd7,
vna_next: 0x20
});
let aux1_2 = iter1.next().expect("Failed to parse");
assert_eq!(
aux1_2,
VerNeedAux {
vna_hash: 0x069691b3,
vna_flags: 0,
vna_other: 0x0b,
vna_name: 0x0ce1,
vna_next: 0
}
);
assert_eq!(aux1_2, VerNeedAux {
vna_hash: 0x069691b3,
vna_flags: 0,
vna_other: 0x0b,
vna_name: 0x0ce1,
vna_next: 0
});
let aux2_2 = iter2.next().expect("Failed to parse");
assert_eq!(
aux2_2,
VerNeedAux {
vna_hash: 0x06969194,
vna_flags: 0,
vna_other: 0x09,
vna_name: 0x0cec,
vna_next: 0
}
);
assert_eq!(aux2_2, VerNeedAux {
vna_hash: 0x06969194,
vna_flags: 0,
vna_other: 0x09,
vna_name: 0x0cec,
vna_next: 0
});
assert!(iter1.next().is_none());
assert!(iter2.next().is_none());
}
@ -878,61 +854,58 @@ fn verdef_iter() {
assert_eq!(entries.len(), 4);
assert_eq!(
entries,
vec![
(
VerDef {
vd_flags: 1,
vd_ndx: 1,
vd_cnt: 1,
vd_hash: 0x0B077AB0,
vd_aux: 20,
vd_next: 28,
},
vec![VerDefAux { vda_name: 0x1, vda_next: 0 }]
),
(
VerDef {
vd_flags: 0,
vd_ndx: 2,
vd_cnt: 1,
vd_hash: 0x088f2f70,
vd_aux: 20,
vd_next: 28,
},
vec![VerDefAux { vda_name: 0xC, vda_next: 0 }]
),
(
VerDef {
vd_flags: 0,
vd_ndx: 3,
vd_cnt: 2,
vd_hash: 0x088f2f71,
vd_aux: 20,
vd_next: 36,
},
vec![
VerDefAux { vda_name: 0x17, vda_next: 8 },
VerDefAux { vda_name: 0xC, vda_next: 0 }
]
),
(
VerDef {
vd_flags: 0,
vd_ndx: 4,
vd_cnt: 2,
vd_hash: 0x088f2f72,
vd_aux: 20,
vd_next: 0,
},
vec![
VerDefAux { vda_name: 0xC, vda_next: 8 },
VerDefAux { vda_name: 0x17, vda_next: 0 }
]
),
]
);
assert_eq!(entries, vec![
(
VerDef {
vd_flags: 1,
vd_ndx: 1,
vd_cnt: 1,
vd_hash: 0x0B077AB0,
vd_aux: 20,
vd_next: 28,
},
vec![VerDefAux { vda_name: 0x1, vda_next: 0 }]
),
(
VerDef {
vd_flags: 0,
vd_ndx: 2,
vd_cnt: 1,
vd_hash: 0x088f2f70,
vd_aux: 20,
vd_next: 28,
},
vec![VerDefAux { vda_name: 0xC, vda_next: 0 }]
),
(
VerDef {
vd_flags: 0,
vd_ndx: 3,
vd_cnt: 2,
vd_hash: 0x088f2f71,
vd_aux: 20,
vd_next: 36,
},
vec![VerDefAux { vda_name: 0x17, vda_next: 8 }, VerDefAux {
vda_name: 0xC,
vda_next: 0
}]
),
(
VerDef {
vd_flags: 0,
vd_ndx: 4,
vd_cnt: 2,
vd_hash: 0x088f2f72,
vd_aux: 20,
vd_next: 0,
},
vec![VerDefAux { vda_name: 0xC, vda_next: 8 }, VerDefAux {
vda_name: 0x17,
vda_next: 0
}]
),
]);
}
#[test]
@ -1041,31 +1014,25 @@ fn version_table() {
.get_requirement(2)
.expect("Failed to parse definition")
.expect("Failed to find req");
assert_eq!(
req1,
SymbolRequirement {
file: "libc.so.6",
name: "GLIBC_2.3",
hash: 0x6969194,
flags: 0,
hidden: false
}
);
assert_eq!(req1, SymbolRequirement {
file: "libc.so.6",
name: "GLIBC_2.3",
hash: 0x6969194,
flags: 0,
hidden: false
});
let req2 = table
.get_requirement(3)
.expect("Failed to parse definition")
.expect("Failed to find req");
assert_eq!(
req2,
SymbolRequirement {
file: "libz.so.1",
name: "ZLIB_1.2.0",
hash: 0x827E5C0,
flags: 0,
hidden: false
}
);
assert_eq!(req2, SymbolRequirement {
file: "libz.so.1",
name: "ZLIB_1.2.0",
hash: 0x827E5C0,
flags: 0,
hidden: false
});
// 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
@ -1138,17 +1105,14 @@ fn parse_verdef32_lsb() {
let entry = VerDef::parse_at(LittleEndian, Class::ELF32, &mut offset, data.as_ref())
.expect("Failed to parse VerDef");
assert_eq!(
entry,
VerDef {
vd_flags: 0x0302,
vd_ndx: 0x0504,
vd_cnt: 0x0706,
vd_hash: 0x0B0A0908,
vd_aux: 0x0F0E0D0C,
vd_next: 0x13121110,
}
);
assert_eq!(entry, VerDef {
vd_flags: 0x0302,
vd_ndx: 0x0504,
vd_cnt: 0x0706,
vd_hash: 0x0B0A0908,
vd_aux: 0x0F0E0D0C,
vd_next: 0x13121110,
});
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())
.expect("Failed to parse VerDef");
assert_eq!(
entry,
VerDef {
vd_flags: 0x0203,
vd_ndx: 0x0405,
vd_cnt: 0x0607,
vd_hash: 0x08090A0B,
vd_aux: 0x0C0D0E0F,
vd_next: 0x10111213,
}
);
assert_eq!(entry, VerDef {
vd_flags: 0x0203,
vd_ndx: 0x0405,
vd_cnt: 0x0607,
vd_hash: 0x08090A0B,
vd_aux: 0x0C0D0E0F,
vd_next: 0x10111213,
});
assert_eq!(offset, ELFVERDEFSIZE);
}
@ -1229,38 +1190,34 @@ fn parse_verdef_bad_version_errors() {
//
#[test]
fn parse_verdefaux32_lsb() {
test_parse_for(
LittleEndian,
Class::ELF32,
VerDefAux { vda_name: 0x03020100, vda_next: 0x07060504 },
);
test_parse_for(LittleEndian, Class::ELF32, VerDefAux {
vda_name: 0x03020100,
vda_next: 0x07060504,
});
}
#[test]
fn parse_verdefaux32_msb() {
test_parse_for(
BigEndian,
Class::ELF32,
VerDefAux { vda_name: 0x00010203, vda_next: 0x04050607 },
);
test_parse_for(BigEndian, Class::ELF32, VerDefAux {
vda_name: 0x00010203,
vda_next: 0x04050607,
});
}
#[test]
fn parse_verdefaux64_lsb() {
test_parse_for(
LittleEndian,
Class::ELF64,
VerDefAux { vda_name: 0x03020100, vda_next: 0x07060504 },
);
test_parse_for(LittleEndian, Class::ELF64, VerDefAux {
vda_name: 0x03020100,
vda_next: 0x07060504,
});
}
#[test]
fn parse_verdefaux64_msb() {
test_parse_for(
BigEndian,
Class::ELF64,
VerDefAux { vda_name: 0x00010203, vda_next: 0x04050607 },
);
test_parse_for(BigEndian, Class::ELF64, VerDefAux {
vda_name: 0x00010203,
vda_next: 0x04050607,
});
}
#[test]
@ -1299,15 +1256,12 @@ fn parse_verneed32_lsb() {
let entry = VerNeed::parse_at(LittleEndian, Class::ELF32, &mut offset, data.as_ref())
.expect("Failed to parse VerNeed");
assert_eq!(
entry,
VerNeed {
vn_cnt: 0x0302,
vn_file: 0x07060504,
vn_aux: 0x0B0A0908,
vn_next: 0x0F0E0D0C,
}
);
assert_eq!(entry, VerNeed {
vn_cnt: 0x0302,
vn_file: 0x07060504,
vn_aux: 0x0B0A0908,
vn_next: 0x0F0E0D0C,
});
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())
.expect("Failed to parse VerNeed");
assert_eq!(
entry,
VerNeed {
vn_cnt: 0x0203,
vn_file: 0x04050607,
vn_aux: 0x08090A0B,
vn_next: 0x0C0D0E0F,
}
);
assert_eq!(entry, VerNeed {
vn_cnt: 0x0203,
vn_file: 0x04050607,
vn_aux: 0x08090A0B,
vn_next: 0x0C0D0E0F,
});
assert_eq!(offset, ELFVERNEEDSIZE);
}
@ -1372,62 +1323,46 @@ fn parse_verneed64_fuzz_too_short() {
//
#[test]
fn parse_verneedaux32_lsb() {
test_parse_for(
LittleEndian,
Class::ELF32,
VerNeedAux {
vna_hash: 0x03020100,
vna_flags: 0x0504,
vna_other: 0x0706,
vna_name: 0x0B0A0908,
vna_next: 0x0F0E0D0C,
},
);
test_parse_for(LittleEndian, Class::ELF32, VerNeedAux {
vna_hash: 0x03020100,
vna_flags: 0x0504,
vna_other: 0x0706,
vna_name: 0x0B0A0908,
vna_next: 0x0F0E0D0C,
});
}
#[test]
fn parse_verneedaux32_msb() {
test_parse_for(
BigEndian,
Class::ELF32,
VerNeedAux {
vna_hash: 0x00010203,
vna_flags: 0x0405,
vna_other: 0x0607,
vna_name: 0x08090A0B,
vna_next: 0x0C0D0E0F,
},
);
test_parse_for(BigEndian, Class::ELF32, VerNeedAux {
vna_hash: 0x00010203,
vna_flags: 0x0405,
vna_other: 0x0607,
vna_name: 0x08090A0B,
vna_next: 0x0C0D0E0F,
});
}
#[test]
fn parse_verneedaux64_lsb() {
test_parse_for(
LittleEndian,
Class::ELF64,
VerNeedAux {
vna_hash: 0x03020100,
vna_flags: 0x0504,
vna_other: 0x0706,
vna_name: 0x0B0A0908,
vna_next: 0x0F0E0D0C,
},
);
test_parse_for(LittleEndian, Class::ELF64, VerNeedAux {
vna_hash: 0x03020100,
vna_flags: 0x0504,
vna_other: 0x0706,
vna_name: 0x0B0A0908,
vna_next: 0x0F0E0D0C,
});
}
#[test]
fn parse_verneedaux64_msb() {
test_parse_for(
BigEndian,
Class::ELF64,
VerNeedAux {
vna_hash: 0x00010203,
vna_flags: 0x0405,
vna_other: 0x0607,
vna_name: 0x08090A0B,
vna_next: 0x0C0D0E0F,
},
);
test_parse_for(BigEndian, Class::ELF64, VerNeedAux {
vna_hash: 0x00010203,
vna_flags: 0x0405,
vna_other: 0x0607,
vna_name: 0x08090A0B,
vna_next: 0x0C0D0E0F,
});
}
#[test]

View File

@ -316,38 +316,34 @@ mod sysv_parse_tests {
#[test]
fn parse_sysvhdr32_lsb() {
test_parse_for(
LittleEndian,
Class::ELF32,
SysVHashHeader { nbucket: 0x03020100, nchain: 0x07060504 },
);
test_parse_for(LittleEndian, Class::ELF32, SysVHashHeader {
nbucket: 0x03020100,
nchain: 0x07060504,
});
}
#[test]
fn parse_sysvhdr32_msb() {
test_parse_for(
BigEndian,
Class::ELF32,
SysVHashHeader { nbucket: 0x00010203, nchain: 0x04050607 },
);
test_parse_for(BigEndian, Class::ELF32, SysVHashHeader {
nbucket: 0x00010203,
nchain: 0x04050607,
});
}
#[test]
fn parse_sysvhdr64_lsb() {
test_parse_for(
LittleEndian,
Class::ELF64,
SysVHashHeader { nbucket: 0x03020100, nchain: 0x07060504 },
);
test_parse_for(LittleEndian, Class::ELF64, SysVHashHeader {
nbucket: 0x03020100,
nchain: 0x07060504,
});
}
#[test]
fn parse_sysvhdr64_msb() {
test_parse_for(
BigEndian,
Class::ELF64,
SysVHashHeader { nbucket: 0x00010203, nchain: 0x04050607 },
);
test_parse_for(BigEndian, Class::ELF64, SysVHashHeader {
nbucket: 0x00010203,
nchain: 0x04050607,
});
}
#[test]
@ -388,58 +384,42 @@ fn gnu_hash_tests() {
#[test]
fn parse_gnuhdr32_lsb() {
test_parse_for(
LittleEndian,
Class::ELF32,
GnuHashHeader {
nbucket: 0x03020100,
table_start_idx: 0x07060504,
nbloom: 0x0B0A0908,
nshift: 0x0F0E0D0C,
},
);
test_parse_for(LittleEndian, Class::ELF32, GnuHashHeader {
nbucket: 0x03020100,
table_start_idx: 0x07060504,
nbloom: 0x0B0A0908,
nshift: 0x0F0E0D0C,
});
}
#[test]
fn parse_gnuhdr32_msb() {
test_parse_for(
BigEndian,
Class::ELF32,
GnuHashHeader {
nbucket: 0x00010203,
table_start_idx: 0x04050607,
nbloom: 0x008090A0B,
nshift: 0x0C0D0E0F,
},
);
test_parse_for(BigEndian, Class::ELF32, GnuHashHeader {
nbucket: 0x00010203,
table_start_idx: 0x04050607,
nbloom: 0x008090A0B,
nshift: 0x0C0D0E0F,
});
}
#[test]
fn parse_gnuhdr64_lsb() {
test_parse_for(
LittleEndian,
Class::ELF64,
GnuHashHeader {
nbucket: 0x03020100,
table_start_idx: 0x07060504,
nbloom: 0x0B0A0908,
nshift: 0x0F0E0D0C,
},
);
test_parse_for(LittleEndian, Class::ELF64, GnuHashHeader {
nbucket: 0x03020100,
table_start_idx: 0x07060504,
nbloom: 0x0B0A0908,
nshift: 0x0F0E0D0C,
});
}
#[test]
fn parse_gnuhdr64_msb() {
test_parse_for(
BigEndian,
Class::ELF64,
GnuHashHeader {
nbucket: 0x00010203,
table_start_idx: 0x04050607,
nbloom: 0x008090A0B,
nshift: 0x0C0D0E0F,
},
);
test_parse_for(BigEndian, Class::ELF64, GnuHashHeader {
nbucket: 0x00010203,
table_start_idx: 0x04050607,
nbloom: 0x008090A0B,
nshift: 0x0C0D0E0F,
});
}
#[test]

View File

@ -473,46 +473,38 @@ fn parse_note_32_lsb_with_no_desc() {
#[test]
fn parse_nhdr32_lsb() {
test_parse_for(
LittleEndian,
Class::ELF32,
NoteHeader { n_namesz: 0x03020100, n_descsz: 0x07060504, n_type: 0x0B0A0908 },
);
test_parse_for(LittleEndian, Class::ELF32, NoteHeader {
n_namesz: 0x03020100,
n_descsz: 0x07060504,
n_type: 0x0B0A0908,
});
}
#[test]
fn parse_nhdr32_msb() {
test_parse_for(
BigEndian,
Class::ELF32,
NoteHeader { n_namesz: 0x00010203, n_descsz: 0x04050607, n_type: 0x08090A0B },
);
test_parse_for(BigEndian, Class::ELF32, NoteHeader {
n_namesz: 0x00010203,
n_descsz: 0x04050607,
n_type: 0x08090A0B,
});
}
#[test]
fn parse_nhdr64_lsb() {
test_parse_for(
LittleEndian,
Class::ELF64,
NoteHeader {
n_namesz: 0x0706050403020100,
n_descsz: 0x0F0E0D0C0B0A0908,
n_type: 0x1716151413121110,
},
);
test_parse_for(LittleEndian, Class::ELF64, NoteHeader {
n_namesz: 0x0706050403020100,
n_descsz: 0x0F0E0D0C0B0A0908,
n_type: 0x1716151413121110,
});
}
#[test]
fn parse_nhdr64_msb() {
test_parse_for(
BigEndian,
Class::ELF64,
NoteHeader {
n_namesz: 0x0001020304050607,
n_descsz: 0x08090A0B0C0D0E0F,
n_type: 0x1011121314151617,
},
);
test_parse_for(BigEndian, Class::ELF64, NoteHeader {
n_namesz: 0x0001020304050607,
n_descsz: 0x08090A0B0C0D0E0F,
n_type: 0x1011121314151617,
});
}
#[test]

View File

@ -142,38 +142,38 @@ mod parse_tests {
#[test]
fn parse_rel32_lsb() {
test_parse_for(
LittleEndian,
Class::ELF32,
Rel { r_offset: 0x03020100, r_sym: 0x00070605, r_type: 0x00000004 },
);
test_parse_for(LittleEndian, Class::ELF32, Rel {
r_offset: 0x03020100,
r_sym: 0x00070605,
r_type: 0x00000004,
});
}
#[test]
fn parse_rel32_msb() {
test_parse_for(
BigEndian,
Class::ELF32,
Rel { r_offset: 0x00010203, r_sym: 0x00040506, r_type: 0x00000007 },
);
test_parse_for(BigEndian, Class::ELF32, Rel {
r_offset: 0x00010203,
r_sym: 0x00040506,
r_type: 0x00000007,
});
}
#[test]
fn parse_rel64_lsb() {
test_parse_for(
LittleEndian,
Class::ELF64,
Rel { r_offset: 0x0706050403020100, r_sym: 0x0F0E0D0C, r_type: 0x0B0A0908 },
);
test_parse_for(LittleEndian, Class::ELF64, Rel {
r_offset: 0x0706050403020100,
r_sym: 0x0F0E0D0C,
r_type: 0x0B0A0908,
});
}
#[test]
fn parse_rel64_msb() {
test_parse_for(
BigEndian,
Class::ELF64,
Rel { r_offset: 0x0001020304050607, r_sym: 0x08090A0B, r_type: 0x0C0D0E0F },
);
test_parse_for(BigEndian, Class::ELF64, Rel {
r_offset: 0x0001020304050607,
r_sym: 0x08090A0B,
r_type: 0x0C0D0E0F,
});
}
#[test]
@ -198,58 +198,42 @@ fn parse_rel64_msb_fuzz_too_short() {
#[test]
fn parse_rela32_lsb() {
test_parse_for(
LittleEndian,
Class::ELF32,
Rela {
r_offset: 0x03020100,
r_sym: 0x00070605,
r_type: 0x00000004,
r_addend: 0x0B0A0908,
},
);
test_parse_for(LittleEndian, Class::ELF32, Rela {
r_offset: 0x03020100,
r_sym: 0x00070605,
r_type: 0x00000004,
r_addend: 0x0B0A0908,
});
}
#[test]
fn parse_rela32_msb() {
test_parse_for(
BigEndian,
Class::ELF32,
Rela {
r_offset: 0x00010203,
r_sym: 0x00040506,
r_type: 0x00000007,
r_addend: 0x08090A0B,
},
);
test_parse_for(BigEndian, Class::ELF32, Rela {
r_offset: 0x00010203,
r_sym: 0x00040506,
r_type: 0x00000007,
r_addend: 0x08090A0B,
});
}
#[test]
fn parse_rela64_lsb() {
test_parse_for(
LittleEndian,
Class::ELF64,
Rela {
r_offset: 0x0706050403020100,
r_sym: 0x0F0E0D0C,
r_type: 0x0B0A0908,
r_addend: 0x1716151413121110,
},
);
test_parse_for(LittleEndian, Class::ELF64, Rela {
r_offset: 0x0706050403020100,
r_sym: 0x0F0E0D0C,
r_type: 0x0B0A0908,
r_addend: 0x1716151413121110,
});
}
#[test]
fn parse_rela64_msb() {
test_parse_for(
BigEndian,
Class::ELF64,
Rela {
r_offset: 0x0001020304050607,
r_sym: 0x08090A0B,
r_type: 0x0C0D0E0F,
r_addend: 0x1011121314151617,
},
);
test_parse_for(BigEndian, Class::ELF64, Rela {
r_offset: 0x0001020304050607,
r_sym: 0x08090A0B,
r_type: 0x0C0D0E0F,
r_addend: 0x1011121314151617,
});
}
#[test]

View File

@ -131,82 +131,66 @@ mod parse_tests {
#[test]
fn parse_shdr32_lsb() {
test_parse_for(
LittleEndian,
Class::ELF32,
SectionHeader {
sh_name: 0x03020100,
sh_type: 0x07060504,
sh_flags: 0xB0A0908,
sh_addr: 0x0F0E0D0C,
sh_offset: 0x13121110,
sh_size: 0x17161514,
sh_link: 0x1B1A1918,
sh_info: 0x1F1E1D1C,
sh_addralign: 0x23222120,
sh_entsize: 0x27262524,
},
);
test_parse_for(LittleEndian, Class::ELF32, SectionHeader {
sh_name: 0x03020100,
sh_type: 0x07060504,
sh_flags: 0xB0A0908,
sh_addr: 0x0F0E0D0C,
sh_offset: 0x13121110,
sh_size: 0x17161514,
sh_link: 0x1B1A1918,
sh_info: 0x1F1E1D1C,
sh_addralign: 0x23222120,
sh_entsize: 0x27262524,
});
}
#[test]
fn parse_shdr32_msb() {
test_parse_for(
BigEndian,
Class::ELF32,
SectionHeader {
sh_name: 0x00010203,
sh_type: 0x04050607,
sh_flags: 0x08090A0B,
sh_addr: 0x0C0D0E0F,
sh_offset: 0x10111213,
sh_size: 0x14151617,
sh_link: 0x18191A1B,
sh_info: 0x1C1D1E1F,
sh_addralign: 0x20212223,
sh_entsize: 0x24252627,
},
);
test_parse_for(BigEndian, Class::ELF32, SectionHeader {
sh_name: 0x00010203,
sh_type: 0x04050607,
sh_flags: 0x08090A0B,
sh_addr: 0x0C0D0E0F,
sh_offset: 0x10111213,
sh_size: 0x14151617,
sh_link: 0x18191A1B,
sh_info: 0x1C1D1E1F,
sh_addralign: 0x20212223,
sh_entsize: 0x24252627,
});
}
#[test]
fn parse_shdr64_lsb() {
test_parse_for(
LittleEndian,
Class::ELF64,
SectionHeader {
sh_name: 0x03020100,
sh_type: 0x07060504,
sh_flags: 0x0F0E0D0C0B0A0908,
sh_addr: 0x1716151413121110,
sh_offset: 0x1F1E1D1C1B1A1918,
sh_size: 0x2726252423222120,
sh_link: 0x2B2A2928,
sh_info: 0x2F2E2D2C,
sh_addralign: 0x3736353433323130,
sh_entsize: 0x3F3E3D3C3B3A3938,
},
);
test_parse_for(LittleEndian, Class::ELF64, SectionHeader {
sh_name: 0x03020100,
sh_type: 0x07060504,
sh_flags: 0x0F0E0D0C0B0A0908,
sh_addr: 0x1716151413121110,
sh_offset: 0x1F1E1D1C1B1A1918,
sh_size: 0x2726252423222120,
sh_link: 0x2B2A2928,
sh_info: 0x2F2E2D2C,
sh_addralign: 0x3736353433323130,
sh_entsize: 0x3F3E3D3C3B3A3938,
});
}
#[test]
fn parse_shdr64_msb() {
test_parse_for(
BigEndian,
Class::ELF64,
SectionHeader {
sh_name: 0x00010203,
sh_type: 0x04050607,
sh_flags: 0x08090A0B0C0D0E0F,
sh_addr: 0x1011121314151617,
sh_offset: 0x18191A1B1C1D1E1F,
sh_size: 0x2021222324252627,
sh_link: 0x28292A2B,
sh_info: 0x2C2D2E2F,
sh_addralign: 0x3031323334353637,
sh_entsize: 0x38393A3B3C3D3E3F,
},
);
test_parse_for(BigEndian, Class::ELF64, SectionHeader {
sh_name: 0x00010203,
sh_type: 0x04050607,
sh_flags: 0x08090A0B0C0D0E0F,
sh_addr: 0x1011121314151617,
sh_offset: 0x18191A1B1C1D1E1F,
sh_size: 0x2021222324252627,
sh_link: 0x28292A2B,
sh_info: 0x2C2D2E2F,
sh_addralign: 0x3031323334353637,
sh_entsize: 0x38393A3B3C3D3E3F,
});
}
#[test]

View File

@ -131,74 +131,58 @@ mod parse_tests {
#[test]
fn parse_phdr32_lsb() {
test_parse_for(
LittleEndian,
Class::ELF32,
ProgramHeader {
p_type: 0x03020100,
p_offset: 0x07060504,
p_vaddr: 0xB0A0908,
p_paddr: 0x0F0E0D0C,
p_filesz: 0x13121110,
p_memsz: 0x17161514,
p_flags: 0x1B1A1918,
p_align: 0x1F1E1D1C,
},
);
test_parse_for(LittleEndian, Class::ELF32, ProgramHeader {
p_type: 0x03020100,
p_offset: 0x07060504,
p_vaddr: 0xB0A0908,
p_paddr: 0x0F0E0D0C,
p_filesz: 0x13121110,
p_memsz: 0x17161514,
p_flags: 0x1B1A1918,
p_align: 0x1F1E1D1C,
});
}
#[test]
fn parse_phdr32_msb() {
test_parse_for(
BigEndian,
Class::ELF32,
ProgramHeader {
p_type: 0x00010203,
p_offset: 0x04050607,
p_vaddr: 0x08090A0B,
p_paddr: 0x0C0D0E0F,
p_filesz: 0x10111213,
p_memsz: 0x14151617,
p_flags: 0x18191A1B,
p_align: 0x1C1D1E1F,
},
);
test_parse_for(BigEndian, Class::ELF32, ProgramHeader {
p_type: 0x00010203,
p_offset: 0x04050607,
p_vaddr: 0x08090A0B,
p_paddr: 0x0C0D0E0F,
p_filesz: 0x10111213,
p_memsz: 0x14151617,
p_flags: 0x18191A1B,
p_align: 0x1C1D1E1F,
});
}
#[test]
fn parse_phdr64_lsb() {
test_parse_for(
LittleEndian,
Class::ELF64,
ProgramHeader {
p_type: 0x03020100,
p_offset: 0x0F0E0D0C0B0A0908,
p_vaddr: 0x1716151413121110,
p_paddr: 0x1F1E1D1C1B1A1918,
p_filesz: 0x2726252423222120,
p_memsz: 0x2F2E2D2C2B2A2928,
p_flags: 0x07060504,
p_align: 0x3736353433323130,
},
);
test_parse_for(LittleEndian, Class::ELF64, ProgramHeader {
p_type: 0x03020100,
p_offset: 0x0F0E0D0C0B0A0908,
p_vaddr: 0x1716151413121110,
p_paddr: 0x1F1E1D1C1B1A1918,
p_filesz: 0x2726252423222120,
p_memsz: 0x2F2E2D2C2B2A2928,
p_flags: 0x07060504,
p_align: 0x3736353433323130,
});
}
#[test]
fn parse_phdr64_msb() {
test_parse_for(
BigEndian,
Class::ELF64,
ProgramHeader {
p_type: 0x00010203,
p_offset: 0x08090A0B0C0D0E0F,
p_vaddr: 0x1011121314151617,
p_paddr: 0x18191A1B1C1D1E1F,
p_filesz: 0x2021222324252627,
p_memsz: 0x28292A2B2C2D2E2F,
p_flags: 0x04050607,
p_align: 0x3031323334353637,
},
);
test_parse_for(BigEndian, Class::ELF64, ProgramHeader {
p_type: 0x00010203,
p_offset: 0x08090A0B0C0D0E0F,
p_vaddr: 0x1011121314151617,
p_paddr: 0x18191A1B1C1D1E1F,
p_filesz: 0x2021222324252627,
p_memsz: 0x28292A2B2C2D2E2F,
p_flags: 0x04050607,
p_align: 0x3031323334353637,
});
}
#[test]

View File

@ -168,66 +168,50 @@ mod parse_tests {
#[test]
fn parse_sym32_lsb() {
test_parse_for(
LittleEndian,
Class::ELF32,
Symbol {
st_name: 0x03020100,
st_value: 0x07060504,
st_size: 0x0B0A0908,
st_shndx: 0x0F0E,
st_info: 0x0C,
st_other: 0x0D,
},
);
test_parse_for(LittleEndian, Class::ELF32, Symbol {
st_name: 0x03020100,
st_value: 0x07060504,
st_size: 0x0B0A0908,
st_shndx: 0x0F0E,
st_info: 0x0C,
st_other: 0x0D,
});
}
#[test]
fn parse_sym32_msb() {
test_parse_for(
BigEndian,
Class::ELF32,
Symbol {
st_name: 0x00010203,
st_value: 0x04050607,
st_size: 0x08090A0B,
st_shndx: 0x0E0F,
st_info: 0x0C,
st_other: 0x0D,
},
);
test_parse_for(BigEndian, Class::ELF32, Symbol {
st_name: 0x00010203,
st_value: 0x04050607,
st_size: 0x08090A0B,
st_shndx: 0x0E0F,
st_info: 0x0C,
st_other: 0x0D,
});
}
#[test]
fn parse_sym64_lsb() {
test_parse_for(
LittleEndian,
Class::ELF64,
Symbol {
st_name: 0x03020100,
st_value: 0x0F0E0D0C0B0A0908,
st_size: 0x1716151413121110,
st_shndx: 0x0706,
st_info: 0x04,
st_other: 0x05,
},
);
test_parse_for(LittleEndian, Class::ELF64, Symbol {
st_name: 0x03020100,
st_value: 0x0F0E0D0C0B0A0908,
st_size: 0x1716151413121110,
st_shndx: 0x0706,
st_info: 0x04,
st_other: 0x05,
});
}
#[test]
fn parse_sym64_msb() {
test_parse_for(
BigEndian,
Class::ELF64,
Symbol {
st_name: 0x00010203,
st_value: 0x08090A0B0C0D0E0F,
st_size: 0x1011121314151617,
st_shndx: 0x0607,
st_info: 0x04,
st_other: 0x05,
},
);
test_parse_for(BigEndian, Class::ELF64, Symbol {
st_name: 0x00010203,
st_value: 0x08090A0B0C0D0E0F,
st_size: 0x1011121314151617,
st_shndx: 0x0607,
st_info: 0x04,
st_other: 0x05,
});
}
#[test]

View File

@ -19,8 +19,8 @@ mod musl_reference_tests {
use std::process::Command;
use std::{env, fs};
use rand::seq::SliceRandom;
use rand::Rng;
use rand::seq::SliceRandom;
// Number of tests to generate for each function
const NTESTS: usize = 500;

View File

@ -29,7 +29,7 @@
use core::ptr::read_volatile;
use super::fenv::{
feclearexcept, fegetround, feraiseexcept, fetestexcept, FE_INEXACT, FE_TONEAREST, FE_UNDERFLOW,
FE_INEXACT, FE_TONEAREST, FE_UNDERFLOW, feclearexcept, fegetround, feraiseexcept, fetestexcept,
};
/*

View File

@ -221,10 +221,10 @@ macro_rules! llvm_intrinsically_optimized {
pub use self::erf::{erf, erfc};
pub use self::erff::{erfcf, erff};
pub use self::exp::exp;
pub use self::exp10::exp10;
pub use self::exp10f::exp10f;
pub use self::exp2::exp2;
pub use self::exp2f::exp2f;
pub use self::exp10::exp10;
pub use self::exp10f::exp10f;
pub use self::expf::expf;
pub use self::expm1::expm1;
pub use self::expm1f::expm1f;
@ -261,12 +261,12 @@ macro_rules! llvm_intrinsically_optimized {
pub use self::lgammaf::lgammaf;
pub use self::lgammaf_r::lgammaf_r;
pub use self::log::log;
pub use self::log10::log10;
pub use self::log10f::log10f;
pub use self::log1p::log1p;
pub use self::log1pf::log1pf;
pub use self::log2::log2;
pub use self::log2f::log2f;
pub use self::log10::log10;
pub use self::log10f::log10f;
pub use self::logf::logf;
pub use self::modf::modf;
pub use self::modff::modff;

View File

@ -42,32 +42,28 @@ pub enum Error {
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
use Error::*;
write!(
f,
"{}",
match self {
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",
write!(f, "{}", match self {
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",
})
}
}

View File

@ -1,7 +1,7 @@
use core::marker::PhantomData;
use core::num::{
NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize, NonZeroU128,
NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize,
NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI128, NonZeroIsize, NonZeroU8,
NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize,
};
use crate::varint::varint_max;

View File

@ -556,7 +556,7 @@ pub mod crc {
#[cfg(feature = "alloc")]
use super::alloc;
use super::{Flavor, Slice};
use crate::{serialize_with_flavor, Result};
use crate::{Result, serialize_with_flavor};
/// Manages CRC modifications as a flavor.
pub struct CrcModifier<'a, B, W>

View File

@ -1,4 +1,4 @@
use serde::{ser, Serialize};
use serde::{Serialize, ser};
use crate::error::{Error, Result};
use crate::ser::flavors::Flavor;

View File

@ -2425,11 +2425,11 @@ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let (start, end) = tri!(deserializer.deserialize_struct(
"Range",
range::FIELDS,
range::RangeVisitor { expecting: "struct Range", phantom: PhantomData },
));
let (start, end) =
tri!(deserializer.deserialize_struct("Range", range::FIELDS, range::RangeVisitor {
expecting: "struct Range",
phantom: PhantomData
},));
Ok(start..end)
}
}

View File

@ -22,7 +22,7 @@
//! ```
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::ser;

View File

@ -218,7 +218,7 @@ mod core {
pub use std::sync::atomic::Ordering;
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
pub use std::sync::atomic::{
AtomicBool, AtomicI16, AtomicI32, AtomicI8, AtomicIsize, AtomicU16, AtomicU32, AtomicU8,
AtomicBool, AtomicI8, AtomicI16, AtomicI32, AtomicIsize, AtomicU8, AtomicU16, AtomicU32,
AtomicUsize, Ordering,
};
#[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::time::Duration;
pub use self::core::{
clone, convert, default, f32, f64, i16, i32, i64, i8, isize, iter, num, option, ptr,
result, str, u16, u32, u64, u8, usize,
clone, convert, default, f32, f64, i8, i16, i32, i64, isize, iter, num, option, ptr,
result, str, u8, u16, u32, u64, usize,
};
#[cfg(any(feature = "std", feature = "alloc"))]
pub use self::core::{cmp, mem, slice};

View File

@ -200,8 +200,8 @@ mod content {
use crate::actually_private;
use crate::de::value::{MapDeserializer, SeqDeserializer};
use crate::de::{
self, size_hint, Deserialize, DeserializeSeed, Deserializer, EnumAccess, Expected,
IgnoredAny, MapAccess, SeqAccess, Unexpected, Visitor,
self, Deserialize, DeserializeSeed, Deserializer, EnumAccess, Expected, IgnoredAny,
MapAccess, SeqAccess, Unexpected, Visitor, size_hint,
};
use crate::lib::*;

View File

@ -2,10 +2,10 @@
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::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 {
($name:literal) => {

View File

@ -2,9 +2,9 @@
use core::arch::asm;
use crate::structures::gdt::SegmentSelector;
pub use crate::structures::DescriptorTablePointer;
use crate::VirtAddr;
pub use crate::structures::DescriptorTablePointer;
use crate::structures::gdt::SegmentSelector;
/// Load a GDT.
///

View File

@ -6,7 +6,7 @@
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, PageSize, Size2MiB, Size4KiB};
use crate::{PrivilegeLevel, VirtAddr};

View File

@ -13,7 +13,7 @@
#![allow(elided_lifetimes_in_paths)]
#![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 instructions;

View File

@ -164,17 +164,17 @@ mod x86_64 {
use bit_field::BitField;
use super::*;
use crate::PrivilegeLevel;
use crate::addr::VirtAddr;
use crate::registers::rflags::RFlags;
// imports for intra doc links
#[cfg(doc)]
use crate::registers::{
control::Cr4Flags,
segmentation::{Segment, Segment64, CS, SS},
segmentation::{CS, SS, Segment, Segment64},
};
use crate::structures::gdt::SegmentSelector;
use crate::structures::paging::{Page, Size4KiB};
use crate::PrivilegeLevel;
impl Msr {
/// Read 64 bits msr register.

View File

@ -5,13 +5,13 @@
use bit_field::BitField;
use super::model_specific::Msr;
use crate::{PrivilegeLevel, VirtAddr};
// imports for intra doc links
#[cfg(doc)]
use crate::{
registers::control::Cr4Flags,
structures::gdt::{Descriptor, DescriptorFlags, GlobalDescriptorTable},
};
use crate::{PrivilegeLevel, VirtAddr};
/// An x86 segment
///

View File

@ -9,12 +9,12 @@
#[cfg(not(feature = "instructions"))]
use u64 as EntryValue;
use crate::PrivilegeLevel;
pub use crate::registers::segmentation::SegmentSelector;
// imports for intra-doc links
#[cfg(doc)]
use crate::registers::segmentation::{Segment, CS, SS};
use crate::registers::segmentation::{CS, SS, Segment};
use crate::structures::tss::TaskStateSegment;
use crate::PrivilegeLevel;
/// 8-byte entry in a descriptor table.
///

View File

@ -788,7 +788,7 @@ pub const fn missing() -> Self {
#[cfg(feature = "instructions")]
#[inline]
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();
self.pointer_low = addr as u16;

View File

@ -5,8 +5,8 @@
use core::ops::{Add, AddAssign, Sub, SubAssign};
use super::page::AddressNotAligned;
use crate::structures::paging::page::{PageSize, Size4KiB};
use crate::PhysAddr;
use crate::structures::paging::page::{PageSize, Size4KiB};
/// A physical memory frame.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]

View File

@ -3,6 +3,7 @@
use core::fmt;
use super::*;
use crate::VirtAddr;
use crate::registers::control::Cr3;
use crate::structures::paging::frame_alloc::FrameAllocator;
use crate::structures::paging::page::{AddressNotAligned, NotGiantPageSize, PageRangeInclusive};
@ -12,7 +13,6 @@
use crate::structures::paging::{
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.
///

View File

@ -6,10 +6,10 @@
use core::marker::PhantomData;
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::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.
pub trait PageSize: Copy + Eq + PartialOrd + Ord + Sealed {

View File

@ -87,27 +87,31 @@ fn new_cc_build(build: &Build, target: TargetSelection) -> cc::Build {
}
pub fn find(build: &Build) {
let targets: HashSet<_> = match build.config.cmd {
// We don't need to check cross targets for these commands.
crate::Subcommand::Clean { .. }
| crate::Subcommand::Suggest { .. }
| crate::Subcommand::Format { .. }
| crate::Subcommand::Setup { .. } => {
build.hosts.iter().cloned().chain(iter::once(build.build)).collect()
}
// Commit 94fbe141558b94fbe141558b is just wrong. This breaks fmt for mikros, so undo it.
//let targets: HashSet<_> = match build.config.cmd {
// // We don't need to check cross targets for these commands.
// crate::Subcommand::Clean { .. }
// | crate::Subcommand::Suggest { .. }
// | crate::Subcommand::Format { .. }
// | 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()
// }
//};
_ => {
// 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<_> =
build.targets.iter().chain(&build.hosts).cloned().chain(iter::once(build.build)).collect();
for target in targets.into_iter() {
find_target(build, target);