mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-27 09:38:57 +00:00
* 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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user