* Clean up xcoff relocation.

objfiles.h (struct objfiles): Add section_offsets, num_sections.
	symfile.c (syms_from_objfile), xcoffread.c (xcoff_symfile_offsets):
	Set them.
	symtab.h (struct general_symbol_info): Add section field.
	minsyms.c (prim_record_minimal_symbol{,_and_info}): Set it.
	xcoffread.c: Set section for symbols and msymbols.
	(struct symtab): Add block_line_section field.
	buildsym.c (end_symtab): Set it.
	(end_symtab and callers): Add section parameter.
	objfiles.c (objfile_relocate): New funciton.
	xcoffexec.c (vmap_symtab): Use it.
	xcoffsolib.h (struct vmap): Remove unused fields.
	config/rs6000/tm-rs6000.h, stack.c, xcoffexec.c: Remove
	CORE_NEEDS_RELOCATION, symtab_relocated.
	config/rs6000/tm-rs6000.h: Remove use of loadinfotext.
	rs6000-tdep.c: Make loadinfotext static.
	breakpoint.c (fixup_breakpoints): Doc fix.
	symtab.h (struct symtab), config/rs6000/tm-rs6000.h, buildsym.c
	(end_symtab): primary field replaces nonreloc.
This commit is contained in:
Jim Kingdon 1993-03-26 14:59:43 +00:00
parent 786f2f3402
commit 3c02636b4e
12 changed files with 279 additions and 204 deletions

View File

@ -1,3 +1,26 @@
Wed Mar 24 08:48:30 1993 Jim Kingdon (kingdon@cygnus.com)
* Clean up xcoff relocation.
objfiles.h (struct objfiles): Add section_offsets, num_sections.
symfile.c (syms_from_objfile), xcoffread.c (xcoff_symfile_offsets):
Set them.
symtab.h (struct general_symbol_info): Add section field.
minsyms.c (prim_record_minimal_symbol{,_and_info}): Set it.
xcoffread.c: Set section for symbols and msymbols.
(struct symtab): Add block_line_section field.
buildsym.c (end_symtab): Set it.
(end_symtab and callers): Add section parameter.
objfiles.c (objfile_relocate): New funciton.
xcoffexec.c (vmap_symtab): Use it.
xcoffsolib.h (struct vmap): Remove unused fields.
config/rs6000/tm-rs6000.h, stack.c, xcoffexec.c: Remove
CORE_NEEDS_RELOCATION, symtab_relocated.
config/rs6000/tm-rs6000.h: Remove use of loadinfotext.
rs6000-tdep.c: Make loadinfotext static.
breakpoint.c (fixup_breakpoints): Doc fix.
symtab.h (struct symtab), config/rs6000/tm-rs6000.h, buildsym.c
(end_symtab): primary field replaces nonreloc.
Thu Mar 25 12:26:50 1993 Stu Grossman (grossman@cygnus.com)
* findvar.c (read_register, write_register): Make these capable

View File

