aboutsummaryrefslogtreecommitdiff
path: root/gdb/xcoffread.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2012-12-18 14:52:59 +0000
committerJoel Brobecker <brobecker@gnat.com>2012-12-18 14:52:59 +0000
commitd5367fe16e4948e9480e49302ab350d9a9c14a50 (patch)
tree0706d0cf8090c15a8647b54b7e9f9363a6257e3d /gdb/xcoffread.c
parent8d708c8cad07b1d961c7d0a30040116d79134e92 (diff)
downloadgdb-d5367fe16e4948e9480e49302ab350d9a9c14a50.zip
gdb-d5367fe16e4948e9480e49302ab350d9a9c14a50.tar.gz
gdb-d5367fe16e4948e9480e49302ab350d9a9c14a50.tar.bz2
Port GDB to powerpc-lynx178.
gdb/ChangeLog: * defs.h (enum gdb_osabi): Add GDB_OSABI_LYNXOS178. * osabi.c (gdb_osabi_names): Add entry for GDB_OSABI_LYNXOS178. * xcoffread.c (xcoff_get_core_n_import_files): New function. (xcoff_get_n_import_files): New function. * xcoffread.h (xcoffread.h): Add declaration. * rs6000-aix-tdep.c: #include "xcoffread.h". (rs6000_aix_osabi_sniffer): Do not return GDB_OSABI_AIX for XCOFF executables that do not depend on any shared library. * rs6000-lynx178-tdep.c: New file. * configure.tgt: Add powerpc-*-lynx*178 handling. * Makefile.in (ALL_TARGET_OBS): Add rs6000-lynx178-tdep.o. (ALLDEPFILES): Add rs6000-lynx178-tdep.c.
Diffstat (limited to 'gdb/xcoffread.c')
-rw-r--r--gdb/xcoffread.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 10c93cc..f3562ff 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -3113,6 +3113,67 @@ static const struct sym_fns xcoff_sym_fns =
&psym_functions
};
+/* Same as xcoff_get_n_import_files, but for core files. */
+
+static int
+xcoff_get_core_n_import_files (bfd *abfd)
+{
+ asection *sect = bfd_get_section_by_name (abfd, ".ldinfo");
+ gdb_byte buf[4];
+ file_ptr offset = 0;
+ int n_entries = 0;
+
+ if (sect == NULL)
+ return -1; /* Not a core file. */
+
+ for (offset = 0; offset < bfd_get_section_size (sect);)
+ {
+ int next;
+
+ n_entries++;
+
+ if (!bfd_get_section_contents (abfd, sect, buf, offset, 4))
+ return -1;
+ next = bfd_get_32 (abfd, buf);
+ if (next == 0)
+ break; /* This is the last entry. */
+ offset += next;
+ }
+
+ /* Return the number of entries, excluding the first one, which is
+ the path to the executable that produced this core file. */
+ return n_entries - 1;
+}
+
+/* Return the number of import files (shared libraries) that the given
+ BFD depends on. Return -1 if this number could not be computed. */
+
+int
+xcoff_get_n_import_files (bfd *abfd)
+{
+ asection *sect = bfd_get_section_by_name (abfd, ".loader");
+ gdb_byte buf[4];
+ int l_nimpid;
+
+ /* If the ".loader" section does not exist, the objfile is probably
+ not an executable. Might be a core file... */
+ if (sect == NULL)
+ return xcoff_get_core_n_import_files (abfd);
+
+ /* The number of entries in the Import Files Table is stored in
+ field l_nimpid. This field is always at offset 16, and is
+ always 4 bytes long. Read those 4 bytes. */
+
+ if (!bfd_get_section_contents (abfd, sect, buf, 16, 4))
+ return -1;
+ l_nimpid = bfd_get_32 (abfd, buf);
+
+ /* By convention, the first entry is the default LIBPATH value
+ to be used by the system loader, so it does not count towards
+ the number of import files. */
+ return l_nimpid - 1;
+}
+
/* Free the per-objfile xcoff data. */
static void