Add undefined rc procs for LinkedData too

This commit is contained in:
Agus Zubiaga 2023-10-08 00:53:04 -03:00 committed by Folkert
parent 99369dec85
commit ad127eb395
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -920,6 +920,8 @@ fn build_proc<'a, B: Backend<'a>>(
} }
} }
Relocation::LinkedData { offset, name } => { Relocation::LinkedData { offset, name } => {
add_undefined_rc_proc(output, name, &rc_proc_names);
if let Some(sym_id) = output.symbol_id(name.as_bytes()) { if let Some(sym_id) = output.symbol_id(name.as_bytes()) {
if cfg!(all(target_arch = "aarch64", target_os = "linux")) { if cfg!(all(target_arch = "aarch64", target_os = "linux")) {
// 700: 90000001 adrp x1, 0x0 <std.builtin.default_panic> // 700: 90000001 adrp x1, 0x0 <std.builtin.default_panic>
@ -1005,6 +1007,21 @@ fn build_proc<'a, B: Backend<'a>>(
output.add_symbol(builtin_symbol); output.add_symbol(builtin_symbol);
} }
add_undefined_rc_proc(output, name, &rc_proc_names);
if let Some(sym_id) = output.symbol_id(name.as_bytes()) {
create_relocation(target_info, sym_id, offset + proc_offset)
} else {
internal_error!("failed to find fn symbol for {:?}", name);
}
}
Relocation::JmpToReturn { .. } => unreachable!(),
};
relocations.push((section_id, elfreloc));
}
}
fn add_undefined_rc_proc(output: &mut Object<'_>, name: &String, rc_proc_names: &Vec<'_, (symbol::Symbol, String)>) {
// If the symbol is an undefined reference counting procedure, we need to add it here. // If the symbol is an undefined reference counting procedure, we need to add it here.
if output.symbol_id(name.as_bytes()).is_none() { if output.symbol_id(name.as_bytes()).is_none() {
for (sym, rc_name) in rc_proc_names.iter() { for (sym, rc_name) in rc_proc_names.iter() {
@ -1029,15 +1046,4 @@ fn build_proc<'a, B: Backend<'a>>(
} }
} }
} }
if let Some(sym_id) = output.symbol_id(name.as_bytes()) {
create_relocation(target_info, sym_id, offset + proc_offset)
} else {
internal_error!("failed to find fn symbol for {:?}", name);
}
}
Relocation::JmpToReturn { .. } => unreachable!(),
};
relocations.push((section_id, elfreloc));
}
} }