Hopefully finish the memory manager implementation for llvm RuntimeDyLd

This commit is contained in:
Lachlan Sneff
2019-02-27 17:21:20 -08:00
parent d55387d581
commit 5d77769381
6 changed files with 176 additions and 47 deletions

View File

@ -616,7 +616,7 @@ fn parse_function(
let struct_value = basic_value.into_struct_value();
for i in 0..(count as u32) {
let value =
builder.build_extract_value(struct_value, i, &state.var_name());
builder.build_extract_value(struct_value, i, &state.var_name()).unwrap();
state.push1(value);
}
}

View File

@ -0,0 +1,8 @@
#[cfg(target_family = "unix")]
mod unix;
#[cfg(target_family = "unix")]
pub use self::unix::*;
#[cfg(target_family = "windows")]
compile_error!("windows not yet supported for the llvm-based compiler backend");

View File

@ -0,0 +1,40 @@
extern "C" {
fn __register_frame(frame: *const u8);
fn __deregister_frame(frame: *const u8);
}
pub unsafe fn register_eh_frames(eh_frames: *const u8, num_bytes: usize) {
visit_frame_desc_entries(eh_frames, num_bytes, |frame| __register_frame(frame));
}
unsafe fn visit_frame_desc_entries<F>(eh_frames: *const u8, num_bytes: usize, visitor: F)
where
F: Fn(*const u8),
{
let mut next = eh_frames;
let mut end = eh_frames.add(num_bytes);
loop {
if next >= end {
break;
}
let cfi = next;
let mut cfi_num_bytes = (next as *const u32).read_unaligned() as u64;
assert!(cfi_num_bytes != 0);
next = next.add(4);
if num_bytes == 0xffffffff {
let cfi_num_bytes64 = (next as *const u64).read_unaligned();
cfi_num_bytes = cfi_num_bytes64;
next = next.add(8);
}
let cie_offset = (next as *const u32).read_unaligned();
if cie_offset != 0 {
visitor(cfi);
}
next = next.add(cfi_num_bytes as usize);
}
}