aboutsummaryrefslogtreecommitdiff
path: root/gdb/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/exec.c')
-rw-r--r--gdb/exec.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/gdb/exec.c b/gdb/exec.c
index 7f53a50..74c61eb 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -530,6 +530,53 @@ remove_target_sections (void *owner)
+enum target_xfer_status
+exec_read_partial_read_only (gdb_byte *readbuf, ULONGEST offset,
+ ULONGEST len, ULONGEST *xfered_len)
+{
+ /* It's unduly pedantic to refuse to look at the executable for
+ read-only pieces; so do the equivalent of readonly regions aka
+ QTro packet. */
+ if (exec_bfd != NULL)
+ {
+ asection *s;
+ bfd_size_type size;
+ bfd_vma vma;
+
+ for (s = exec_bfd->sections; s; s = s->next)
+ {
+ if ((s->flags & SEC_LOAD) == 0
+ || (s->flags & SEC_READONLY) == 0)
+ continue;
+
+ vma = s->vma;
+ size = bfd_get_section_size (s);
+ if (vma <= offset && offset < (vma + size))
+ {
+ ULONGEST amt;
+
+ amt = (vma + size) - offset;
+ if (amt > len)
+ amt = len;
+
+ amt = bfd_get_section_contents (exec_bfd, s,
+ readbuf, offset - vma, amt);
+
+ if (amt == 0)
+ return TARGET_XFER_EOF;
+ else
+ {
+ *xfered_len = amt;
+ return TARGET_XFER_OK;
+ }
+ }
+ }
+ }
+
+ /* Indicate failure to find the requested memory block. */
+ return TARGET_XFER_E_IO;
+}
+
VEC(mem_range_s) *
section_table_available_memory (VEC(mem_range_s) *memory,
CORE_ADDR memaddr, ULONGEST len,