mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
when encountering memcpy, actually look for roc_memcpy
This commit is contained in:
parent
5311d9a02b
commit
7c91aa79c9
1 changed files with 16 additions and 8 deletions
|
@ -1065,11 +1065,9 @@ impl AppSections {
|
|||
|
||||
let address = symbol.as_ref().map(|s| s.address()).unwrap_or_default();
|
||||
let name = symbol.and_then(|s| s.name()).unwrap_or_default();
|
||||
let name = redirect_libc_functions(name).unwrap_or(name).to_string();
|
||||
|
||||
relocations
|
||||
.entry(name.to_string())
|
||||
.or_default()
|
||||
.push(AppRelocation {
|
||||
relocations.entry(name).or_default().push(AppRelocation {
|
||||
offset_in_section,
|
||||
address,
|
||||
relocation,
|
||||
|
@ -1415,6 +1413,16 @@ fn relocate_dummy_dll_entries(executable: &mut [u8], md: &PeMetadata) {
|
|||
dir.size.set(LE, new_reloc_directory_size as u32);
|
||||
}
|
||||
|
||||
/// Redirect `memcpy` and similar libc functions to their roc equivalents
|
||||
pub(crate) fn redirect_libc_functions(name: &str) -> Option<&str> {
|
||||
match name {
|
||||
"memcpy" => Some("roc_memcpy"),
|
||||
"memset" => Some("roc_memset"),
|
||||
"memmove" => Some("roc_memmove"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
const PE_DYNHOST: &[u8] = include_bytes!("../dynhost_benchmarks_windows.exe") as &[_];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue