diff --git a/lib/codegen/meta-python/isa/x86/recipes.py b/lib/codegen/meta-python/isa/x86/recipes.py index f033cc2090..8a204728d9 100644 --- a/lib/codegen/meta-python/isa/x86/recipes.py +++ b/lib/codegen/meta-python/isa/x86/recipes.py @@ -1510,11 +1510,11 @@ jt_base = TailRecipe( 'jt_base', BranchTableBase, size=5, ins=(), outs=(GPR), clobbers_flags=False, emit=''' - // No reloc is needed here as the jump table is emitted directly after - // the function body. PUT_OP(bits, rex2(0, out_reg0), sink); modrm_riprel(out_reg0, sink); + // No reloc is needed here as the jump table is emitted directly after + // the function body. jt_disp4(table, func, sink); ''') diff --git a/lib/codegen/src/isa/x86/binemit.rs b/lib/codegen/src/isa/x86/binemit.rs index 9095512eda..2389595b2e 100644 --- a/lib/codegen/src/isa/x86/binemit.rs +++ b/lib/codegen/src/isa/x86/binemit.rs @@ -328,12 +328,13 @@ fn disp1(destination: Ebb, func: &Function, sink: &mut CS sink.put1(delta as u8); } -/// Emit a single-byte branch displacement to `destination`. +/// Emit a four-byte branch displacement to `destination`. fn disp4(destination: Ebb, func: &Function, sink: &mut CS) { let delta = func.offsets[destination].wrapping_sub(sink.offset() + 4); sink.put4(delta); } +/// Emit a four-byte displacement to jump table `jt`. fn jt_disp4(jt: JumpTable, func: &Function, sink: &mut CS) { let delta = func.jt_offsets[jt].wrapping_sub(sink.offset() + 4); sink.put4(delta);