mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 17:30:43 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0053667db | ||
|
|
d35c278284 | ||
|
|
fbec436b89 |
No files matched your search
@@ -202,6 +202,7 @@ remains unsupported.
|
||||
|
||||
### Fixed
|
||||
- Fixed the native dependency audit reading Cargo JSON and inspection-tool output in the process locale encoding; it now reads and reports UTF-8 paths and diagnostics under an ASCII locale (#363).
|
||||
- Fixed a latent ARM64 `LSLV` encoding bug that forced bit 1 of the shift-count register field (part of #131). The dynamic binary translator uses `X10` in its only call, which already has that bit set. `RBIT`, `CLZ` and `LSLV` now panic on out-of-range register numbers before emitting an instruction. Encoding tests use words checked against LLVM's assembler.
|
||||
- Made the static probe and the binder share one bounded import parser, after the truncated-name fix for #270. Truncated, unterminated, empty or non-ASCII names, reserved bits and endless tables are reported by the probe and refused by the binder.
|
||||
- Fixed the thread's TLS pointer naming the TLS data itself (#76). Compiled code loads the pointer from the thread environment block, indexes it by the module's TLS index to get the address of the data block, and then adds a variable's offset; the loader had mapped the data where the pointer array belongs, so the first eight bytes of the template were used as the block address. `setup_tls` now maps a pointer array at the thread's TLS base and the data block one page above it, and stores the block address in the slot of the index it assigns. `crates/loader/tests/tls_layout.rs` follows that access sequence through guest memory for a template with zero fill, a rebased image and a zero-fill-only directory. The data block of the fixture harness can now be at most 60 KiB, down from 64 KiB, before it would meet the thread environment block. Alignment requests above 4 KiB and more than one module's TLS are not handled. The access sequence follows Microsoft's public PE Format page; nothing ran on Windows, and independent review is pending.
|
||||
- Fixed the MXCSR flags of an unmasked floating-point overflow whose result is exact before the exponent is bounded, such as the largest binary32 value times two (#128). Only the overflow flag is set; the precision flag used to be set as well although nothing was rounded. A masked overflow still sets both flags and delivers infinity or the largest finite value, and an unmasked overflow that is also inexact still sets both. Five Intel SDM cases in `cpu_known_answers.rs` moved from open defect to verified on both engines, with three more for the other rounding modes, and the scalar and conversion sweeps now compare the precision flag in this case as well. Not compared with x86 hardware; awaiting independent review.
|
||||
|
||||
@@ -307,23 +307,27 @@ impl Arm64Assembler {
|
||||
}
|
||||
|
||||
/// RBIT Xd, Xn: reverse the bit order of the source.
|
||||
/// Panics if a register number exceeds 31.
|
||||
pub fn rbit_64(&mut self, xd: u8, xn: u8) {
|
||||
self.emit(0xdac0_0000 | ((u32::from(xn) & 0x1f) << 5) | (u32::from(xd) & 0x1f));
|
||||
assert!(xd <= XZR && xn <= XZR, "RBIT register must be in 0..=31");
|
||||
self.emit(0xdac0_0000 | (u32::from(xn) << 5) | u32::from(xd));
|
||||
}
|
||||
|
||||
/// CLZ Xd, Xn: count the leading zero bits of the source.
|
||||
/// Panics if a register number exceeds 31.
|
||||
pub fn clz_64(&mut self, xd: u8, xn: u8) {
|
||||
self.emit(0xdac0_1000 | ((u32::from(xn) & 0x1f) << 5) | (u32::from(xd) & 0x1f));
|
||||
assert!(xd <= XZR && xn <= XZR, "CLZ register must be in 0..=31");
|
||||
self.emit(0xdac0_1000 | (u32::from(xn) << 5) | u32::from(xd));
|
||||
}
|
||||
|
||||
/// LSLV Xd, Xn, Xm: shift the source left by the amount in Xm.
|
||||
/// Panics if a register number exceeds 31.
|
||||
pub fn lslv_64(&mut self, xd: u8, xn: u8, xm: u8) {
|
||||
self.emit(
|
||||
0x9ac2_2000
|
||||
| ((u32::from(xm) & 0x1f) << 16)
|
||||
| ((u32::from(xn) & 0x1f) << 5)
|
||||
| (u32::from(xd) & 0x1f),
|
||||
assert!(
|
||||
xd <= XZR && xn <= XZR && xm <= XZR,
|
||||
"LSLV register must be in 0..=31"
|
||||
);
|
||||
self.emit(0x9ac0_2000 | (u32::from(xm) << 16) | (u32::from(xn) << 5) | u32::from(xd));
|
||||
}
|
||||
|
||||
/// LDR Qt, [Xn, #offset] (offset a multiple of 16)
|
||||
@@ -791,6 +795,44 @@ mod tests {
|
||||
assert_eq!(branch.instructions()[0], 0x14000005);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rbit_clz_lslv_encodings_match_llvm() {
|
||||
// A64 words from Apple Clang's integrated assembler and llvm-objdump.
|
||||
let mut asm = Arm64Assembler::new();
|
||||
asm.rbit_64(X10, X9); // rbit x10, x9
|
||||
asm.rbit_64(X0, XZR); // rbit x0, xzr
|
||||
asm.clz_64(X10, X10); // clz x10, x10
|
||||
asm.clz_64(XZR, X30); // clz xzr, x30
|
||||
asm.lslv_64(X11, X11, X10); // lslv x11, x11, x10
|
||||
asm.lslv_64(X0, X1, X0); // lslv x0, x1, x0
|
||||
asm.lslv_64(XZR, X30, XZR); // lslv xzr, x30, xzr
|
||||
assert_eq!(
|
||||
asm.instructions(),
|
||||
[
|
||||
0xdac0012a, 0xdac003e0, 0xdac0114a, 0xdac013df, 0x9aca216b, 0x9ac02020, 0x9adf23df,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rbit_clz_lslv_reject_out_of_range_registers() {
|
||||
let invalid_operands: [fn(&mut Arm64Assembler); 7] = [
|
||||
|asm| asm.rbit_64(32, X0),
|
||||
|asm| asm.rbit_64(X0, 32),
|
||||
|asm| asm.clz_64(32, X0),
|
||||
|asm| asm.clz_64(X0, 32),
|
||||
|asm| asm.lslv_64(32, X0, X0),
|
||||
|asm| asm.lslv_64(X0, 32, X0),
|
||||
|asm| asm.lslv_64(X0, X0, 32),
|
||||
];
|
||||
for (index, emit) in invalid_operands.into_iter().enumerate() {
|
||||
let mut asm = Arm64Assembler::new();
|
||||
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| emit(&mut asm)));
|
||||
assert!(result.is_err(), "invalid operand case {index} was accepted");
|
||||
assert!(asm.instructions().is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsigned_offset_stores_scale_by_access_size() {
|
||||
let mut asm = Arm64Assembler::new();
|
||||
|
||||
Reference in new issue
Block a user