diff --git a/src/binary_parser.rs b/src/binary_parser.rs index e9bd52a4..a0b3f688 100644 --- a/src/binary_parser.rs +++ b/src/binary_parser.rs @@ -12,6 +12,8 @@ pub struct BinaryInfo { pub symbols: HashMap, pub bss_addr: u64, pub bss_size: u64, + pub pyruntime_addr: u64, + pub pyruntime_size: u64, #[allow(dead_code)] pub addr: u64, #[allow(dead_code)] @@ -65,11 +67,23 @@ pub fn parse_binary(filename: &Path, addr: u64, size: u64) -> Result Result Result Result Result Err(format_err!("Unhandled binary type")), } diff --git a/src/python_process_info.rs b/src/python_process_info.rs index 65befeb1..55b8cbef 100644 --- a/src/python_process_info.rs +++ b/src/python_process_info.rs @@ -437,6 +437,21 @@ fn get_interpreter_address_from_binary

( where P: ProcessMemory, { + // First check the pyruntime section it was found + if binary.pyruntime_addr != 0 { + let bss = process.copy( + binary.pyruntime_addr as usize, + binary.pyruntime_size as usize, + )?; + #[allow(clippy::cast_ptr_alignment)] + let addrs = unsafe { + slice::from_raw_parts(bss.as_ptr() as *const usize, bss.len() / size_of::()) + }; + if let Ok(addr) = check_interpreter_addresses(addrs, maps, process, version) { + return Ok(addr); + } + } + // We're going to scan the BSS/data section for things, and try to narrowly scan things that // look like pointers to PyinterpreterState let bss = process.copy(binary.bss_addr as usize, binary.bss_size as usize)?;