aarch64: Implement TLS ELF GD Relocations
Implement the `TlsValue` opcode in the aarch64 backend for ELF_GD. This is a little bit unusual as the default TLS mechanism for aarch64 is TLS Descriptors in other compilers. However currently we only recognize elf_gd so lets start with that as a TLS implementation.
This commit is contained in:
@@ -8,7 +8,7 @@ use crate::ir::{InstructionData, Opcode, TrapCode};
|
||||
use crate::isa::aarch64::settings as aarch64_settings;
|
||||
use crate::machinst::lower::*;
|
||||
use crate::machinst::*;
|
||||
use crate::settings::Flags;
|
||||
use crate::settings::{Flags, TlsModel};
|
||||
use crate::{CodegenError, CodegenResult};
|
||||
|
||||
use crate::isa::aarch64::abi::*;
|
||||
@@ -3489,7 +3489,24 @@ pub(crate) fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
|
||||
});
|
||||
}
|
||||
|
||||
Opcode::TlsValue => unimplemented!("tls_value"),
|
||||
Opcode::TlsValue => match flags.tls_model() {
|
||||
TlsModel::ElfGd => {
|
||||
let dst = get_output_reg(ctx, outputs[0]).only_reg().unwrap();
|
||||
let (name, _, _) = ctx.symbol_value(insn).unwrap();
|
||||
let symbol = name.clone();
|
||||
ctx.emit(Inst::ElfTlsGetAddr { symbol });
|
||||
|
||||
let x0 = xreg(0);
|
||||
ctx.emit(Inst::gen_move(dst, x0, I64));
|
||||
}
|
||||
_ => {
|
||||
todo!(
|
||||
"Unimplemented TLS model in AArch64 backend: {:?}",
|
||||
flags.tls_model()
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
Opcode::FcvtLowFromSint => unimplemented!("FcvtLowFromSint"),
|
||||
Opcode::FvpromoteLow => unimplemented!("FvpromoteLow"),
|
||||
Opcode::Fvdemote => unimplemented!("Fvdemote"),
|
||||
|
||||
Reference in New Issue
Block a user