MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / patch_call_pair

Function patch_call_pair

crates/asm-to-binary/src/object_linker.rs:424–445  ·  view source on GitHub ↗
(
    section_bytes: &mut [u8],
    site: usize,
    site_abs: u64,
    target_abs: u64,
    addend: i64,
)

Source from the content-addressed store, hash-verified

422 map: &'a [(&str, u64, u64)],
423 addr: u64,
424) -> Option<(&'a str, u64)> {
425 for &(name, start, end) in map {
426 let in_range = if start == end {
427 addr == start
428 } else {
429 addr >= start && addr < end
430 };
431 if in_range {
432 return Some((name, start));
433 }
434 }
435 None
436}
437
438// --- PC-relative splitting ---
439
440fn read_u32_at(buf: &[u8], off: usize) -> Result<u32, LinkerError> {
441 let end = off + 4;
442 let Some(bytes) = buf.get(off..end) else {
443 return Err(LinkerError::new(format!(
444 "relocation read at offset {off} exceeds section size {}",
445 buf.len()
446 )));
447 };
448 let arr: [u8; 4] = bytes

Callers 1

linkMethod · 0.85

Calls 3

read_u32_atFunction · 0.85
write_u32_atFunction · 0.85
pcrel_splitFunction · 0.70

Tested by

no test coverage detected