cranelift: Add COFF TLS Support (#4546)

* cranelift: Implement COFF TLS Relocations

* cranelift: Emit SecRel relocations

* cranelift: Handle _tls_index symbol in backend
This commit is contained in:
Afonso Bordado
2022-08-11 17:33:40 +01:00
committed by GitHub
parent a40b253792
commit c5bc368cfe
10 changed files with 153 additions and 29 deletions

View File

@@ -116,6 +116,7 @@ impl Inst {
| Inst::XmmUninitializedValue { .. }
| Inst::ElfTlsGetAddr { .. }
| Inst::MachOTlsGetAddr { .. }
| Inst::CoffTlsGetAddr { .. }
| Inst::Unwind { .. }
| Inst::DummyUse { .. } => smallvec![],
@@ -1709,6 +1710,10 @@ impl PrettyPrint for Inst {
format!("%rax = macho_tls_get_addr {:?}", symbol)
}
Inst::CoffTlsGetAddr { ref symbol } => {
format!("%rax = coff_tls_get_addr {:?}", symbol)
}
Inst::Unwind { inst } => {
format!("unwind {:?}", inst)
}
@@ -2155,6 +2160,17 @@ fn x64_get_operands<F: Fn(VReg) -> VReg>(inst: &Inst, collector: &mut OperandCol
collector.reg_clobbers(clobbers);
}
Inst::CoffTlsGetAddr { .. } => {
// We also use the gs register. But that register is not allocatable by the
// register allocator, so we don't need to mark it as used here.
// We use %rax to set the address
collector.reg_def(Writable::from_reg(regs::rax()));
// We use %rcx as a temporary variable to load the _tls_index
collector.reg_def(Writable::from_reg(regs::rcx()));
}
Inst::Unwind { .. } => {}
Inst::DummyUse { reg } => {