diff options
author | Pedro Alves <palves@redhat.com> | 2009-05-22 03:01:45 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2009-05-22 03:01:45 +0000 |
commit | 348f8c02f44abcb5f5b0ab1a0c597001ee35da79 (patch) | |
tree | 451226879b03bbb2e0c0e52e95af07c1d13832ec /gdb/bfd-target.c | |
parent | 415756309f1044b3c3345e7cbf6c680a263ff44a (diff) | |
download | binutils-gdb-348f8c02f44abcb5f5b0ab1a0c597001ee35da79.tar.gz |
* bfd-target.c: Don't include gdb_assert.h or gdb_string.h.
Include exec.h.
(struct section_closure): Delete.
(add_to_section_table): Delete.
(build_target_sections_from_bfd): Delete.
(target_bfd_xfer_partial): Use section_table_xfer_memory_partial.
(target_bfd_reopen): Use build_section_table.
* exec.c (xfer_memory): Move most code except for overlay
debugging support from here...
(section_table_xfer_memory): ... to this new function.
(section_table_xfer_memory_partial): New.
* exec.h (section_table_xfer_memory_partial): Declare.
* bfd-target.h (build_target_sections_from_bfd): Delete
declaration.
Diffstat (limited to 'gdb/bfd-target.c')
-rw-r--r-- | gdb/bfd-target.c | 80 |
1 files changed, 8 insertions, 72 deletions
diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c index 5ce9e19f3a0..3eaae841616 100644 --- a/gdb/bfd-target.c +++ b/gdb/bfd-target.c @@ -20,51 +20,7 @@ #include "defs.h" #include "target.h" #include "bfd-target.h" -#include "gdb_assert.h" -#include "gdb_string.h" - -/* Locate all mappable sections of a BFD file, filling in a target - section for each. */ - -struct section_closure -{ - struct section_table *end; -}; - -static void -add_to_section_table (struct bfd *abfd, struct bfd_section *asect, - void *closure) -{ - struct section_closure *pp = closure; - flagword aflag; - - /* NOTE: cagney/2003-10-22: Is this pruning useful? */ - aflag = bfd_get_section_flags (abfd, asect); - if (!(aflag & SEC_ALLOC)) - return; - if (bfd_section_size (abfd, asect) == 0) - return; - pp->end->bfd = abfd; - pp->end->the_bfd_section = asect; - pp->end->addr = bfd_section_vma (abfd, asect); - pp->end->endaddr = pp->end->addr + bfd_section_size (abfd, asect); - pp->end++; -} - -void -build_target_sections_from_bfd (struct target_ops *targ, struct bfd *abfd) -{ - unsigned count; - struct section_table *start; - struct section_closure cl; - - count = bfd_count_sections (abfd); - target_resize_to_sections (targ, count); - start = targ->to_sections; - cl.end = targ->to_sections; - bfd_map_over_sections (abfd, add_to_section_table, &cl); - gdb_assert (cl.end - start <= count); -} +#include "exec.h" static LONGEST target_bfd_xfer_partial (struct target_ops *ops, @@ -76,32 +32,9 @@ target_bfd_xfer_partial (struct target_ops *ops, switch (object) { case TARGET_OBJECT_MEMORY: - { - struct section_table *s = target_section_by_addr (ops, offset); - if (s == NULL) - return -1; - /* If the length extends beyond the section, truncate it. Be - careful to not suffer from overflow (wish S contained a - length). */ - if ((offset - s->addr + len) > (s->endaddr - s->addr)) - len = (s->endaddr - s->addr) - (offset - s->addr); - if (readbuf != NULL - && !bfd_get_section_contents (s->bfd, s->the_bfd_section, - readbuf, offset - s->addr, len)) - return -1; -#if 1 - if (writebuf != NULL) - return -1; -#else - /* FIXME: cagney/2003-10-31: The BFD interface doesn't yet - take a const buffer. */ - if (writebuf != NULL - && !bfd_set_section_contents (s->bfd, s->the_bfd_section, - writebuf, offset - s->addr, len)) - return -1; -#endif - return len; - } + return section_table_xfer_memory_partial (readbuf, writebuf, offset, len, + ops->to_sections, + ops->to_sections_end); default: return -1; } @@ -125,6 +58,9 @@ target_bfd_reopen (struct bfd *bfd) t->to_xfer_partial = target_bfd_xfer_partial; t->to_xclose = target_bfd_xclose; t->to_data = bfd; - build_target_sections_from_bfd (t, bfd); + + build_section_table (bfd, + &t->to_sections, + &t->to_sections_end); return t; } |