Fix segfault due to b64 encoding (#919)
* Fix segfault due to b64 encoding Prior to this patch, bconst.b64 encoded its instruction with a 32-bit immediate that caused improper decoding of the MOV instruction; instead, use a REX prefix and rely on zero-extension of the immediate. Fixes #911.
This commit is contained in:
committed by
Benjamin Bouvier
parent
1eb6cd93b2
commit
cc57e84cbd
@@ -683,10 +683,7 @@ pub fn define(
|
||||
for &ty in &[B1, B8, B16, B32] {
|
||||
e.enc_both(bconst.bind(ty), rec_pu_id_bool.opcodes(vec![0xb8]));
|
||||
}
|
||||
e.enc64(
|
||||
bconst.bind(B64),
|
||||
rec_pu_id_bool.opcodes(vec![0xb8]).rex().w(),
|
||||
);
|
||||
e.enc64(bconst.bind(B64), rec_pu_id_bool.opcodes(vec![0xb8]).rex());
|
||||
|
||||
// Shifts and rotates.
|
||||
// Note that the dynamic shift amount is only masked by 5 or 6 bits; the 8-bit
|
||||
|
||||
10
cranelift/filetests/filetests/isa/x86/binary64-run.clif
Normal file
10
cranelift/filetests/filetests/isa/x86/binary64-run.clif
Normal file
@@ -0,0 +1,10 @@
|
||||
test run
|
||||
target x86_64
|
||||
|
||||
; this verifies that returning b64 immediates does not result in a segmentation fault, see https://github.com/CraneStation/cranelift/issues/911
|
||||
function %test_b64() -> b64 {
|
||||
ebb0:
|
||||
[-, %r10] v0 = bconst.b64 true
|
||||
return v0
|
||||
}
|
||||
; run
|
||||
@@ -1642,3 +1642,10 @@ ebb0:
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
function %B64() {
|
||||
ebb0:
|
||||
[-, %rax] v1 = bconst.b64 true ; bin: 40 b8 00000001
|
||||
[-, %r10] v0 = bconst.b64 true ; bin: 41 ba 00000001
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user