aboutsummaryrefslogtreecommitdiff
path: root/examples/armv4t/gdb/libraries.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/armv4t/gdb/libraries.rs')
-rw-r--r--examples/armv4t/gdb/libraries.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/examples/armv4t/gdb/libraries.rs b/examples/armv4t/gdb/libraries.rs
new file mode 100644
index 0000000..0c64dd7
--- /dev/null
+++ b/examples/armv4t/gdb/libraries.rs
@@ -0,0 +1,28 @@
+use super::copy_range_to_buf;
+use crate::emu::Emu;
+use gdbstub::target;
+use gdbstub::target::TargetResult;
+
+impl target::ext::libraries::LibrariesSvr4 for Emu {
+ fn get_libraries_svr4(
+ &self,
+ offset: u64,
+ length: usize,
+ buf: &mut [u8],
+ ) -> TargetResult<usize, Self> {
+ // `l_ld` is the address of the `PT_DYNAMIC` ELF segment, so fake an
+ // address here.
+ //
+ // The `main-lm`, `lm`, and `lmid` seem to refer to in-memory structures
+ // which gdb may read, but gdb also seems to work well enough if they're
+ // null-ish or otherwise pointing to non-present things.
+ let xml = r#"
+<library-list-svr4 version="1.0" main-lm="0x4">
+ <library name="/test.elf" lm="0x8" l_addr="0" l_ld="0" lmid="0x14"/>
+</library-list-svr4>
+"#
+ .trim()
+ .as_bytes();
+ Ok(copy_range_to_buf(xml, offset, length, buf))
+ }
+}