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

Function word_at_linked_address

crates/asm-to-binary/tests/object_linker.rs:18–29  ·  view source on GitHub ↗
(assembled: &asm_to_binary::AssembledOutput, addr: u64)

Source from the content-addressed store, hash-verified

16}
17
18fn word_at_linked_address(assembled: &asm_to_binary::AssembledOutput, addr: u64) -> u32 {
19 let mut base = 0u64;
20 for section in assembled.sections_iter() {
21 let end = base + section.bytes.len() as u64;
22 if addr >= base && addr + 4 <= end {
23 let off = (addr - base) as usize;
24 return word_at(section.bytes, off);
25 }
26 base = end;
27 }
28 panic!("no linked section contains address {addr:#x}");
29}
30
31#[test]
32fn links_two_objects_and_resolves_call_relocation() {

Calls 2

word_atFunction · 0.85
sections_iterMethod · 0.80

Tested by

no test coverage detected