@ -588,6 +588,8 @@ start_symtab (name, dirname, start_addr)
for that file and put it in the list of all such.
END_ADDR is the address of the end of the file's text.
SECTION is the section number (in objfile->section_offsets) of
the blockvector and linetable.
Note that it is possible for end_symtab() to return NULL. In particular,
for the DWARF case at least, it will return NULL when it finds a
@ -597,11 +599,12 @@ start_symtab (name, dirname, start_addr)
because then gdb will never know about this empty file (FIXME). */
struct symtab *
end_symtab (end_addr, sort_pending, sort_linevec, objfile)
end_symtab (end_addr, sort_pending, sort_linevec, objfile, section)
CORE_ADDR end_addr;
int sort_pending;
int sort_linevec;
struct objfile *objfile;
int section;
{
register struct symtab *symtab;
register struct blockvector *blockvector;
@ -731,6 +734,7 @@ end_symtab (end_addr, sort_pending, sort_linevec, objfile)
{
symtab->linetable = NULL;
}
symtab->block_line_section = section;
if (subfile->dirname)
{
/* Reallocate the dirname on the symbol obstack */
@ -753,14 +757,11 @@ end_symtab (end_addr, sort_pending, sort_linevec, objfile)
language it is from things we found in the symbols. */
symtab->language = subfile->language;
#ifdef IBM6000_TARGET
/* In case we need to duplicate symbol tables (to represent include
files), and in case our system needs relocation, we want to
relocate the main symbol table node only (for the main file,
not for the include files). */
/* All symtabs for the main file and the subfiles share a
blockvector, so we need to clear primary for everything but
the main file. */
symtab->nonreloc = TRUE;
#endif
symtab->primary = 0;
}
if (subfile->name != NULL)
{
@ -779,14 +780,11 @@ end_symtab (end_addr, sort_pending, sort_linevec, objfile)
free ((PTR)subfile);
}
#ifdef IBM6000_TARGET
/* all include symbol tables are non-relocatable, except the main source
file's. */
/* Set this for the main source file. */
if (symtab)
{
symtab->nonreloc = FALSE;
symtab->primary = 1;
}
#endif
last_source_file = NULL;
current_subfile = NULL;

View File

@ -227,7 +227,7 @@ extern char *
pop_subfile PARAMS ((void));
extern struct symtab *
end_symtab PARAMS ((CORE_ADDR, int, int, struct objfile *));
end_symtab PARAMS ((CORE_ADDR, int, int, struct objfile *, int));
extern void
scan_file_globals PARAMS ((struct objfile *));

View File

@ -336,7 +336,8 @@ static int isreg; /* Kludge to identify register variables */
static int offreg; /* Kludge to identify basereg references */
/* This value is added to each symbol value. FIXME: Generalize to
the section_offsets structure used by dbxread. */
the section_offsets structure used by dbxread (once this is done,
pass the appropriate section number to end_symtab). */
static CORE_ADDR baseaddr; /* Add to each symbol value */
/* The section offsets used in the current psymtab or symtab. FIXME,
@ -1977,7 +1978,8 @@ read_file_scope (dip, thisdie, enddie, objfile)
start_symtab (dip -> at_name, dip -> at_comp_dir, dip -> at_low_pc);
decode_line_numbers (lnbase);
process_dies (thisdie + dip -> die_length, enddie, objfile);
symtab = end_symtab (dip -> at_high_pc, 0, 0, objfile);
symtab = end_symtab (dip -> at_high_pc, 0, 0, objfile, 0);
if (symtab != NULL)
{
symtab -> language = cu_language;

View File

@ -187,7 +187,7 @@ record_minimal_symbol_and_info (name, address, ms_type, info, objfile)
struct objfile *objfile;
{
name = obsavestring (name, strlen (name), &objfile -> symbol_obstack);
prim_record_minimal_symbol_and_info (name, address, ms_type, info);
prim_record_minimal_symbol_and_info (name, address, ms_type, info, -1);
}
/*

View File

@ -266,6 +266,7 @@ prim_record_minimal_symbol (name, address, ms_type)
SYMBOL_NAME (msymbol) = (char *) name;
SYMBOL_INIT_LANGUAGE_SPECIFIC (msymbol, language_unknown);
SYMBOL_VALUE_ADDRESS (msymbol) = address;
SYMBOL_SECTION (msymbol) = -1;
MSYMBOL_TYPE (msymbol) = ms_type;
/* FIXME: This info, if it remains, needs its own field. */
MSYMBOL_INFO (msymbol) = NULL; /* FIXME! */
@ -277,11 +278,12 @@ prim_record_minimal_symbol (name, address, ms_type)
and pass it a NULL info pointer value if info is not needed? */
void
prim_record_minimal_symbol_and_info (name, address, ms_type, info)
prim_record_minimal_symbol_and_info (name, address, ms_type, info, section)
const char *name;
CORE_ADDR address;
enum minimal_symbol_type ms_type;
char *info;
int section;
{
register struct msym_bunch *new;
register struct minimal_symbol *msymbol;
@ -297,6 +299,7 @@ prim_record_minimal_symbol_and_info (name, address, ms_type, info)
SYMBOL_NAME (msymbol) = (char *) name;
SYMBOL_INIT_LANGUAGE_SPECIFIC (msymbol, language_unknown);
SYMBOL_VALUE_ADDRESS (msymbol) = address;
SYMBOL_SECTION (msymbol) = section;
MSYMBOL_TYPE (msymbol) = ms_type;
/* FIXME: This info, if it remains, needs its own field. */
MSYMBOL_INFO (msymbol) = info; /* FIXME! */

View File

@ -341,7 +341,96 @@ free_all_objfiles ()
free_objfile (objfile);
}
}
/* Relocate OBJFILE to NEW_OFFSETS. There should be OBJFILE->NUM_SECTIONS
entries in new_offsets. */
void
objfile_relocate (objfile, new_offsets)
struct objfile *objfile;
struct section_offsets *new_offsets;
{
struct section_offsets *delta = (struct section_offsets *) alloca
(sizeof (struct section_offsets)
+ objfile->num_sections * sizeof (delta->offsets));
{
int i;
int something_changed = 0;
for (i = 0; i < objfile->num_sections; ++i)
{
ANOFFSET (delta, i) =
ANOFFSET (new_offsets, i) - ANOFFSET (objfile->section_offsets, i);
if (ANOFFSET (delta, i) != 0)
something_changed = 1;
}
if (!something_changed)
return;
}
/* OK, get all the symtabs. */
{
struct symtab *s;
for (s = objfile->symtabs; s; s = s->next)
{
struct linetable *l;
struct blockvector *bv;
int i;
/* First the line table. */
l = LINETABLE (s);
if (l)
{
for (i = 0; i < l->nitems; ++i)
l->item[i].pc += ANOFFSET (delta, s->block_line_section);
}
/* Don't relocate a shared blockvector more than once. */
if (!s->primary)
continue;
bv = BLOCKVECTOR (s);
for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i)
{
struct block *b;
int j;
b = BLOCKVECTOR_BLOCK (bv, i);
BLOCK_START (b) += ANOFFSET (delta, s->block_line_section);
BLOCK_END (b) += ANOFFSET (delta, s->block_line_section);
for (j = 0; j < BLOCK_NSYMS (b); ++j)
{
struct symbol *sym = BLOCK_SYM (b, j);
/* The RS6000 code from which this was taken skipped
any symbols in STRUCT_NAMESPACE or UNDEF_NAMESPACE.
But I'm leaving out that test, on the theory that
they can't possibly pass the tests below. */
if ((SYMBOL_CLASS (sym) == LOC_LABEL
|| SYMBOL_CLASS (sym) == LOC_STATIC)
&& SYMBOL_SECTION (sym) >= 0)
{
SYMBOL_VALUE_ADDRESS (sym) +=
ANOFFSET (delta, SYMBOL_SECTION (sym));
}
}
}
}
}
{
struct minimal_symbol *msym;
ALL_OBJFILE_MSYMBOLS (objfile, msym)
SYMBOL_VALUE_ADDRESS (msym) += ANOFFSET (delta, SYMBOL_SECTION (msym));
}
{
int i;
for (i = 0; i < objfile->num_sections; ++i)
ANOFFSET (objfile->section_offsets, i) = ANOFFSET (new_offsets, i);
}
}
/* Many places in gdb want to test just to see if we have any partial
symbols available. This function returns zero if none are currently
available, nonzero otherwise. */

