Skip to content

Commit cddc960

Browse files
committed
Use JITModule::get_address in relocate_for_jit
This way we will use the actual personality function defined by the standard library version of the jitted program rather than the copy of rustc. In addition this is necessary to be able to mangle the symbol name of the personality function in the future as extern {} wouldn't be able to refer to it if the symbol name is mangled.
1 parent e0b2d43 commit cddc960

1 file changed

Lines changed: 3 additions & 21 deletions

File tree

src/debuginfo/emit.rs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -81,34 +81,16 @@ impl WriterRelocate {
8181
/// Perform the collected relocations to be usable for JIT usage.
8282
#[cfg(all(feature = "jit", not(windows)))]
8383
pub(super) fn relocate_for_jit(mut self, jit_module: &cranelift_jit::JITModule) -> Vec<u8> {
84-
use cranelift_module::Module;
85-
8684
for reloc in self.relocs.drain(..) {
8785
match reloc.name {
8886
super::DebugRelocName::Section(_) => unreachable!(),
8987
super::DebugRelocName::Symbol(sym) => {
9088
let addr = if sym & 1 << 31 == 0 {
9189
let func_id = FuncId::from_u32(sym.try_into().unwrap());
92-
// FIXME make JITModule::get_address public and use it here instead.
93-
// HACK rust_eh_personality is likely not defined in the same crate,
94-
// so get_finalized_function won't work. Use the rust_eh_personality
95-
// of cg_clif itself, which is likely ABI compatible.
96-
if jit_module.declarations().get_function_decl(func_id).name.as_deref()
97-
== Some("rust_eh_personality")
98-
{
99-
unsafe extern "C" {
100-
fn rust_eh_personality() -> !;
101-
}
102-
rust_eh_personality as *const u8
103-
} else {
104-
jit_module.get_finalized_function(func_id)
105-
}
90+
jit_module.get_address(&func_id.into())
10691
} else {
107-
jit_module
108-
.get_finalized_data(DataId::from_u32(
109-
u32::try_from(sym).unwrap() & !(1 << 31),
110-
))
111-
.0
92+
let data_id = DataId::from_u32(u32::try_from(sym).unwrap() & !(1 << 31));
93+
jit_module.get_address(&data_id.into())
11294
};
11395

11496
let val = (addr as u64 as i64 + reloc.addend) as u64;

0 commit comments

Comments
 (0)