Skip to content

Commit

Permalink
Merge pull request #117 from afranchuk/in-memory-soname
Browse files Browse the repository at this point in the history
Read ELF SONAMEs directly from process memory when possible.
  • Loading branch information
gabrielesvelto authored Jun 27, 2024
2 parents ec2c008 + cfdbc8f commit 9e748df
Show file tree
Hide file tree
Showing 10 changed files with 674 additions and 363 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
# ]
[target.x86_64-linux-android]
linker = "x86_64-linux-android30-clang"
# By default the linker _doesn't_ generate a build-id, however we want one for our tests.
rustflags = ["-C", "link-args=-Wl,--build-id=sha1"]
runner = [".cargo/android-runner.sh"]
8 changes: 5 additions & 3 deletions src/bin/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod linux {
use super::*;
use minidump_writer::{
minidump_writer::STOP_TIMEOUT,
module_reader,
ptrace_dumper::{PtraceDumper, AT_SYSINFO_EHDR},
LINUX_GATE_LIBRARY_NAME,
};
Expand Down Expand Up @@ -100,7 +101,7 @@ mod linux {
}
}
let idx = found_exe.unwrap();
let id = dumper.elf_identifier_for_mapping_index(idx)?;
let module_reader::BuildId(id) = dumper.from_process_memory_for_index(idx)?;
dumper.resume_threads()?;
assert!(!id.is_empty());
assert!(id.iter().any(|&x| x > 0));
Expand Down Expand Up @@ -133,11 +134,12 @@ mod linux {
let ppid = getppid().as_raw();
let mut dumper = PtraceDumper::new(ppid, STOP_TIMEOUT)?;
let mut found_linux_gate = false;
for mut mapping in dumper.mappings.clone() {
for mapping in dumper.mappings.clone() {
if mapping.name == Some(LINUX_GATE_LIBRARY_NAME.into()) {
found_linux_gate = true;
dumper.suspend_threads()?;
let id = PtraceDumper::elf_identifier_for_mapping(&mut mapping, ppid)?;
let module_reader::BuildId(id) =
dumper.from_process_memory_for_mapping(&mapping)?;
test!(!id.is_empty(), "id-vec is empty")?;
test!(id.iter().any(|&x| x > 0), "all id elements are 0")?;
dumper.resume_threads()?;
Expand Down
2 changes: 1 addition & 1 deletion src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
mod android;
pub mod app_memory;
pub(crate) mod auxv_reader;
pub mod build_id_reader;
pub mod crash_context;
mod dso_debug;
mod dumper_cpu_info;
pub mod errors;
pub mod maps_reader;
pub mod minidump_writer;
pub mod module_reader;
pub mod ptrace_dumper;
pub(crate) mod sections;
pub mod thread_info;
Expand Down
319 changes: 0 additions & 319 deletions src/linux/build_id_reader.rs

This file was deleted.

Loading

0 comments on commit 9e748df

Please sign in to comment.