OLD | NEW |
1 /* Reading symbol files from memory. | 1 /* Reading symbol files from memory. |
2 | 2 |
3 Copyright (C) 1986-1987, 1989, 1991, 1994-1996, 1998, 2000-2005, | 3 Copyright (C) 1986-1987, 1989, 1991, 1994-1996, 1998, 2000-2005, |
4 2007-2012 Free Software Foundation, Inc. | 4 2007-2012 Free Software Foundation, Inc. |
5 | 5 |
6 This file is part of GDB. | 6 This file is part of GDB. |
7 | 7 |
8 This program is free software; you can redistribute it and/or modify | 8 This program is free software; you can redistribute it and/or modify |
9 it under the terms of the GNU General Public License as published by | 9 it under the terms of the GNU General Public License as published by |
10 the Free Software Foundation; either version 3 of the License, or | 10 the Free Software Foundation; either version 3 of the License, or |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "objfiles.h" | 48 #include "objfiles.h" |
49 #include "exceptions.h" | 49 #include "exceptions.h" |
50 #include "gdbcmd.h" | 50 #include "gdbcmd.h" |
51 #include "target.h" | 51 #include "target.h" |
52 #include "value.h" | 52 #include "value.h" |
53 #include "symfile.h" | 53 #include "symfile.h" |
54 #include "observer.h" | 54 #include "observer.h" |
55 #include "auxv.h" | 55 #include "auxv.h" |
56 #include "elf/common.h" | 56 #include "elf/common.h" |
57 | 57 |
| 58 /* Verify parameters of target_read_memory_bfd and target_read_memory are |
| 59 compatible. */ |
| 60 |
| 61 gdb_static_assert (sizeof (CORE_ADDR) == sizeof (bfd_vma)); |
| 62 gdb_static_assert (sizeof (gdb_byte) == sizeof (bfd_byte)); |
| 63 gdb_static_assert (sizeof (ssize_t) <= sizeof (bfd_size_type)); |
| 64 |
| 65 /* Provide bfd/ compatible prototype for target_read_memory. Casting would not |
| 66 be enough as LEN width may differ. */ |
| 67 |
| 68 static int |
| 69 target_read_memory_bfd (bfd_vma memaddr, bfd_byte *myaddr, bfd_size_type len) |
| 70 { |
| 71 /* MYADDR must be already allocated for the LEN size so it has to fit in |
| 72 ssize_t. */ |
| 73 gdb_assert ((ssize_t) len == len); |
| 74 |
| 75 return target_read_memory (memaddr, myaddr, len); |
| 76 } |
58 | 77 |
59 /* Read inferior memory at ADDR to find the header of a loaded object file | 78 /* Read inferior memory at ADDR to find the header of a loaded object file |
60 and read its in-core symbols out of inferior memory. TEMPL is a bfd | 79 and read its in-core symbols out of inferior memory. TEMPL is a bfd |
61 representing the target's format. NAME is the name to use for this | 80 representing the target's format. NAME is the name to use for this |
62 symbol file in messages; it can be NULL or a malloc-allocated string | 81 symbol file in messages; it can be NULL or a malloc-allocated string |
63 which will be attached to the BFD. */ | 82 which will be attached to the BFD. */ |
64 static struct objfile * | 83 static struct objfile * |
65 symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name, | 84 symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name, |
66 int from_tty) | 85 int from_tty) |
67 { | 86 { |
68 struct objfile *objf; | 87 struct objfile *objf; |
69 struct bfd *nbfd; | 88 struct bfd *nbfd; |
70 struct bfd_section *sec; | 89 struct bfd_section *sec; |
71 bfd_vma loadbase; | 90 bfd_vma loadbase; |
72 struct section_addr_info *sai; | 91 struct section_addr_info *sai; |
73 unsigned int i; | 92 unsigned int i; |
74 struct cleanup *cleanup; | 93 struct cleanup *cleanup; |
75 | 94 |
76 if (bfd_get_flavour (templ) != bfd_target_elf_flavour) | 95 if (bfd_get_flavour (templ) != bfd_target_elf_flavour) |
77 error (_("add-symbol-file-from-memory not supported for this target")); | 96 error (_("add-symbol-file-from-memory not supported for this target")); |
78 | 97 |
79 nbfd = bfd_elf_bfd_from_remote_memory (templ, addr, &loadbase, | 98 nbfd = bfd_elf_bfd_from_remote_memory (templ, addr, &loadbase, |
80 » » » » » target_read_memory); | 99 » » » » » target_read_memory_bfd); |
81 if (nbfd == NULL) | 100 if (nbfd == NULL) |
82 error (_("Failed to read a valid object file image from memory.")); | 101 error (_("Failed to read a valid object file image from memory.")); |
83 | 102 |
84 if (name == NULL) | 103 if (name == NULL) |
85 nbfd->filename = xstrdup ("shared object read from target memory"); | 104 nbfd->filename = xstrdup ("shared object read from target memory"); |
86 else | 105 else |
87 nbfd->filename = name; | 106 nbfd->filename = name; |
88 | 107 |
89 if (!bfd_check_format (nbfd, bfd_object)) | 108 if (!bfd_check_format (nbfd, bfd_object)) |
90 { | 109 { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 _("Load the symbols out of memory from a " | 242 _("Load the symbols out of memory from a " |
224 "dynamically loaded object file.\n" | 243 "dynamically loaded object file.\n" |
225 "Give an expression for the address " | 244 "Give an expression for the address " |
226 "of the file's shared object file header."), | 245 "of the file's shared object file header."), |
227 &cmdlist); | 246 &cmdlist); |
228 | 247 |
229 /* Want to know of each new inferior so that its vsyscall info can | 248 /* Want to know of each new inferior so that its vsyscall info can |
230 be extracted. */ | 249 be extracted. */ |
231 observer_attach_inferior_created (add_vsyscall_page); | 250 observer_attach_inferior_created (add_vsyscall_page); |
232 } | 251 } |
OLD | NEW |