/* Read AIX xcoff symbol tables and convert to internal format, for GDB.
- Copyright (C) 1986-2013 Free Software Foundation, Inc.
+ Copyright (C) 1986-2014 Free Software Foundation, Inc.
Derived from coffread.c, dbxread.c, and a lot of hacking.
Contributed by IBM Corporation.
#include <sys/types.h>
#include <fcntl.h>
#include <ctype.h>
-#include "gdb_string.h"
+#include <string.h>
-#include <sys/param.h>
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
-#include "gdb_stat.h"
+#include <sys/stat.h>
#include "coff/internal.h"
#include "libcoff.h" /* FIXME, internal data from BFD */
char *c_name;
int c_symnum; /* Symbol number of this entry. */
int c_naux; /* 0 if syment only, 1 if syment + auxent. */
- long c_value;
+ CORE_ADDR c_value;
unsigned char c_sclass;
int c_secnum;
unsigned int c_type;
struct linetable_entry *fentry; /* function entry vector */
int fentry_size; /* # of function entries */
struct linetable *newLineTb; /* new line table */
+ int extra_lines = 0;
#define NUM_OF_FUNCTIONS 20
fentry[function_count].line = ii;
fentry[function_count].pc = oldLineTb->item[ii].pc;
++function_count;
+
+ /* If the function was compiled with XLC, we may have to add an
+ extra line entry later. Reserve space for that. */
+ if (ii + 1 < oldLineTb->nitems
+ && oldLineTb->item[ii].pc != oldLineTb->item[ii + 1].pc)
+ extra_lines++;
}
}
newLineTb = (struct linetable *)
xmalloc
(sizeof (struct linetable) +
- (oldLineTb->nitems - function_count) * sizeof (struct linetable_entry));
+ (oldLineTb->nitems - function_count + extra_lines) * sizeof (struct linetable_entry));
/* If line table does not start with a function beginning, copy up until
a function begin. */
for (ii = 0; ii < function_count; ++ii)
{
+ /* If the function was compiled with XLC, we may have to add an
+ extra line to cover the function prologue. */
+ jj = fentry[ii].line;
+ if (jj + 1 < oldLineTb->nitems
+ && oldLineTb->item[jj].pc != oldLineTb->item[jj + 1].pc)
+ {
+ newLineTb->item[newline] = oldLineTb->item[jj];
+ newLineTb->item[newline].line = oldLineTb->item[jj + 1].line;
+ newline++;
+ }
+
for (jj = fentry[ii].line + 1;
jj < oldLineTb->nitems && oldLineTb->item[jj].line != 0;
++jj, ++newline)
newLineTb->item[newline] = oldLineTb->item[jj];
}
xfree (fentry);
- newLineTb->nitems = oldLineTb->nitems - function_count;
+ /* The number of items in the line table must include these
+ extra lines which were added in case of XLC compiled functions. */
+ newLineTb->nitems = oldLineTb->nitems - function_count + extra_lines;
return newLineTb;
}
}
static void
-aix_process_linenos (void)
+aix_process_linenos (struct objfile *objfile)
{
/* There is no linenos to read if there are only dwarf info. */
if (this_symtab_psymtab == NULL)
unsigned int max_symnum;
int just_started = 1;
int depth = 0;
- int fcn_start_addr = 0;
+ CORE_ADDR fcn_start_addr = 0;
struct coff_symbol fcn_stab_saved = { 0 };
file_ptr symtab_offset; /* symbol table and */
file_ptr stringtab_offset; /* string table file offsets */
struct coff_symfile_info *info;
- char *name;
+ const char *name;
unsigned int size;
info = XCOFF_DATA (objfile);
symfile_bfd = abfd = objfile->obfd;
- name = objfile->name;
+ name = objfile_name (objfile);
num_symbols = bfd_get_symcount (abfd); /* # of symbols */
symtab_offset = obj_sym_filepos (abfd); /* symbol table file offset */
xcoffread.c reads all the symbols and does in fact randomly access them
(in C_BSTAT and line number processing). */
- bfd_target_xcoff_flavour,
-
xcoff_new_init, /* init anything gbl to entire symtab */
xcoff_symfile_init, /* read initial info, setup for sym_read() */
xcoff_initial_scan, /* read a symbol file into symtab */
void
_initialize_xcoffread (void)
{
- add_symtab_fns (&xcoff_sym_fns);
+ add_symtab_fns (bfd_target_xcoff_flavour, &xcoff_sym_fns);
xcoff_objfile_data_key = register_objfile_data_with_cleanup (NULL,
xcoff_free_info);