mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
add function calls and maybe fix function call relocations?
This commit is contained in:
parent
356f225b5d
commit
027b8aff4d
4 changed files with 22 additions and 3 deletions
|
@ -858,8 +858,13 @@ impl Assembler<AArch64GeneralReg, AArch64FloatReg> for AArch64Assembler {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn call(_buf: &mut Vec<'_, u8>, _relocs: &mut Vec<'_, Relocation>, _fn_name: String) {
|
||||
todo!("calling functions literal for AArch64");
|
||||
fn call(buf: &mut Vec<'_, u8>, relocs: &mut Vec<'_, Relocation>, fn_name: String) {
|
||||
let inst = 0b1001_0100_0000_0000_0000_0000_0000u32;
|
||||
buf.extend(inst.to_le_bytes());
|
||||
relocs.push(Relocation::LinkedFunction {
|
||||
offset: buf.len() as u64 - 4,
|
||||
name: fn_name,
|
||||
});
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
|
|
@ -731,6 +731,9 @@ impl<
|
|||
fn relocations_mut(&mut self) -> &mut Vec<'a, Relocation> {
|
||||
&mut self.relocs
|
||||
}
|
||||
fn target_info(&self) -> TargetInfo {
|
||||
self.storage_manager.target_info
|
||||
}
|
||||
fn module_interns_helpers_mut(
|
||||
&mut self,
|
||||
) -> (
|
||||
|
|
|
@ -28,6 +28,7 @@ use roc_mono::list_element_layout;
|
|||
mod generic64;
|
||||
mod object_builder;
|
||||
pub use object_builder::build_module;
|
||||
use roc_target::TargetInfo;
|
||||
mod run_roc;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
@ -303,6 +304,7 @@ trait Backend<'a> {
|
|||
fn interns_mut(&mut self) -> &mut Interns;
|
||||
fn interner(&self) -> &STLayoutInterner<'a>;
|
||||
fn relocations_mut(&mut self) -> &mut Vec<'a, Relocation>;
|
||||
fn target_info(&self) -> TargetInfo;
|
||||
|
||||
fn interner_mut(&mut self) -> &mut STLayoutInterner<'a> {
|
||||
self.module_interns_helpers_mut().1
|
||||
|
|
|
@ -797,6 +797,7 @@ fn build_proc<'a, B: Backend<'a>>(
|
|||
proc: Proc<'a>,
|
||||
) {
|
||||
let mut local_data_index = 0;
|
||||
let target_info = backend.target_info();
|
||||
let (proc_data, relocs, rc_proc_names) = backend.build_proc(proc, layout_ids);
|
||||
let proc_offset = output.add_symbol_data(proc_id, section_id, &proc_data, 16);
|
||||
for reloc in relocs.iter() {
|
||||
|
@ -882,11 +883,19 @@ fn build_proc<'a, B: Backend<'a>>(
|
|||
}
|
||||
|
||||
if let Some(sym_id) = output.symbol_id(name.as_bytes()) {
|
||||
let encoding = match target_info.architecture {
|
||||
roc_target::Architecture::Aarch32 => todo!(),
|
||||
roc_target::Architecture::Aarch64 => RelocationEncoding::AArch64Call,
|
||||
roc_target::Architecture::Wasm32 => todo!(),
|
||||
roc_target::Architecture::X86_32 => todo!(),
|
||||
roc_target::Architecture::X86_64 => RelocationEncoding::X86Branch,
|
||||
};
|
||||
|
||||
write::Relocation {
|
||||
offset: offset + proc_offset,
|
||||
size: 32,
|
||||
kind: RelocationKind::PltRelative,
|
||||
encoding: RelocationEncoding::X86Branch,
|
||||
encoding,
|
||||
symbol: sym_id,
|
||||
addend: -4,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue