summaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authorJim Blandy <jimb@codesourcery.com>2004-05-02 10:14:02 +0000
committerJim Blandy <jimb@codesourcery.com>2004-05-02 10:14:02 +0000
commitee8d94458f58ccfe055715e1d343fbaea86af32c (patch)
tree93abf5dde0d3bde5c3adf0e2531cdb6b66f79217 /gdb/symfile.c
parent9f85cba6e38997c7143261e1255c56513908ade6 (diff)
downloadgdb-ee8d94458f58ccfe055715e1d343fbaea86af32c.tar.gz
Move the symbol-file-from-memory functions into their own file.
* symfile-mem.c, symfile-mem.h: New files. * symfile.c (symbol_file_add_from_bfd): New function. (symbol_file_add): Call symbol_file_add_from_bfd. (symbol_file_add_from_memory, add_symbol_file_from_memory_command): Moved to symfile-mem.c. (_initialize_symfile): Move definition of add-symbol-file-from-memory command to symfile-mem.c. * symfile.h (symbol_file_add_from_bfd): New declaration. * config/i386/linux.mt (TDEPFILES): Add symfile-mem.o. * config/powerpc/linux.mt (TDEPFILES): Same. * Makefile.in (SFILES): Add symfile-mem.c. (symfile_mem_h): New variable. (HFILES_NO_SRCDIR): Add symfile-mem.h. (symfile-mem.o): New rule.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c115
1 files changed, 18 insertions, 97 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 7c83011426a..b688cae7eb9 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -910,6 +910,22 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
}
+/* Process the symbol file ABFD, as either the main file or as a
+ dynamically loaded file.
+
+ See symbol_file_add_with_addrs_or_offsets's comments for
+ details. */
+struct objfile *
+symbol_file_add_from_bfd (bfd *abfd, int from_tty,
+ struct section_addr_info *addrs,
+ int mainline, int flags)
+{
+ return symbol_file_add_with_addrs_or_offsets (abfd,
+ from_tty, addrs, 0, 0,
+ mainline, flags);
+}
+
+
/* Process a symbol file, as either the main file or as a dynamically
loaded file. See symbol_file_add_with_addrs_or_offsets's comments
for details. */
@@ -917,9 +933,8 @@ struct objfile *
symbol_file_add (char *name, int from_tty, struct section_addr_info *addrs,
int mainline, int flags)
{
- return symbol_file_add_with_addrs_or_offsets (symfile_bfd_open (name),
- from_tty, addrs, 0, 0,
- mainline, flags);
+ return symbol_file_add_from_bfd (symfile_bfd_open (name), from_tty,
+ addrs, mainline, flags);
}
@@ -1769,93 +1784,6 @@ add_shared_symbol_files_command (char *args, int from_tty)
#endif
}
-#if 0
-/* 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
- representing the target's format. */
-struct objfile *
-symbol_file_add_from_memory (bfd *templ, CORE_ADDR addr, int from_tty)
-{
- struct objfile *objf;
- bfd *nbfd;
- asection *sec;
- bfd_vma loadbase;
- struct section_addr_info *sai;
- unsigned int i;
-
- if (bfd_get_flavour (templ) != bfd_target_elf_flavour)
- error ("add-symbol-file-from-memory not supported for this target");
-
- nbfd = bfd_elf_bfd_from_remote_memory (templ, addr, &loadbase,
- target_read_memory);
- if (nbfd == NULL)
- {
- error ("Failed to read a valid object file image from memory.");
- return NULL;
- }
-
- nbfd->filename = xstrdup ("shared object read from target memory");
-
- if (!bfd_check_format (nbfd, bfd_object))
- {
- /* FIXME: should be checking for errors from bfd_close (for one thing,
- on error it does not free all the storage associated with the
- bfd). */
- bfd_close (nbfd);
- error ("Got object file from memory but can't read symbols: %s.",
- bfd_errmsg (bfd_get_error ()));
- return NULL;
- }
-
- sai = alloc_section_addr_info (bfd_count_sections (nbfd));
- make_cleanup (xfree, sai);
- i = 0;
- for (sec = nbfd->sections; sec != NULL; sec = sec->next)
- if ((bfd_get_section_flags (nbfd, sec) & (SEC_ALLOC|SEC_LOAD)) != 0)
- {
- sai->other[i].addr = bfd_get_section_vma (nbfd, sec) + loadbase;
- sai->other[i].name = (char *) bfd_get_section_name (nbfd, sec);
- sai->other[i].sectindex = sec->index;
- ++i;
- }
-
- objf = symbol_file_add_with_addrs_or_offsets (nbfd, from_tty,
- sai, NULL, 0, 0, OBJF_SHARED);
-
- /* This might change our ideas about frames already looked at. */
- reinit_frame_cache ();
-
- return objf;
-}
-#endif
-
-static void
-add_symbol_file_from_memory_command (char *args, int from_tty)
-{
-#if 0
- CORE_ADDR addr;
- bfd *templ;
-
- if (args == NULL)
- error ("add-symbol-file-from-memory requires an expression argument");
-
- addr = parse_and_eval_address (args);
-
- /* We need some representative bfd to know the target we are looking at. */
- if (symfile_objfile != NULL)
- templ = symfile_objfile->obfd;
- else
- templ = exec_bfd;
- if (templ == NULL)
- error ("\
-Must use symbol-file or exec-file before add-symbol-file-from-memory.");
-
- symbol_file_add_from_memory (templ, addr, from_tty);
-#else
- error ("add-symbol-file-from-memory not implemented");
-#endif
-}
-
/* Re-read symbols if a symbol-file has changed. */
void
reread_symbols (void)
@@ -3615,13 +3543,6 @@ with the text. SECT is a section name to be loaded at SECT_ADDR.",
&cmdlist);
set_cmd_completer (c, filename_completer);
- c = add_cmd ("add-symbol-file-from-memory", class_files,
- add_symbol_file_from_memory_command,
- "\
-Load the symbols out of memory from a dynamically loaded object file.\n\
-Give an expression for the address of the file's shared object file header.",
- &cmdlist);
-
c = add_cmd ("add-shared-symbol-files", class_files,
add_shared_symbol_files_command,
"Load the symbols from shared objects in the dynamic linker's link map.",