diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2012-06-04 14:35:25 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2012-06-04 14:35:25 +0000 |
commit | fe78531dcfcd709286a292c7707b987685f61919 (patch) | |
tree | 7cff9e175034d5854a0501d29f3a7695f201707c /gdb | |
parent | 78e5175a52db89d5e51fdbcb020ef040f68fe5c1 (diff) | |
download | binutils-fe78531dcfcd709286a292c7707b987685f61919.zip binutils-fe78531dcfcd709286a292c7707b987685f61919.tar.gz binutils-fe78531dcfcd709286a292c7707b987685f61919.tar.bz2 |
bfd/
* bfd-in.h (bfd_elf_bfd_from_remote_memory): Make LEN argument
of target_read_memory as bfd_size_type.
* bfd-in2.h: Regenerate.
* elf-bfd.h (elf_backend_bfd_from_remote_memory): Make LEN
argument of target_read_memory as bfd_size_type.
(_bfd_elf32_bfd_from_remote_memory): Likewise.
(_bfd_elf64_bfd_from_remote_memory): Likewise.
* elf.c (bfd_elf_bfd_from_remote_memory): Likewise.
* elfcode.h (NAME(_bfd_elf,bfd_from_remote_memory)): Likewise.
gdb/
* symfile-mem.c: 3 new gdb_static_assert for target_read_memory_bfd
parameters.
(target_read_memory_bfd): New function.
(symbol_file_add_from_memory): Use it.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/symfile-mem.c | 21 |
2 files changed, 27 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 20fd853..0f5d4d9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2012-06-04 Jan Kratochvil <jan.kratochvil@redhat.com> + + * symfile-mem.c: 3 new gdb_static_assert for target_read_memory_bfd + parameters. + (target_read_memory_bfd): New function. + (symbol_file_add_from_memory): Use it. + 2012-06-03 Doug Evans <dje@google.com> * symtab.c (lookup_global_symbol_from_objfile): Only scan blockvector diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c index 91125e1..45d95a7 100644 --- a/gdb/symfile-mem.c +++ b/gdb/symfile-mem.c @@ -55,6 +55,25 @@ #include "auxv.h" #include "elf/common.h" +/* Verify parameters of target_read_memory_bfd and target_read_memory are + compatible. */ + +gdb_static_assert (sizeof (CORE_ADDR) == sizeof (bfd_vma)); +gdb_static_assert (sizeof (gdb_byte) == sizeof (bfd_byte)); +gdb_static_assert (sizeof (size_t) <= sizeof (bfd_size_type)); + +/* Provide bfd/ compatible prototype for target_read_memory. Casting would not + be enough as LEN width may differ. */ + +static int +target_read_memory_bfd (bfd_vma memaddr, bfd_byte *myaddr, bfd_size_type len) +{ + /* MYADDR must be already allocated for the LEN size so it has to fit in + size_t. */ + gdb_assert ((size_t) len == len); + + return target_read_memory (memaddr, myaddr, len); +} /* Read inferior memory at ADDR to find the header of a loaded object file and read its in-core symbols out of inferior memory. TEMPL is a bfd @@ -77,7 +96,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name, error (_("add-symbol-file-from-memory not supported for this target")); nbfd = bfd_elf_bfd_from_remote_memory (templ, addr, &loadbase, - target_read_memory); + target_read_memory_bfd); if (nbfd == NULL) error (_("Failed to read a valid object file image from memory.")); |