cranelift codegen: pass source locations with external relocations;
This commit is contained in:
@@ -205,7 +205,8 @@ pub(crate) fn define(shared_defs: &SharedDefinitions, regs: &IsaRegs) -> RecipeG
|
||||
|
||||
recipes.push(EncodingRecipeBuilder::new("UJcall", &formats.call, 4).emit(
|
||||
r#"
|
||||
sink.reloc_external(Reloc::RiscvCall,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::RiscvCall,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
0);
|
||||
// rd=%x1 is the standard link register.
|
||||
|
||||
@@ -1258,7 +1258,8 @@ pub(crate) fn define<'shared>(
|
||||
.emit(
|
||||
r#"
|
||||
{{PUT_OP}}(bits | (out_reg0 & 7), rex1(out_reg0), sink);
|
||||
sink.reloc_external(Reloc::Abs4,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::Abs4,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
0);
|
||||
sink.put4(0);
|
||||
@@ -1273,7 +1274,8 @@ pub(crate) fn define<'shared>(
|
||||
.emit(
|
||||
r#"
|
||||
{{PUT_OP}}(bits | (out_reg0 & 7), rex1(out_reg0), sink);
|
||||
sink.reloc_external(Reloc::Abs8,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::Abs8,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
0);
|
||||
sink.put8(0);
|
||||
@@ -1288,7 +1290,8 @@ pub(crate) fn define<'shared>(
|
||||
.emit(
|
||||
r#"
|
||||
{{PUT_OP}}(bits | (out_reg0 & 7), rex1(out_reg0), sink);
|
||||
sink.reloc_external(Reloc::Abs4,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::Abs4,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
0);
|
||||
// Write the immediate as `!0` for the benefit of BaldrMonkey.
|
||||
@@ -1304,7 +1307,8 @@ pub(crate) fn define<'shared>(
|
||||
.emit(
|
||||
r#"
|
||||
{{PUT_OP}}(bits | (out_reg0 & 7), rex1(out_reg0), sink);
|
||||
sink.reloc_external(Reloc::Abs8,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::Abs8,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
0);
|
||||
// Write the immediate as `!0` for the benefit of BaldrMonkey.
|
||||
@@ -1324,7 +1328,8 @@ pub(crate) fn define<'shared>(
|
||||
modrm_riprel(out_reg0, sink);
|
||||
// The addend adjusts for the difference between the end of the
|
||||
// instruction and the beginning of the immediate field.
|
||||
sink.reloc_external(Reloc::X86PCRel4,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::X86PCRel4,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
-4);
|
||||
sink.put4(0);
|
||||
@@ -1343,7 +1348,8 @@ pub(crate) fn define<'shared>(
|
||||
modrm_riprel(out_reg0, sink);
|
||||
// The addend adjusts for the difference between the end of the
|
||||
// instruction and the beginning of the immediate field.
|
||||
sink.reloc_external(Reloc::X86GOTPCRel4,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::X86GOTPCRel4,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
-4);
|
||||
sink.put4(0);
|
||||
@@ -1358,7 +1364,8 @@ pub(crate) fn define<'shared>(
|
||||
.emit(
|
||||
r#"
|
||||
{{PUT_OP}}(bits | (out_reg0 & 7), rex1(out_reg0), sink);
|
||||
sink.reloc_external(Reloc::Abs4,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::Abs4,
|
||||
&func.global_values[global_value].symbol_name(),
|
||||
0);
|
||||
sink.put4(0);
|
||||
@@ -1373,7 +1380,8 @@ pub(crate) fn define<'shared>(
|
||||
.emit(
|
||||
r#"
|
||||
{{PUT_OP}}(bits | (out_reg0 & 7), rex1(out_reg0), sink);
|
||||
sink.reloc_external(Reloc::Abs8,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::Abs8,
|
||||
&func.global_values[global_value].symbol_name(),
|
||||
0);
|
||||
sink.put8(0);
|
||||
@@ -1391,7 +1399,8 @@ pub(crate) fn define<'shared>(
|
||||
modrm_rm(5, out_reg0, sink);
|
||||
// The addend adjusts for the difference between the end of the
|
||||
// instruction and the beginning of the immediate field.
|
||||
sink.reloc_external(Reloc::X86PCRel4,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::X86PCRel4,
|
||||
&func.global_values[global_value].symbol_name(),
|
||||
-4);
|
||||
sink.put4(0);
|
||||
@@ -1409,7 +1418,8 @@ pub(crate) fn define<'shared>(
|
||||
modrm_rm(5, out_reg0, sink);
|
||||
// The addend adjusts for the difference between the end of the
|
||||
// instruction and the beginning of the immediate field.
|
||||
sink.reloc_external(Reloc::X86GOTPCRel4,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::X86GOTPCRel4,
|
||||
&func.global_values[global_value].symbol_name(),
|
||||
-4);
|
||||
sink.put4(0);
|
||||
@@ -2402,7 +2412,8 @@ pub(crate) fn define<'shared>(
|
||||
{{PUT_OP}}(bits, BASE_REX, sink);
|
||||
// The addend adjusts for the difference between the end of the
|
||||
// instruction and the beginning of the immediate field.
|
||||
sink.reloc_external(Reloc::X86CallPCRel4,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::X86CallPCRel4,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
-4);
|
||||
sink.put4(0);
|
||||
@@ -2415,7 +2426,8 @@ pub(crate) fn define<'shared>(
|
||||
r#"
|
||||
sink.trap(TrapCode::StackOverflow, func.srclocs[inst]);
|
||||
{{PUT_OP}}(bits, BASE_REX, sink);
|
||||
sink.reloc_external(Reloc::X86CallPLTRel4,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::X86CallPLTRel4,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
-4);
|
||||
sink.put4(0);
|
||||
@@ -3320,7 +3332,8 @@ pub(crate) fn define<'shared>(
|
||||
const LEA: u8 = 0x8d;
|
||||
sink.put1(LEA); // lea
|
||||
modrm_riprel(0b111/*out_reg0*/, sink); // 0x3d
|
||||
sink.reloc_external(Reloc::ElfX86_64TlsGd,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::ElfX86_64TlsGd,
|
||||
&func.global_values[global_value].symbol_name(),
|
||||
-4);
|
||||
sink.put4(0);
|
||||
@@ -3330,7 +3343,8 @@ pub(crate) fn define<'shared>(
|
||||
sink.put1(0x66); // data16
|
||||
sink.put1(0b01001000); // rex.w
|
||||
sink.put1(0xe8); // call
|
||||
sink.reloc_external(Reloc::X86CallPLTRel4,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::X86CallPLTRel4,
|
||||
&ExternalName::LibCall(LibCall::ElfTlsGetAddr),
|
||||
-4);
|
||||
sink.put4(0);
|
||||
@@ -3351,7 +3365,8 @@ pub(crate) fn define<'shared>(
|
||||
sink.put1(0x48); // rex
|
||||
sink.put1(0x8b); // mov
|
||||
modrm_riprel(0b111/*out_reg0*/, sink); // 0x3d
|
||||
sink.reloc_external(Reloc::MachOX86_64Tlv,
|
||||
sink.reloc_external(func.srclocs[inst],
|
||||
Reloc::MachOX86_64Tlv,
|
||||
&func.global_values[global_value].symbol_name(),
|
||||
-4);
|
||||
sink.put4(0);
|
||||
|
||||
Reference in New Issue
Block a user