View File

@ -245,6 +245,18 @@ struct objfile
gets freed automatically when reading a new object file. */
PTR obj_private;
/* Set of relocation offsets to apply to each section.
Currently on the psymbol_obstack (which makes no sense, but I'm
not sure it's harming anything).
These offsets indicate that all symbols (including partial and
minimal symbols) which have been read have been relocated by this
much. Symbols which are yet to be read need to be relocated by
it. */
struct section_offsets *section_offsets;
int num_sections;
};
/* Defines for the objfile flag word. */
@ -306,6 +318,9 @@ free_objfile PARAMS ((struct objfile *));
extern void
free_all_objfiles PARAMS ((void));
extern void
objfile_relocate PARAMS ((struct objfile *, struct section_offsets *));
extern int
have_partial_symbols PARAMS ((void));

View File

@ -1129,13 +1129,10 @@ struct loadinfo {
#define LOADINFOLEN 10
/* FIXME Warning -- loadinfotextindex is used for a nefarious purpose by
tm-rs6000.h. */
static struct loadinfo *loadinfo = NULL;
static int loadinfolen = 0;
static int loadinfotocindex = 0;
int loadinfotextindex = 0;
static int loadinfotextindex = 0;
void

View File

@ -301,21 +301,19 @@ map_vmap (bfd *bf, bfd *arch)
}
/* true, if symbol table and minimal symbol table are relocated. */
int symtab_relocated = 0;
/* vmap_symtab - handle symbol translation on vmapping */
vmap_symtab(vp, old_start, vip)
register struct vmap *vp;
CORE_ADDR old_start;
struct stat *vip;
static void
vmap_symtab (vp)
register struct vmap *vp;
{
register struct symtab *s;
register struct objfile *objfile;
register struct minimal_symbol *msymbol;
asection *textsec;
asection *datasec;
asection *bsssec;
CORE_ADDR old_text_offset;
struct section_offsets *new_offsets;
int i;
objfile = vp->objfile;
if (objfile == NULL)
@ -328,140 +326,26 @@ struct stat *vip;
objfile = symfile_objfile;
}
s = objfile->symtabs;
new_offsets = alloca
(sizeof (struct section_offsets)
+ sizeof (new_offsets->offsets) * objfile->num_sections);
if (vp->tstart != old_start) {
/* Once we find a relocation base address for one of the symtabs
in this objfile, it will be the same for all symtabs in this
objfile. Clean this algorithm. FIXME. */
for (; s; s = s->next)
if (!s->nonreloc || LINETABLE(s))
vmap_symtab_1(s, vp, old_start);
#if 1
/* I believe trampoline entries now have a name like
<trampoline>. In any event, if something needs to be changed,
it should be changed in ALL_MSYMBOLS, so it works everywhere. */
/*
Himm.., recently we nullified trampoline entry names in order not
to confuse them with real symbols. Appearently this turned into a
problem, and msymbol vector did not get relocated properly. If
msymbols have to have non-null names, then we should name
trampoline entries with empty strings. */
ALL_MSYMBOLS (objfile, msymbol)
#else
for (msymbol = objfile->msymbols;
SYMBOL_NAME (msymbol) || SYMBOL_VALUE_ADDRESS (msymbol);
(msymbol)++)
#endif
if (SYMBOL_VALUE_ADDRESS (msymbol) < TEXT_SEGMENT_BASE)
SYMBOL_VALUE_ADDRESS (msymbol) += vp->tstart - old_start;
}
if (vp->tstart != old_start) {
/* breakpoints need to be relocated as well. */
fixup_breakpoints (0, TEXT_SEGMENT_BASE, vp->tstart - old_start);
}
for (i = 0; i < objfile->num_sections; ++i)
ANOFFSET (new_offsets, i) = ANOFFSET (objfile->section_offsets, i);
symtab_relocated = 1;
}
textsec = bfd_get_section_by_name (vp->bfd, ".text");
old_text_offset = ANOFFSET (objfile->section_offsets, textsec->target_index);
ANOFFSET (new_offsets, textsec->target_index) = vp->tstart;
datasec = bfd_get_section_by_name (vp->bfd, ".data");
ANOFFSET (new_offsets, datasec->target_index) = vp->dstart;
bsssec = bfd_get_section_by_name (vp->bfd, ".bss");
ANOFFSET (new_offsets, bsssec->target_index) = vp->dstart;
vmap_symtab_1(s, vp, old_start)
register struct symtab *s;
register struct vmap *vp;
CORE_ADDR old_start;
{
register int i, j;
int len, blen;
register struct linetable *l;
struct blockvector *bv;
register struct block *b;
int depth;
register ulong reloc, dreloc;
if ((reloc = vp->tstart - old_start) == 0)
return;
dreloc = vp->dstart; /* data relocation */
/*
* The line table must be relocated. This is only present for
* .text sections, so only vp->text type maps need be considered.
*/
l = LINETABLE (s);
if (l) {
len = l->nitems;
for (i = 0; i < len; i++)
l->item[i].pc += reloc;
}
/* if this symbol table is not relocatable, only line table should
be relocated and the rest ignored. */
if (s->nonreloc)
return;
bv = BLOCKVECTOR(s);
len = BLOCKVECTOR_NBLOCKS(bv);
for (i = 0; i < len; i++) {
b = BLOCKVECTOR_BLOCK(bv, i);
BLOCK_START(b) += reloc;
BLOCK_END(b) += reloc;
blen = BLOCK_NSYMS(b);
for (j = 0; j < blen; j++) {
register struct symbol *sym;
sym = BLOCK_SYM(b, j);
switch (SYMBOL_NAMESPACE(sym)) {
case STRUCT_NAMESPACE:
case UNDEF_NAMESPACE:
continue;
case LABEL_NAMESPACE:
case VAR_NAMESPACE:
break;
}
switch (SYMBOL_CLASS(sym)) {
case LOC_CONST:
case LOC_CONST_BYTES:
case LOC_LOCAL:
case LOC_REGISTER:
case LOC_ARG:
case LOC_LOCAL_ARG:
case LOC_REF_ARG:
case LOC_REGPARM:
case LOC_TYPEDEF:
continue;
#ifdef FIXME
case LOC_EXTERNAL:
#endif
case LOC_LABEL:
SYMBOL_VALUE_ADDRESS(sym) += reloc;
break;
case LOC_STATIC:
SYMBOL_VALUE_ADDRESS(sym) += dreloc;
break;
case LOC_BLOCK:
break;
default:
fatal("botched symbol class %x"
, SYMBOL_CLASS(sym));
break;
}
}
}
objfile_relocate (objfile, new_offsets);
if (old_text_offset != ANOFFSET (new_offsets, textsec->target_index))
/* breakpoints need to be relocated as well. */
fixup_breakpoints (0, TEXT_SEGMENT_BASE, vp->tstart - old_text_offset);
}
/* Add symbols for an objfile. */
@ -554,7 +438,7 @@ add_vmap(ldi)
"Error while reading shared library symbols:\n"))
{
/* Note this is only done if symbol reading was successful. */
vmap_symtab (vp, 0, 0);
vmap_symtab (vp);
vp->loaded = 1;
}
#endif
@ -698,7 +582,7 @@ retry:
}
/* relocate symbol table(s). */
vmap_symtab(vp, ostart, &vi);
vmap_symtab (vp);
/* there may be more, so we don't break out of the loop. */
}
@ -1079,7 +963,7 @@ bfd_err:
stp->endaddr = bfd_section_vma (stp->bfd, stp->sec_ptr) + vp->dend;
}
vmap_symtab (vp, 0, 0);
vmap_symtab (vp);
add_text_to_loadinfo (ldip->ldinfo_textorg, ldip->ldinfo_dataorg);
} while (ldip->ldinfo_next != 0);

