along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/************************************************************************
- * *
- * NOTICE *
- * *
- * This file is still under construction. When it is complete, this *
- * notice will be removed. Until then, direct any questions or changes *
- * to Fred Fish at Cygnus Support (fnf@cygnus.com) *
- * *
- * FIXME Still needs support for shared libraries. *
- * FIXME Still needs support for core files. *
- * FIXME The ".debug" and ".line" section names are hardwired. *
- * *
- ************************************************************************/
-
#include "defs.h"
#include "bfd.h"
+#include <time.h> /* For time_t in libbfd.h. */
#include "libbfd.h"
-#include "libhppa.h"
+#include "som.h"
#include <syms.h>
#include "symtab.h"
#include "symfile.h"
#include "objfiles.h"
#include "buildsym.h"
+#include "stabsread.h"
#include "gdb-stabs.h"
#include "complaints.h"
#include <string.h>
#include "demangle.h"
#include <sys/file.h>
+
+/* Size of n_value and n_strx fields in a stab symbol. */
+#define BYTES_IN_WORD 4
+
#include "aout/aout64.h"
/* Various things we might complain about... */
static void
pa_new_init PARAMS ((struct objfile *));
+static void
+read_unwind_info PARAMS ((struct objfile *));
+
static void
pa_symfile_read PARAMS ((struct objfile *, struct section_offsets *, int));
unsigned int i;
int val;
char *stringtab;
- struct symbol_dictionary_record *buf, *bufp;
+ struct symbol_dictionary_record *buf, *bufp, *endbufp;
+ char *symname;
CONST int symsize = sizeof (struct symbol_dictionary_record);
number_of_symbols = bfd_get_symcount (abfd);
val = bfd_read (stringtab, obj_stringtab_size (abfd), 1, abfd);
if (val != obj_stringtab_size (abfd))
error ("Can't read in HP string table.");
-
- for (i = 0, bufp = buf; i < number_of_symbols; i++, bufp++)
+
+ endbufp = buf + number_of_symbols;
+ for (bufp = buf; bufp < endbufp; ++bufp)
{
enum minimal_symbol_type ms_type;
QUIT;
- if (bufp->symbol_scope != SS_UNIVERSAL)
- continue;
-
- switch (bufp->symbol_type)
- {
- case ST_SYM_EXT:
- case ST_ARG_EXT:
- continue;
- case ST_CODE:
- case ST_PRI_PROG:
- case ST_SEC_PROG:
- case ST_ENTRY:
- case ST_MILLICODE:
- ms_type = mst_text;
- bufp->symbol_value &= ~0x3; /* clear out permission bits */
- break;
- case ST_DATA:
- ms_type = mst_data;
- break;
- default:
- continue;
- }
+ switch (bufp->symbol_scope)
+ {
+ case SS_UNIVERSAL:
+ switch (bufp->symbol_type)
+ {
+ case ST_SYM_EXT:
+ case ST_ARG_EXT:
+ continue;
+
+ case ST_CODE:
+ case ST_PRI_PROG:
+ case ST_SEC_PROG:
+ case ST_ENTRY:
+ case ST_MILLICODE:
+ symname = bufp->name.n_strx + stringtab;
+ ms_type = mst_text;
+ bufp->symbol_value &= ~0x3; /* clear out permission bits */
+ break;
+ case ST_DATA:
+ symname = bufp->name.n_strx + stringtab;
+ ms_type = mst_data;
+ break;
+ default:
+ continue;
+ }
+ break;
+
+#if 0
+ /* SS_GLOBAL and SS_LOCAL are two names for the same thing (!). */
+ case SS_GLOBAL:
+#endif
+ case SS_LOCAL:
+ switch (bufp->symbol_type)
+ {
+ case ST_SYM_EXT:
+ case ST_ARG_EXT:
+ continue;
+
+ case ST_CODE:
+ symname = bufp->name.n_strx + stringtab;
+ ms_type = mst_file_text;
+ bufp->symbol_value &= ~0x3; /* clear out permission bits */
+
+ check_strange_names:
+ /* GAS leaves symbols with the prefixes "LS$", "LBB$",
+ and "LBE$" in .o files after assembling. And thus
+ they appear in the final executable. This can
+ cause problems if these special symbols have the
+ same value as real symbols. So ignore them. Also "LC$". */
+ if (*symname == 'L'
+ && (symname[2] == '$' || symname[3] == '$'))
+ continue;
+ break;
+
+ case ST_PRI_PROG:
+ case ST_SEC_PROG:
+ case ST_ENTRY:
+ case ST_MILLICODE:
+ symname = bufp->name.n_strx + stringtab;
+ ms_type = mst_file_text;
+ bufp->symbol_value &= ~0x3; /* clear out permission bits */
+ break;
+
+ case ST_DATA:
+ symname = bufp->name.n_strx + stringtab;
+ ms_type = mst_file_data;
+ goto check_strange_names;
+
+ default:
+ continue;
+ }
+ break;
+
+ default:
+ continue;
+ }
if (bufp->name.n_strx > obj_stringtab_size (abfd))
error ("Invalid symbol data; bad HP string table offset: %d",
bufp->name.n_strx);
- record_minimal_symbol (bufp->name.n_strx + stringtab,
+ record_minimal_symbol (symname,
bufp->symbol_value, ms_type,
objfile);
}
install_minimal_symbols (objfile);
}
+/* Read in the backtrace information stored in the `$UNWIND_START$' section of
+ the object file. This info is used mainly by find_unwind_entry() to find
+ out the stack frame size and frame pointer used by procedures. We put
+ everything on the psymbol obstack in the objfile so that it automatically
+ gets freed when the objfile is destroyed. */
+
+static void
+read_unwind_info (objfile)
+ struct objfile *objfile;
+{
+ asection *unwind_sec;
+ struct obj_unwind_info *ui;
+
+ ui = obstack_alloc (&objfile->psymbol_obstack,
+ sizeof (struct obj_unwind_info));
+
+ ui->table = NULL;
+ ui->cache = NULL;
+ ui->last = -1;
+
+ unwind_sec = bfd_get_section_by_name (objfile->obfd,
+ "$UNWIND_START$");
+ if (unwind_sec)
+ {
+ int size;
+ int i, *ip;
+
+ size = bfd_section_size (objfile->obfd, unwind_sec);
+ ui->table = obstack_alloc (&objfile->psymbol_obstack, size);
+ ui->last = size / sizeof (struct unwind_table_entry) - 1;
+
+ bfd_get_section_contents (objfile->obfd, unwind_sec, ui->table,
+ 0, size);
+
+ OBJ_UNWIND_INFO (objfile) = ui;
+ }
+}
+
/* Scan and build partial symbols for a symbol file.
We have been initialized by a call to pa_symfile_init, which
currently does nothing.
pastab_build_psymtabs (objfile, section_offsets, mainline);
+ read_unwind_info(objfile);
+
do_cleanups (back_to);
}
if (!DBX_TEXT_SECT (objfile))
error ("Can't find .text section in symbol file");
+ /* FIXME: I suspect this should be external_nlist. The size of host
+ types like long and bfd_vma should not affect how we read the
+ file. */
DBX_SYMBOL_SIZE (objfile) = sizeof (struct internal_nlist);
DBX_SYMCOUNT (objfile) = bfd_section_size (sym_bfd, stabsect)
/ DBX_SYMBOL_SIZE (objfile);
perror_with_name (name);
val = bfd_read (DBX_STRINGTAB (objfile), DBX_STRINGTAB_SIZE (objfile), 1,
sym_bfd);
- if (val != DBX_STRINGTAB_SIZE (objfile))
+ if (val == 0)
+ error ("End of file reading string table");
+ else if (val < 0)
+ /* It's possible bfd_read should be setting bfd_error, and we should be
+ checking that. But currently it doesn't set bfd_error. */
perror_with_name (name);
+ else if (val != DBX_STRINGTAB_SIZE (objfile))
+ error ("Short read reading string table");
}
/* PA specific parsing routine for section offsets.