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 pcrel_split(offset: i64) -> (i32, i32) {
441 let lo12 = ((offset & 0xFFF) as i32).wrapping_sub(if offset & 0x800 != 0 { 0x1000 } else { 0 });
442 let hi20 = ((offset - lo12 as i64) >> 12) as i32;
443 (hi20, lo12)
444}
445
446fn read_u32_at(buf: &[u8], off: usize) -> Result<u32, LinkerError> {
447 let end = off + 4;
448 let Some(bytes) = buf.get(off..end) else {

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