public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-remove-obj_section: change somread.c to use BFD indices
@ 2012-12-17 18:31 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2012-12-17 18:31 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-remove-obj_section has been updated
       via  6ced7a1920b9e0310239345d71e9b2a8f9242cbd (commit)
       via  508e1f258d241e9ec9df4fd742b17455aa0548c6 (commit)
       via  86b0e04d738f8f33291612bc2d63d1963d7fae14 (commit)
      from  b0dc9788832ef00e3d546b2cb2be436a9ba68fa0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 6ced7a1920b9e0310239345d71e9b2a8f9242cbd
Author: Tom Tromey <tromey@redhat.com>
Date:   Fri Dec 14 11:41:45 2012 -0700

    change somread.c to use BFD indices

commit 508e1f258d241e9ec9df4fd742b17455aa0548c6
Author: Tom Tromey <tromey@redhat.com>
Date:   Fri Dec 14 11:18:09 2012 -0700

    fix build_objfile_section_table comment

commit 86b0e04d738f8f33291612bc2d63d1963d7fae14
Author: Tom Tromey <tromey@redhat.com>
Date:   Fri Dec 14 11:10:14 2012 -0700

    make it possible to build somread.c anywhere
    
    This makes it possible to build somread.c anywhere the
    corresponding BFD target is enabled.
    I sent it to John David Anglin for testing.

-----------------------------------------------------------------------

Summary of changes:
 gdb/configure    |   52 ++++++++++++++++++++++++
 gdb/configure.ac |    7 +++
 gdb/objfiles.c   |   13 +-----
 gdb/solib-som.c  |    2 -
 gdb/somread.c    |  114 +++++++++++++++++++++++++++---------------------------
 5 files changed, 118 insertions(+), 70 deletions(-)

First 500 lines of diff:
diff --git a/gdb/configure b/gdb/configure
index 6273193..c54709c 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -12674,6 +12674,58 @@ if test $gdb_cv_var_macho = yes; then
   CONFIG_OBS="$CONFIG_OBS machoread.o"
 fi
 
+# Add SOM support to GDB, but only if BFD includes it.
+
+  OLD_CFLAGS=$CFLAGS
+  OLD_LDFLAGS=$LDFLAGS
+  OLD_LIBS=$LIBS
+  # Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS
+  # points somewhere with bfd, with -I/foo/lib and -L/foo/lib.  We
+  # always want our bfd.
+  CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
+  LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
+  intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
+  # -ldl is provided by bfd/Makfile.am (LIBDL) <PLUGINS>.
+  if test "$plugins" = "yes"; then
+    LIBS="-ldl $LIBS"
+  fi
+  LIBS="-lbfd -liberty $intl $LIBS"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SOM support in BFD" >&5
+$as_echo_n "checking for SOM support in BFD... " >&6; }
+if test "${gdb_cv_var_som+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+  #include "bfd.h"
+  #include "som.h"
+
+int
+main ()
+{
+return bfd_som_attach_aux_hdr (NULL, 0, NULL);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gdb_cv_var_som=yes
+else
+  gdb_cv_var_som=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_var_som" >&5
+$as_echo "$gdb_cv_var_som" >&6; }
+  CFLAGS=$OLD_CFLAGS
+  LDFLAGS=$OLD_LDFLAGS
+  LIBS=$OLD_LIBS
+if test $gdb_cv_var_som = yes; then
+  CONFIG_OBS="$CONFIG_OBS somread.o"
+fi
+
 # Add any host-specific objects to GDB.
 CONFIG_OBS="${CONFIG_OBS} ${gdb_host_obs}"
 
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 0468f3b..debfb0c 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2034,6 +2034,13 @@ if test $gdb_cv_var_macho = yes; then
   CONFIG_OBS="$CONFIG_OBS machoread.o"
 fi
 