View File

@ -50,7 +50,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "objfiles.h"
#include "buildsym.h"
#include "stabsread.h"
#include "gdb-stabs.h"
#include "complaints.h"
#include "coff/internal.h" /* FIXME, internal data from BFD */
@ -201,6 +200,9 @@ init_lineno PARAMS ((bfd *, file_ptr, int));
static void
find_linenos PARAMS ((bfd *, sec_ptr, PTR));
static void
read_symbol PARAMS ((struct internal_syment *, int));
static int
read_symbol_lineno PARAMS ((int));
@ -972,7 +974,7 @@ retrieve_traceback (abfd, textsec, cs, size)
/* Reading symbol table has to be fast! Keep the followings as macros, rather
than functions. */
#define RECORD_MINIMAL_SYMBOL(NAME, ADDR, TYPE, ALLOCED) \
#define RECORD_MINIMAL_SYMBOL(NAME, ADDR, TYPE, ALLOCED, SECTION) \
{ \
char *namestr; \
if (ALLOCED) \
@ -982,7 +984,8 @@ retrieve_traceback (abfd, textsec, cs, size)
obstack_copy0 (&objfile->symbol_obstack, (NAME) + 1, strlen ((NAME)+1)); \
(ALLOCED) = 1; \
} \
prim_record_minimal_symbol (namestr, (ADDR), (TYPE)); \
prim_record_minimal_symbol_and_info (namestr, (ADDR), (TYPE), \
(char *)NULL, (SECTION)); \
misc_func_recorded = 1; \
}
@ -1012,6 +1015,10 @@ static struct symbol parmsym;
static int static_block_base = 0;
/* Section number for the current static block. */
static int static_block_section = -1;
/* true if space for symbol name has been allocated. */
static int symname_alloced = 0;
@ -1056,6 +1063,7 @@ read_xcoff_symtab (objfile, nsyms)
char *last_csect_name; /* last seen csect's name and value */
CORE_ADDR last_csect_val;
int last_csect_sec;
int misc_func_recorded; /* true if any misc. function */
current_objfile = objfile;
@ -1154,7 +1162,7 @@ read_xcoff_symtab (objfile, nsyms)
if (cs->c_symnum == next_file_symnum && cs->c_sclass != C_FILE) {
if (last_source_file)
{
end_symtab (cur_src_end_addr, 1, 0, objfile);
end_symtab (cur_src_end_addr, 1, 0, objfile, textsec->target_index);
end_stabs ();
}
@ -1215,13 +1223,14 @@ read_xcoff_symtab (objfile, nsyms)
if (!misc_func_recorded) {
int alloced = 0;
RECORD_MINIMAL_SYMBOL (last_csect_name, last_csect_val,
mst_text, alloced);
mst_text, alloced, last_csect_sec);
}
complete_symtab (filestring, file_start_addr);
cur_src_end_addr = file_end_addr;
end_symtab (file_end_addr, 1, 0, objfile);
end_symtab (file_end_addr, 1, 0, objfile,
textsec->target_index);
end_stabs ();
start_stabs ();
start_symtab ((char *)NULL, (char *)NULL, (CORE_ADDR)0);
@ -1239,6 +1248,7 @@ read_xcoff_symtab (objfile, nsyms)
if (cs->c_name && cs->c_name[0] == '.') {
last_csect_name = cs->c_name;
last_csect_val = cs->c_value;
last_csect_sec = cs->c_secnum;
}
}
misc_func_recorded = 0;
@ -1270,7 +1280,7 @@ read_xcoff_symtab (objfile, nsyms)
function_entry_point:
RECORD_MINIMAL_SYMBOL (cs->c_name, cs->c_value, mst_text,
symname_alloced);
symname_alloced, cs->c_secnum);
fcn_line_offset = main_aux->x_sym.x_fcnary.x_fcn.x_lnnoptr;
fcn_start_addr = cs->c_value;
@ -1357,8 +1367,9 @@ function_entry_point:
/* Recording this entry is necessary. Single stepping relies on
this vector to get an idea about function address boundaries. */
prim_record_minimal_symbol ("<trampoline>", cs->c_value,
mst_unknown);
prim_record_minimal_symbol_and_info
("<trampoline>", cs->c_value, mst_unknown,
(char *)NULL, cs->c_secnum);
#else
/* record trampoline code entries as mst_unknown symbol. When we
@ -1389,7 +1400,7 @@ function_entry_point:
int alloced = 0;
RECORD_MINIMAL_SYMBOL (last_csect_name, last_csect_val,
mst_text, alloced);
mst_text, alloced, last_csect_sec);
}
/* c_value field contains symnum of next .file entry in table
@ -1406,7 +1417,7 @@ function_entry_point:
complete_symtab (filestring, file_start_addr);
cur_src_end_addr = file_end_addr;
end_symtab (file_end_addr, 1, 0, objfile);
end_symtab (file_end_addr, 1, 0, objfile, textsec->target_index);
end_stabs ();
start_stabs ();
start_symtab (cs->c_name, (char *)NULL, (CORE_ADDR)0);
@ -1526,6 +1537,8 @@ function_entry_point:
#else
new->name = define_symbol
(fcn_cs_saved.c_value, fcn_stab_saved.c_name, 0, 0, objfile);
if (new->name != NULL)
SYMBOL_SECTION (new->name) = cs->c_secnum;
#endif
}
else if (STREQ (cs->c_name, ".ef")) {
@ -1553,11 +1566,18 @@ function_entry_point:
break;
case C_BSTAT : /* begin static block */
static_block_base = read_symbol_nvalue (cs->c_value);
{
struct internal_syment symbol;
read_symbol (&symbol, cs->c_value);
static_block_base = symbol.n_value;
static_block_section = symbol.n_scnum;
}
break;
case C_ESTAT : /* end of static block */
static_block_base = 0;
static_block_section = -1;
break;
case C_ARG : /* These are not implemented. */
@ -1619,7 +1639,7 @@ function_entry_point:
if (last_source_file)
{
end_symtab (cur_src_end_addr, 1, 0, objfile);
end_symtab (cur_src_end_addr, 1, 0, objfile, textsec->target_index);
end_stabs ();
}
@ -1669,6 +1689,7 @@ process_xcoff_symbol (cs, objfile)
/* default assumptions */
SYMBOL_VALUE (sym) = cs->c_value;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
SYMBOL_SECTION (sym) = cs->c_secnum;
if (ISFCN (cs->c_type)) {
@ -1814,7 +1835,10 @@ process_xcoff_symbol (cs, objfile)
break;
#else /* !NO_DEFINE_SYMBOL */
return define_symbol (cs->c_value, cs->c_name, 0, 0, objfile);
sym = define_symbol (cs->c_value, cs->c_name, 0, 0, objfile);
if (sym != NULL)
SYMBOL_SECTION (sym) = cs->c_secnum;
return sym;
#endif
case C_GSYM:
@ -1835,9 +1859,14 @@ process_xcoff_symbol (cs, objfile)
add_symbol_to_list (sym2, &local_symbols);
break;
#else
sym = define_symbol (cs->c_value, cs->c_name, 0, 0, objfile);
SYMBOL_CLASS (sym) = (cs->c_sclass == C_PSYM) ? LOC_ARG : LOC_REGPARM;
return sym;
sym = define_symbol (cs->c_value, cs->c_name, 0, 0, objfile);
if (sym != NULL)
{
SYMBOL_CLASS (sym) =
(cs->c_sclass == C_PSYM) ? LOC_ARG : LOC_REGPARM;
SYMBOL_SECTION (sym) = cs->c_secnum;
}
return sym;
#endif
case C_STSYM:
@ -1865,7 +1894,11 @@ process_xcoff_symbol (cs, objfile)
++pp;
if (*pp == 'V') *pp = 'S';
sym = define_symbol (cs->c_value, cs->c_name, 0, 0, objfile);
SYMBOL_VALUE (sym) += static_block_base;
if (sym != NULL)
{
SYMBOL_VALUE (sym) += static_block_base;
SYMBOL_SECTION (sym) = static_block_section;
}
return sym;
#endif
@ -1876,6 +1909,7 @@ process_xcoff_symbol (cs, objfile)
SYMBOL_CLASS (sym) = LOC_LOCAL;
pp += 1;
SYMBOL_TYPE (sym) = read_type (&pp, objfile);
SYMBOL_SECTION (sym) = cs->c_secnum;
SYMBOL_DUP (sym, sym2);
add_symbol_to_list (sym2, &local_symbols);
break;
@ -1883,6 +1917,7 @@ process_xcoff_symbol (cs, objfile)
case C_AUTO:
SYMBOL_CLASS (sym) = LOC_LOCAL;
SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced);
SYMBOL_SECTION (sym) = cs->c_secnum;
SYMBOL_DUP (sym, sym2);
add_symbol_to_list (sym2, &local_symbols);
break;
@ -1890,6 +1925,7 @@ process_xcoff_symbol (cs, objfile)
case C_EXT:
SYMBOL_CLASS (sym) = LOC_STATIC;
SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced);
SYMBOL_SECTION (sym) = cs->c_secnum;
SYMBOL_DUP (sym, sym2);
add_symbol_to_list (sym2, &global_symbols);
break;
@ -1897,6 +1933,7 @@ process_xcoff_symbol (cs, objfile)
case C_STAT:
SYMBOL_CLASS (sym) = LOC_STATIC;
SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced);
SYMBOL_SECTION (sym) = cs->c_secnum;
SYMBOL_DUP (sym, sym2);
add_symbol_to_list
(sym2, within_function ? &local_symbols : &file_symbols);
@ -1906,6 +1943,7 @@ process_xcoff_symbol (cs, objfile)
printf ("ERROR! C_REG is not fully implemented!\n");
SYMBOL_CLASS (sym) = LOC_REGISTER;
SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced);
SYMBOL_SECTION (sym) = cs->c_secnum;
SYMBOL_DUP (sym, sym2);
add_symbol_to_list (sym2, &local_symbols);
break;
@ -1935,6 +1973,8 @@ process_xcoff_symbol (cs, objfile)
#else
if (pp) {
sym = define_symbol (cs->c_value, cs->c_name, 0, 0, objfile);
if (sym != NULL)
SYMBOL_SECTION (sym) = cs->c_secnum;
return sym;
}
else {
@ -1951,6 +1991,24 @@ process_xcoff_symbol (cs, objfile)
return sym2;
}
/* Set *SYMBOL to symbol number symno in symtbl. */
static void
read_symbol (symbol, symno)
struct internal_syment *symbol;
int symno;
{
if (symno < 0 || symno >= symtbl_num_syms)
{
struct complaint msg =
{"Invalid symbol offset", 0, 0};
complain (&msg);
symbol->n_value = 0;
symbol->n_scnum = -1;
return;
}
bfd_coff_swap_sym_in (symfile_bfd, symtbl + (symno*local_symesz), symbol);
}
/* Get value corresponding to symbol number symno in symtbl. */
static int
@ -1959,14 +2017,7 @@ read_symbol_nvalue (symno)
{
struct internal_syment symbol[1];
if (symno < 0 || symno >= symtbl_num_syms)
{
struct complaint msg =
{"Invalid symbol offset", 0, 0};
complain (&msg);
return 0;
}
bfd_coff_swap_sym_in (symfile_bfd, symtbl + (symno*local_symesz), symbol);
read_symbol (symbol, symno);
return symbol->n_value;
}
@ -2313,8 +2364,19 @@ xcoff_symfile_read (objfile, section_offset, mainline)
select_source_symtab (0);
}
/* XCOFF-specific parsing routine for section offsets.
Plain and simple for now. */
/* XCOFF-specific parsing routine for section offsets. */
static int largest_section;
static void
note_one_section (abfd, asect, ptr)
bfd *abfd;
asection *asect;
PTR ptr;
{
if (asect->target_index > largest_section)
largest_section = asect->target_index;
}
static
struct section_offsets *
@ -2324,13 +2386,17 @@ xcoff_symfile_offsets (objfile, addr)
{
struct section_offsets *section_offsets;
int i;
section_offsets = (struct section_offsets *)
obstack_alloc (&objfile -> psymbol_obstack,
sizeof (struct section_offsets) +
sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1));
for (i = 0; i < SECT_OFF_MAX; i++)
largest_section = 0;
bfd_map_over_sections (objfile->obfd, note_one_section, NULL);
objfile->num_sections = largest_section + 1;
section_offsets = (struct section_offsets *)
obstack_alloc
(&objfile -> psymbol_obstack,
sizeof (struct section_offsets)
+ sizeof (section_offsets->offsets) * (objfile->num_sections));
for (i = 0; i < objfile->num_sections; i++)
ANOFFSET (section_offsets, i) = addr;
return section_offsets;

View File

@ -40,10 +40,8 @@ struct vmap {
/* This is NULL for the exec-file. */
struct objfile *objfile;
CORE_ADDR ostart; /* objext start ??? */
unsigned loaded:1; /* True if symbols are loaded */
unsigned reloced:1; /* True, if symbols relocated */
unsigned padding:14;
unsigned padding:15;
};