diff options
author | Kevin Buettner <kevinb@redhat.com> | 2012-03-03 01:23:45 +0000 |
---|---|---|
committer | Kevin Buettner <kevinb@redhat.com> | 2012-03-03 01:23:45 +0000 |
commit | d98bfeb0233c622e936bdda16ff03277077f5ca2 (patch) | |
tree | e0a9fd593d3f088e78995b29fc3a2f33087f9ba1 /sim/rx/load.c | |
parent | 636b802b4e0e0bfa08745d20c468bac0a38e9fa1 (diff) | |
download | gdb-d98bfeb0233c622e936bdda16ff03277077f5ca2.zip gdb-d98bfeb0233c622e936bdda16ff03277077f5ca2.tar.gz gdb-d98bfeb0233c622e936bdda16ff03277077f5ca2.tar.bz2 |
Update rx sim so that it'll print load statistics.
Diffstat (limited to 'sim/rx/load.c')
-rw-r--r-- | sim/rx/load.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/sim/rx/load.c b/sim/rx/load.c index 39eb261..f6fc56e 100644 --- a/sim/rx/load.c +++ b/sim/rx/load.c @@ -28,9 +28,36 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "libbfd.h" #include "cpu.h" #include "mem.h" +#include "load.h" #include "elf/internal.h" #include "elf/common.h" +/* Helper function for invoking a GDB-specified printf. */ +static void +xprintf (host_callback *callback, const char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + + (*callback->vprintf_filtered) (callback, fmt, ap); + + va_end (ap); +} + +/* Given a file offset, look up the section name. */ +static const char * +find_section_name_by_offset (bfd *abfd, file_ptr filepos) +{ + asection *s; + + for (s = abfd->sections; s; s = s->next) + if (s->filepos == filepos) + return bfd_get_section_name (abfd, s); + + return "(unknown)"; +} + /* A note about endianness and swapping... The RX chip is CISC-like in that the opcodes are variable length @@ -56,7 +83,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ encoded in little-endian format. */ void -rx_load (bfd *prog) +rx_load (bfd *prog, host_callback *callback) { unsigned long highest_addr_loaded = 0; Elf_Internal_Phdr * phdrs; @@ -105,6 +132,11 @@ rx_load (bfd *prog) if (verbose > 1) fprintf (stderr, "[load segment: lma=%08x vma=%08x size=%08x]\n", (int) base, (int) p->p_vaddr, (int) size); + if (callback) + xprintf (callback, + "Loading section %s, size %#lx lma %08lx vma %08lx\n", + find_section_name_by_offset (prog, p->p_offset), + size, base, p->p_vaddr); buf = malloc (size); if (buf == NULL) |