+# Add SOM support to GDB, but only if BFD includes it.
+GDB_AC_CHECK_BFD([for SOM support in BFD], gdb_cv_var_som,
+                 [bfd_som_attach_aux_hdr (NULL, 0, NULL)], som.h)
+if test $gdb_cv_var_som = yes; then
+  CONFIG_OBS="$CONFIG_OBS somread.o"
+fi
+
 # Add any host-specific objects to GDB.
 CONFIG_OBS="${CONFIG_OBS} ${gdb_host_obs}"
 
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 8640531..9662cfb 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -203,17 +203,8 @@ add_to_objfile_sections (struct bfd *abfd, struct bfd_section *asect,
 
 /* Builds a section table for OBJFILE.
 
-   Note that while we are building the table, which goes into the
-   objfile obstack, we hijack the sections_end pointer to instead hold
-   a count of the number of sections.  When bfd_map_over_sections
-   returns, this count is used to compute the pointer to the end of
-   the sections table, which then overwrites the count.
-
-   Also note that the OFFSET and OVLY_MAPPED in each table entry
-   are initialized to zero.
-
-   Also note that if anything else writes to the objfile obstack while
-   we are building the table, we're pretty much hosed.  */
+   Note that the OFFSET and OVLY_MAPPED in each table entry are
+   initialized to zero.  */
 
 void
 build_objfile_section_table (struct objfile *objfile)
diff --git a/gdb/solib-som.c b/gdb/solib-som.c
index 47bf5a3..469fba3 100644
--- a/gdb/solib-som.c
+++ b/gdb/solib-som.c
@@ -845,8 +845,6 @@ som_solib_section_offsets (struct objfile *objfile,
 	  offsets->offsets[SECT_OFF_TEXT (objfile)]
 	    = (so_list->lm_info->text_addr
 	       - so_list->lm_info->text_link_addr);
-	  offsets->offsets[SECT_OFF_RODATA (objfile)]
-	    = ANOFFSET (offsets, SECT_OFF_TEXT (objfile));
 
 	  /* We should look at presumed_dp in the SOM header, but
 	     that's not easily available.  This should be OK though.  */
diff --git a/gdb/somread.c b/gdb/somread.c
index f603162..29910af 100644
--- a/gdb/somread.c
+++ b/gdb/somread.c
@@ -20,7 +20,7 @@
 
 #include "defs.h"
 #include "bfd.h"
-#include <syms.h>
+#include "som/aout.h"
 #include "symtab.h"
 #include "symfile.h"
 #include "objfiles.h"
@@ -52,9 +52,9 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
   int val, dynamic;
   char *stringtab;
   asection *shlib_info;
-  struct symbol_dictionary_record *buf, *bufp, *endbufp;
+  struct som_external_symbol_dictionary_record *buf, *bufp, *endbufp;
   char *symname;
-  CONST int symsize = sizeof (struct symbol_dictionary_record);
+  CONST int symsize = sizeof (struct som_external_symbol_dictionary_record);
   CORE_ADDR text_offset, data_offset;
 
 
@@ -101,14 +101,20 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
   for (bufp = buf; bufp < endbufp; ++bufp)
     {
       enum minimal_symbol_type ms_type;
+      unsigned int flags = bfd_getb32 (bufp->flags);
+      unsigned int symbol_type =
+        (flags >> SOM_SYMBOL_TYPE_SH) & SOM_SYMBOL_TYPE_MASK;
+      unsigned int symbol_scope =
+        (flags >> SOM_SYMBOL_SCOPE_SH) & SOM_SYMBOL_SCOPE_MASK;
+      CORE_ADDR symbol_value = bfd_getb32 (bufp->symbol_value);
 
       QUIT;
 
-      switch (bufp->symbol_scope)
+      switch (symbol_scope)
 	{
 	case SS_UNIVERSAL:
 	case SS_EXTERNAL:
-	  switch (bufp->symbol_type)
+	  switch (symbol_type)
 	    {
 	    case ST_SYM_EXT:
 	    case ST_ARG_EXT:
@@ -118,15 +124,14 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
 	    case ST_PRI_PROG:
 	    case ST_SEC_PROG:
 	    case ST_MILLICODE:
-	      symname = bufp->name.n_strx + stringtab;
+	      symname = bfd_getb32 (bufp->name) + stringtab;
 	      ms_type = mst_text;
-	      bufp->symbol_value += text_offset;
-	      bufp->symbol_value = gdbarch_addr_bits_remove
-				     (gdbarch, bufp->symbol_value);
+	      symbol_value += text_offset;
+	      symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
 	      break;
 
 	    case ST_ENTRY:
-	      symname = bufp->name.n_strx + stringtab;
+	      symname = bfd_getb32 (bufp->name) + stringtab;
 	      /* For a dynamic executable, ST_ENTRY symbols are
 	         the stubs, while the ST_CODE symbol is the real
 	         function.  */
@@ -134,22 +139,20 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
 		ms_type = mst_solib_trampoline;
 	      else
 		ms_type = mst_text;
-	      bufp->symbol_value += text_offset;
-	      bufp->symbol_value = gdbarch_addr_bits_remove
-				     (gdbarch, bufp->symbol_value);
+	      symbol_value += text_offset;
+	      symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
 	      break;
 
 	    case ST_STUB:
-	      symname = bufp->name.n_strx + stringtab;
+	      symname = bfd_getb32 (bufp->name) + stringtab;
 	      ms_type = mst_solib_trampoline;
-	      bufp->symbol_value += text_offset;
-	      bufp->symbol_value = gdbarch_addr_bits_remove
-				     (gdbarch, bufp->symbol_value);
+	      symbol_value += text_offset;
+	      symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
 	      break;
 
 	    case ST_DATA:
-	      symname = bufp->name.n_strx + stringtab;
-	      bufp->symbol_value += data_offset;
+	      symname = bfd_getb32 (bufp->name) + stringtab;
+	      symbol_value += data_offset;
 	      ms_type = mst_data;
 	      break;
 	    default:
@@ -162,18 +165,17 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
 	case SS_GLOBAL:
 #endif
 	case SS_LOCAL:
-	  switch (bufp->symbol_type)
+	  switch (symbol_type)
 	    {
 	    case ST_SYM_EXT:
 	    case ST_ARG_EXT:
 	      continue;
 
 	    case ST_CODE:
-	      symname = bufp->name.n_strx + stringtab;
+	      symname = bfd_getb32 (bufp->name) + stringtab;
 	      ms_type = mst_file_text;
-	      bufp->symbol_value += text_offset;
-	      bufp->symbol_value = gdbarch_addr_bits_remove
-				     (gdbarch, bufp->symbol_value);
+	      symbol_value += text_offset;
+	      symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
 
 	    check_strange_names:
 	      /* Utah GCC 2.5, FSF GCC 2.6 and later generate correct local
@@ -201,37 +203,34 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
 	    case ST_PRI_PROG:
 	    case ST_SEC_PROG:
 	    case ST_MILLICODE:
-	      symname = bufp->name.n_strx + stringtab;
+	      symname = bfd_getb32 (bufp->name) + stringtab;
 	      ms_type = mst_file_text;
-	      bufp->symbol_value += text_offset;
-	      bufp->symbol_value = gdbarch_addr_bits_remove
-				     (gdbarch, bufp->symbol_value);
+	      symbol_value += text_offset;
+	      symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
 	      break;
 
 	    case ST_ENTRY:
-	      symname = bufp->name.n_strx + stringtab;
+	      symname = bfd_getb32 (bufp->name) + stringtab;
 	      /* SS_LOCAL symbols in a shared library do not have
 		 export stubs, so we do not have to worry about
 		 using mst_file_text vs mst_solib_trampoline here like
 		 we do for SS_UNIVERSAL and SS_EXTERNAL symbols above.  */
 	      ms_type = mst_file_text;
-	      bufp->symbol_value += text_offset;
-	      bufp->symbol_value = gdbarch_addr_bits_remove
-				     (gdbarch, bufp->symbol_value);
+	      symbol_value += text_offset;
+	      symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
 	      break;
 
 	    case ST_STUB:
-	      symname = bufp->name.n_strx + stringtab;
+	      symname = bfd_getb32 (bufp->name) + stringtab;
 	      ms_type = mst_solib_trampoline;
-	      bufp->symbol_value += text_offset;
-	      bufp->symbol_value = gdbarch_addr_bits_remove
-				     (gdbarch, bufp->symbol_value);
+	      symbol_value += text_offset;
+	      symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
 	      break;
 
 
 	    case ST_DATA:
-	      symname = bufp->name.n_strx + stringtab;
-	      bufp->symbol_value += data_offset;
+	      symname = bfd_getb32 (bufp->name) + stringtab;
+	      symbol_value += data_offset;
 	      ms_type = mst_file_data;
 	      goto check_strange_names;
 
@@ -247,12 +246,12 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
 	     This also happens for weak symbols, but their type is
 	     ST_DATA.  */
 	case SS_UNSAT:
-	  switch (bufp->symbol_type)
+	  switch (symbol_type)
 	    {
 	    case ST_STORAGE:
 	    case ST_DATA:
-	      symname = bufp->name.n_strx + stringtab;
-	      bufp->symbol_value += data_offset;
+	      symname = bfd_getb32 (bufp->name) + stringtab;
+	      symbol_value += data_offset;
 	      ms_type = mst_data;
 	      break;
 
@@ -265,12 +264,11 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
 	  continue;
 	}
 
-      if (bufp->name.n_strx > obj_som_stringtab_size (abfd))
-	error (_("Invalid symbol data; bad HP string table offset: %d"),
-	       bufp->name.n_strx);
+      if (bfd_getb32 (bufp->name) > obj_som_stringtab_size (abfd))
+	error (_("Invalid symbol data; bad HP string table offset: %s"),
+	       plongest (bfd_getb32 (bufp->name)));
 
-      prim_record_minimal_symbol (symname, bufp->symbol_value, ms_type,
-				  objfile);
+      prim_record_minimal_symbol (symname, symbol_value, ms_type, objfile);
     }
 }
 
@@ -290,7 +288,7 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
    for real.
 
    We look for sections with specific names, to tell us what debug
-   format to look for:  FIXME!!!
+   format to look for.
 
    somstab_build_psymtabs() handles STABS symbols.
 
@@ -373,22 +371,22 @@ som_symfile_offsets (struct objfile *objfile, struct section_addr_info *addrs)
 {
   int i;
   CORE_ADDR text_addr;
+  asection *sect;
 
   objfile->num_sections = bfd_count_sections (objfile->obfd);
   objfile->section_offsets = (struct section_offsets *)
     obstack_alloc (&objfile->objfile_obstack, 
 		   SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
 
-  /* FIXME: ezannoni 2000-04-20 The section names in SOM are not
-     .text, .data, etc, but $TEXT$, $DATA$,...  We should initialize
-     SET_OFF_* from bfd.  (See default_symfile_offsets()).  But I don't
-     know the correspondence between SOM sections and GDB's idea of
-     section names.  So for now we default to what is was before these
-     changes.  */
-  objfile->sect_index_text = 0;
-  objfile->sect_index_data = 1;
-  objfile->sect_index_bss = 2;
-  objfile->sect_index_rodata = 3;
+  sect = bfd_get_section_by_name (objfile->obfd, "$TEXT$");
+  if (sect != NULL)
+    objfile->sect_index_text = sect->index;
+  sect = bfd_get_section_by_name (objfile->obfd, "$DATA$");
+  if (sect != NULL)
+    objfile->sect_index_data = sect->index;
+  sect = bfd_get_section_by_name (objfile->obfd, "$BSS$");
+  if (sect != NULL)
+    objfile->sect_index_bss = sect->index;
 
   /* First see if we're a shared library.  If so, get the section
      offsets from the library, else get them from addrs.  */
@@ -427,6 +425,8 @@ static const struct sym_fns som_sym_fns =
   &psym_functions
 };
 
+initialize_file_ftype _initialize_somread;
+
 void
 _initialize_somread (void)
 {


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-12-17 18:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-17 18:31 [SCM] archer-tromey-remove-obj_section: change somread.c to use BFD indices tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).