on aarch64, unify data and function pointers

This commit is contained in:
Folkert 2023-09-17 21:15:48 +02:00
parent 311ae4c7a6
commit ce34d5826b
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 13 additions and 13 deletions

View file

@ -1076,6 +1076,17 @@ impl Assembler<AArch64GeneralReg, AArch64FloatReg> for AArch64Assembler {
relocs: &mut Vec<'_, Relocation>,
fn_name: String,
dst: AArch64GeneralReg,
) {
// a function pointer is the same as a data pointer on AArch64
Self::data_pointer(buf, relocs, fn_name, dst)
}
#[inline(always)]
fn data_pointer(
buf: &mut Vec<'_, u8>,
relocs: &mut Vec<'_, Relocation>,
fn_name: String,
dst: AArch64GeneralReg,
) {
// an `adrp` instruction and an addition to add in the lower bits
buf.extend((0x9000_0000u32 | dst.id() as u32).to_le_bytes());
@ -1095,23 +1106,12 @@ impl Assembler<AArch64GeneralReg, AArch64FloatReg> for AArch64Assembler {
// 4e0: 91000021 add x1, x1, #0x0
// 00000000000004e0: ARM64_RELOC_PAGEOFF12 ___unnamed_6
// in practice, that just looks a lot like a data relocation
relocs.push(Relocation::LinkedData {
offset: buf.len() as u64 - 8,
name: fn_name,
});
}
#[inline(always)]
fn data_pointer(
_buf: &mut Vec<'_, u8>,
_relocs: &mut Vec<'_, Relocation>,
_fn_name: String,
_dst: AArch64GeneralReg,
) {
eprintln!("data_pointer not implemented for this target");
}
#[inline(always)]
fn imul_reg64_reg64_reg64(
buf: &mut Vec<'_, u8>,

View file

@ -945,6 +945,8 @@ fn build_proc<'a, B: Backend<'a>>(
symbol: sym_id,
addend: 0,
}
} else if cfg!(all(target_arch = "aarch64", target_os = "macos")) {
todo!()
} else {
write::Relocation {
offset: offset + proc_offset,
@ -955,8 +957,6 @@ fn build_proc<'a, B: Backend<'a>>(
addend: -4,
}
}
} else if cfg!(all(target_arch = "aarch64", target_os = "macos")) {
todo!()
} else {
internal_error!("failed to find data symbol for {:?}", name);
}