* xcoffread.c (process_xcoff_symbol): Use new variables

func_symbol_type and var_symbol_type as type of functions and
	variables which don't have any stabs associated with them.
	Reindent most of function.
	(_initialize_xcoffread): Initialize *_symbol_type.

	* xcoffread.c (read_xcoff_symtab): Reindent most of function.
	Put C_HIDEXT symbols in the minimal symbols, rather than ignoring
	them (this part commented out as I didn't quite get it to work).
	(cs_to_section, find_targ_sec): New functions, to support above code.
	* xcoffread.c (RECORD_MINIMAL_SYMBOL): Only skip '.' if it is
	actually present.
This commit is contained in:
Jim Kingdon 1995-01-31 18:38:06 +00:00
parent 1abb243d51
commit a81ce07da8
2 changed files with 738 additions and 555 deletions

View file

@ -1,3 +1,18 @@
Tue Jan 31 09:40:11 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
* xcoffread.c (process_xcoff_symbol): Use new variables
func_symbol_type and var_symbol_type as type of functions and
variables which don't have any stabs associated with them.
Reindent most of function.
(_initialize_xcoffread): Initialize *_symbol_type.
* xcoffread.c (read_xcoff_symtab): Reindent most of function.
Put C_HIDEXT symbols in the minimal symbols, rather than ignoring
them (this part commented out as I didn't quite get it to work).
(cs_to_section, find_targ_sec): New functions, to support above code.
* xcoffread.c (RECORD_MINIMAL_SYMBOL): Only skip '.' if it is
actually present.
Mon Jan 30 17:34:24 1995 Stu Grossman (grossman@cygnus.com) Mon Jan 30 17:34:24 1995 Stu Grossman (grossman@cygnus.com)
* gdbtk.tcl (create_file_win): Disable old popup menu for source * gdbtk.tcl (create_file_win): Disable old popup menu for source

View file

@ -54,6 +54,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "stabsread.h" #include "stabsread.h"
#include "complaints.h" #include "complaints.h"
#include "gdb-stabs.h"
/* For interface with stabsread.c. */ /* For interface with stabsread.c. */
#include "aout/stab_gnu.h" #include "aout/stab_gnu.h"
@ -208,6 +210,51 @@ read_xcoff_symtab PARAMS ((struct objfile *, int));
static void static void
add_stab_to_list PARAMS ((char *, struct pending_stabs **)); add_stab_to_list PARAMS ((char *, struct pending_stabs **));
#ifdef STATIC_NODEBUG_VARS
/* Return the section_offsets* that CS points to. */
static int cs_to_section PARAMS ((struct coff_symbol *, struct objfile *));
struct find_targ_sec_arg {
int targ_index;
int *resultp;
};
static void find_targ_sec PARAMS ((bfd *, asection *, void *));
static void find_targ_sec (abfd, sect, obj)
bfd *abfd;
asection *sect;
PTR obj;
{
struct find_targ_sec_arg *args = (struct find_targ_sec_arg *)obj;
if (sect->target_index == args->targ_index)
{
/* This is the section. Figure out what SECT_OFF_* code it is. */
if (bfd_get_section_flags (abfd, sect) & SEC_CODE)
*args->resultp = SECT_OFF_TEXT;
else if (bfd_get_section_flags (abfd, sect) & SEC_LOAD)
*args->resultp = SECT_OFF_DATA;
else
*args->resultp = SECT_OFF_BSS;
}
}
/* Return the section number (SECT_OFF_*) that CS points to. */
static int
cs_to_section (cs, objfile)
struct coff_symbol *cs;
struct objfile *objfile;
{
int off = SECT_OFF_TEXT;
struct find_targ_sec_arg args;
args.targ_index = cs->c_secnum;
args.resultp = &off;
bfd_map_over_sections (objfile->obfd, find_targ_sec, &args);
return off;
}
#endif /* STATIC_NODEBUG_VARS */
/* add a given stab string into given stab vector. */ /* add a given stab string into given stab vector. */
static void static void
@ -938,11 +985,11 @@ retrieve_traceback (abfd, textsec, cs, size)
#define RECORD_MINIMAL_SYMBOL(NAME, ADDR, TYPE, ALLOCED, SECTION, OBJFILE) \ #define RECORD_MINIMAL_SYMBOL(NAME, ADDR, TYPE, ALLOCED, SECTION, OBJFILE) \
{ \ { \
char *namestr; \ char *namestr; \
if (ALLOCED) \ namestr = (NAME); \
namestr = (NAME) + 1; \ if (namestr[0] == '.') ++namestr; \
else { \ if (!(ALLOCED)) { \
(NAME) = namestr = \ (NAME) = namestr = \
obstack_copy0 (&objfile->symbol_obstack, (NAME) + 1, strlen ((NAME)+1)); \ obstack_copy0 (&objfile->symbol_obstack, namestr, strlen (namestr)); \
(ALLOCED) = 1; \ (ALLOCED) = 1; \
} \ } \
prim_record_minimal_symbol_and_info (namestr, (ADDR), (TYPE), \ prim_record_minimal_symbol_and_info (namestr, (ADDR), (TYPE), \
@ -1068,7 +1115,8 @@ read_xcoff_symtab (objfile, nsyms)
current_objfile = objfile; current_objfile = objfile;
/* Get the appropriate COFF "constants" related to the file we're handling. */ /* Get the appropriate COFF "constants" related to the file we're
handling. */
N_TMASK = coff_data (abfd)->local_n_tmask; N_TMASK = coff_data (abfd)->local_n_tmask;
N_BTSHFT = coff_data (abfd)->local_n_btshft; N_BTSHFT = coff_data (abfd)->local_n_btshft;
local_symesz = coff_data (abfd)->local_symesz; local_symesz = coff_data (abfd)->local_symesz;
@ -1098,21 +1146,24 @@ read_xcoff_symtab (objfile, nsyms)
raw_symbol = symtbl; raw_symbol = symtbl;
textsec = bfd_get_section_by_name (abfd, ".text"); textsec = bfd_get_section_by_name (abfd, ".text");
if (!textsec) { if (!textsec)
{
printf_unfiltered ("Unable to locate text section!\n"); printf_unfiltered ("Unable to locate text section!\n");
} }
next_symbol_text_func = xcoff_next_symbol_text; next_symbol_text_func = xcoff_next_symbol_text;
while (symnum < nsyms) { while (symnum < nsyms)
{
QUIT; /* make this command interruptable. */ QUIT; /* make this command interruptable. */
/* READ_ONE_SYMBOL (symbol, cs, symname_alloced); */ /* READ_ONE_SYMBOL (symbol, cs, symname_alloced); */
/* read one symbol into `cs' structure. After processing the whole symbol /* read one symbol into `cs' structure. After processing the
table, only string table will be kept in memory, symbol table and debug whole symbol table, only string table will be kept in memory,
section of xcoff will be freed. Thus we can mark symbols with names symbol table and debug section of xcoff will be freed. Thus
in string table as `alloced'. */ we can mark symbols with names in string table as
`alloced'. */
{ {
int ii; int ii;
@ -1121,7 +1172,8 @@ read_xcoff_symtab (objfile, nsyms)
cs->c_symnum = symnum; cs->c_symnum = symnum;
cs->c_naux = symbol->n_numaux; cs->c_naux = symbol->n_numaux;
if (symbol->n_zeroes) { if (symbol->n_zeroes)
{
symname_alloced = 0; symname_alloced = 0;
/* We must use the original, unswapped, name here so the name field /* We must use the original, unswapped, name here so the name field
pointed to by cs->c_name will persist throughout xcoffread. If pointed to by cs->c_name will persist throughout xcoffread. If
@ -1138,10 +1190,15 @@ read_xcoff_symtab (objfile, nsyms)
cs->c_name = p; cs->c_name = p;
symname_alloced = 1; symname_alloced = 1;
} }
} else if (symbol->n_sclass & 0x80) { }
else if (symbol->n_sclass & 0x80)
{
cs->c_name = debugsec + symbol->n_offset; cs->c_name = debugsec + symbol->n_offset;
symname_alloced = 0; symname_alloced = 0;
} else { /* in string table */ }
else
{
/* in string table */
cs->c_name = strtbl + (int)symbol->n_offset; cs->c_name = strtbl + (int)symbol->n_offset;
symname_alloced = 1; symname_alloced = 1;
} }
@ -1153,23 +1210,28 @@ read_xcoff_symtab (objfile, nsyms)
raw_symbol += coff_data (abfd)->local_symesz; raw_symbol += coff_data (abfd)->local_symesz;
++symnum; ++symnum;
raw_auxptr = raw_symbol; /* Save addr of first aux entry */ /* Save addr of first aux entry. */
raw_auxptr = raw_symbol;
/* Skip all the auxents associated with this symbol. */ /* Skip all the auxents associated with this symbol. */
for (ii = symbol->n_numaux; ii; --ii ) { for (ii = symbol->n_numaux; ii; --ii)
{
raw_symbol += coff_data (abfd)->local_auxesz; raw_symbol += coff_data (abfd)->local_auxesz;
++symnum; ++symnum;
} }
} }
/* if symbol name starts with ".$" or "$", ignore it. */ /* if symbol name starts with ".$" or "$", ignore it. */
if (cs->c_name[0] == '$' || (cs->c_name[1] == '$' && cs->c_name[0] == '.')) if (cs->c_name[0] == '$'
|| (cs->c_name[1] == '$' && cs->c_name[0] == '.'))
continue; continue;
if (cs->c_symnum == next_file_symnum && cs->c_sclass != C_FILE) { if (cs->c_symnum == next_file_symnum && cs->c_sclass != C_FILE)
{
if (last_source_file) if (last_source_file)
{ {
end_symtab (cur_src_end_addr, 1, 0, objfile, textsec->target_index); end_symtab (cur_src_end_addr, 1, 0, objfile,
textsec->target_index);
end_stabs (); end_stabs ();
} }
@ -1180,15 +1242,17 @@ read_xcoff_symtab (objfile, nsyms)
} }
/* if explicitly specified as a function, treat is as one. */ /* if explicitly specified as a function, treat is as one. */
if (ISFCN(cs->c_type) && cs->c_sclass != C_TPDEF) { if (ISFCN(cs->c_type) && cs->c_sclass != C_TPDEF)
{
bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass, bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
0, cs->c_naux, &main_aux); 0, cs->c_naux, &main_aux);
goto function_entry_point; goto function_entry_point;
} }
if ((cs->c_sclass == C_EXT || cs->c_sclass == C_HIDEXT) && cs->c_naux == 1) if ((cs->c_sclass == C_EXT || cs->c_sclass == C_HIDEXT)
&& cs->c_naux == 1)
{ {
/* dealing with a symbol with a csect entry. */ /* Dealing with a symbol with a csect entry. */
#define CSECT(PP) ((PP)->x_csect) #define CSECT(PP) ((PP)->x_csect)
#define CSECT_LEN(PP) (CSECT(PP).x_scnlen.l) #define CSECT_LEN(PP) (CSECT(PP).x_scnlen.l)
@ -1200,16 +1264,20 @@ read_xcoff_symtab (objfile, nsyms)
bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass, bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
0, cs->c_naux, &main_aux); 0, cs->c_naux, &main_aux);
switch (CSECT_SMTYP (&main_aux)) { switch (CSECT_SMTYP (&main_aux))
{
case XTY_ER: case XTY_ER:
continue; /* ignore all external references. */ /* Ignore all external references. */
continue;
case XTY_SD : /* a section description. */ case XTY_SD:
/* A section description. */
{
switch (CSECT_SCLAS (&main_aux))
{ {
switch (CSECT_SCLAS (&main_aux)) {
case XMC_PR : /* a `.text' csect. */ case XMC_PR:
{ {
/* A program csect is seen. We have to allocate one /* A program csect is seen. We have to allocate one
@ -1223,20 +1291,23 @@ read_xcoff_symtab (objfile, nsyms)
approach does not work! GCC (and I think xlc) seem approach does not work! GCC (and I think xlc) seem
to put all the code in the unnamed program csect. */ to put all the code in the unnamed program csect. */
if (last_csect_name) { if (last_csect_name)
{
/* if no misc. function recorded in the last seen csect, enter /* If no misc. function recorded in the last
it as a function. This will take care of functions like seen csect, enter it as a function. This
strcmp() compiled by xlc. */ will take care of functions like strcmp()
compiled by xlc. */
if (!misc_func_recorded) { if (!misc_func_recorded)
{
int alloced = 0; int alloced = 0;
RECORD_MINIMAL_SYMBOL (last_csect_name, last_csect_val, RECORD_MINIMAL_SYMBOL
(last_csect_name, last_csect_val,
mst_text, alloced, last_csect_sec, mst_text, alloced, last_csect_sec,
objfile); objfile);
} }
complete_symtab (filestring, file_start_addr); complete_symtab (filestring, file_start_addr);
cur_src_end_addr = file_end_addr; cur_src_end_addr = file_end_addr;
end_symtab (file_end_addr, 1, 0, objfile, end_symtab (file_end_addr, 1, 0, objfile,
@ -1245,19 +1316,23 @@ read_xcoff_symtab (objfile, nsyms)
start_stabs (); start_stabs ();
/* Give all csects for this source file the same /* Give all csects for this source file the same
name. */ name. */
start_symtab (filestring, (char *)NULL, (CORE_ADDR)0); start_symtab (filestring, NULL, (CORE_ADDR)0);
} }
/* If this is the very first csect seen, basically `__start'. */ /* If this is the very first csect seen,
if (just_started) { basically `__start'. */
first_object_file_end = cs->c_value + CSECT_LEN (&main_aux); if (just_started)
{
first_object_file_end
= cs->c_value + CSECT_LEN (&main_aux);
just_started = 0; just_started = 0;
} }
file_start_addr = cs->c_value; file_start_addr = cs->c_value;
file_end_addr = cs->c_value + CSECT_LEN (&main_aux); file_end_addr = cs->c_value + CSECT_LEN (&main_aux);
if (cs->c_name && cs->c_name[0] == '.') { if (cs->c_name && cs->c_name[0] == '.')
{
last_csect_name = cs->c_name; last_csect_name = cs->c_name;
last_csect_val = cs->c_value; last_csect_val = cs->c_value;
last_csect_sec = cs->c_secnum; last_csect_sec = cs->c_secnum;
@ -1269,8 +1344,9 @@ read_xcoff_symtab (objfile, nsyms)
case XMC_RW : case XMC_RW :
break; break;
/* If the section is not a data description, ignore it. Note that /* If the section is not a data description,
uninitialized data will show up as XTY_CM/XMC_RW pair. */ ignore it. Note that uninitialized data will
show up as XTY_CM/XMC_RW pair. */
case XMC_TC0: case XMC_TC0:
if (toc_offset) if (toc_offset)
@ -1278,12 +1354,22 @@ read_xcoff_symtab (objfile, nsyms)
toc_offset = cs->c_value; toc_offset = cs->c_value;
continue; continue;
case XMC_TC : /* ignore toc entries */ case XMC_TC:
default : /* any other XMC_XXX */ #ifdef STATIC_NODEBUG_VARS
/* We need to process these symbols if they are C_HIDEXT,
for static variables in files compiled without -g. */
if (cs->c_sclass == C_HIDEXT)
break;
else
#endif
continue;
default:
/* Ignore the symbol. */
continue; continue;
} }
} }
break; /* switch CSECT_SCLAS() */ break;
case XTY_LD: case XTY_LD:
@ -1293,7 +1379,8 @@ read_xcoff_symtab (objfile, nsyms)
/* a function entry point. */ /* a function entry point. */
function_entry_point: function_entry_point:
RECORD_MINIMAL_SYMBOL (cs->c_name, cs->c_value, mst_text, RECORD_MINIMAL_SYMBOL (cs->c_name, cs->c_value, mst_text,
symname_alloced, cs->c_secnum, objfile); symname_alloced, cs->c_secnum,
objfile);
fcn_line_offset = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr; fcn_line_offset = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr;
fcn_start_addr = cs->c_value; fcn_start_addr = cs->c_value;
@ -1303,7 +1390,6 @@ read_xcoff_symtab (objfile, nsyms)
fcn_cs_saved = *cs; fcn_cs_saved = *cs;
fcn_aux_saved = main_aux; fcn_aux_saved = main_aux;
ptb = NULL; ptb = NULL;
/* If function has two auxent, then debugging information is /* If function has two auxent, then debugging information is
@ -1320,33 +1406,49 @@ read_xcoff_symtab (objfile, nsyms)
complain (&msg); complain (&msg);
} }
/* If there is traceback info, create and add parameters for it. */ /* If there is traceback info, create and add parameters
for it. */
if (ptb && (ptb->fixedparms || ptb->floatparms)) { if (ptb && (ptb->fixedparms || ptb->floatparms))
{
int parmcnt = ptb->fixedparms + ptb->floatparms; int parmcnt = ptb->fixedparms + ptb->floatparms;
char *parmcode = (char*) &ptb->parminfo; char *parmcode = (char*) &ptb->parminfo;
int parmvalue = ptb->framesize + 0x18; /* sizeof(LINK AREA) == 0x18 */
/* The link area is 0x18 bytes. */
int parmvalue = ptb->framesize + 0x18;
unsigned int ii, mask; unsigned int ii, mask;
for (ii=0, mask = 0x80000000; ii <parmcnt; ++ii) { for (ii=0, mask = 0x80000000; ii <parmcnt; ++ii)
{
struct symbol *parm; struct symbol *parm;
if (ptb->parminfo & mask) { /* float or double */ if (ptb->parminfo & mask)
{
/* float or double */
mask = mask >> 1; mask = mask >> 1;
if (ptb->parminfo & mask) { /* double parm */ if (ptb->parminfo & mask)
{
/* double parm */
ADD_PARM_TO_PENDING ADD_PARM_TO_PENDING
(parm, parmvalue, builtin_type_double, local_symbols); (parm, parmvalue, builtin_type_double,
local_symbols);
parmvalue += sizeof (double); parmvalue += sizeof (double);
} }
else { /* float parm */ else
{
/* float parm */
ADD_PARM_TO_PENDING ADD_PARM_TO_PENDING
(parm, parmvalue, builtin_type_float, local_symbols); (parm, parmvalue, builtin_type_float,
local_symbols);
parmvalue += sizeof (float); parmvalue += sizeof (float);
} }
} }
else { /* fixed parm, use (int*) for hex rep. */ else
ADD_PARM_TO_PENDING (parm, parmvalue, {
/* fixed parm, use (int*) for hex rep. */
ADD_PARM_TO_PENDING
(parm, parmvalue,
lookup_pointer_type (builtin_type_int), lookup_pointer_type (builtin_type_int),
local_symbols); local_symbols);
parmvalue += sizeof (int); parmvalue += sizeof (int);
@ -1354,10 +1456,12 @@ read_xcoff_symtab (objfile, nsyms)
mask = mask >> 1; mask = mask >> 1;
} }
/* Fake this as a function. Needed in process_xcoff_symbol() */ /* Fake this as a function. Needed in
process_xcoff_symbol(). */
cs->c_type = 32; cs->c_type = 32;
finish_block(process_xcoff_symbol (cs, objfile), &local_symbols, finish_block
(process_xcoff_symbol (cs, objfile), &local_symbols,
pending_blocks, cs->c_value, pending_blocks, cs->c_value,
cs->c_value + ptb->fsize, objfile); cs->c_value + ptb->fsize, objfile);
} }
@ -1366,10 +1470,12 @@ read_xcoff_symtab (objfile, nsyms)
case XMC_GL: case XMC_GL:
/* shared library function trampoline code entry point. */ /* shared library function trampoline code entry point. */
/* record trampoline code entries as mst_solib_trampoline symbol. /* record trampoline code entries as
When we lookup mst symbols, we will choose mst_text over mst_solib_trampoline symbol. When we lookup mst
symbols, we will choose mst_text over
mst_solib_trampoline. */ mst_solib_trampoline. */
RECORD_MINIMAL_SYMBOL (cs->c_name, cs->c_value, RECORD_MINIMAL_SYMBOL
(cs->c_name, cs->c_value,
mst_solib_trampoline, mst_solib_trampoline,
symname_alloced, cs->c_secnum, objfile); symname_alloced, cs->c_secnum, objfile);
continue; continue;
@ -1389,24 +1495,28 @@ read_xcoff_symtab (objfile, nsyms)
break; break;
} }
default : /* all other XTY_XXXs */ default:
break; break;
} /* switch CSECT_SMTYP() */ } }
}
switch (cs->c_sclass) { switch (cs->c_sclass)
{
case C_FILE: case C_FILE:
/* see if the last csect needs to be recorded. */ /* see if the last csect needs to be recorded. */
if (last_csect_name && !misc_func_recorded) { if (last_csect_name && !misc_func_recorded)
{
/* if no misc. function recorded in the last seen csect, enter /* If no misc. function recorded in the last seen csect, enter
it as a function. This will take care of functions like it as a function. This will take care of functions like
strcmp() compiled by xlc. */ strcmp() compiled by xlc. */
int alloced = 0; int alloced = 0;
RECORD_MINIMAL_SYMBOL (last_csect_name, last_csect_val, RECORD_MINIMAL_SYMBOL
(last_csect_name, last_csect_val,
mst_text, alloced, last_csect_sec, objfile); mst_text, alloced, last_csect_sec, objfile);
} }
@ -1415,12 +1525,12 @@ read_xcoff_symtab (objfile, nsyms)
next_file_symnum = cs->c_value; next_file_symnum = cs->c_value;
/* complete symbol table for last object file containing /* Complete symbol table for last object file containing
debugging information. */ debugging information. */
/* Whether or not there was a csect in the previous file, we have to call /* Whether or not there was a csect in the previous file, we
`end_stabs' and `start_stabs' to reset type_vector, have to call `end_stabs' and `start_stabs' to reset
line_vector, etc. structures. */ type_vector, line_vector, etc. structures. */
complete_symtab (filestring, file_start_addr); complete_symtab (filestring, file_start_addr);
cur_src_end_addr = file_end_addr; cur_src_end_addr = file_end_addr;
@ -1450,14 +1560,13 @@ read_xcoff_symtab (objfile, nsyms)
file_start_addr = file_end_addr = 0; file_start_addr = file_end_addr = 0;
break; break;
case C_FUN: case C_FUN:
fcn_stab_saved = *cs; fcn_stab_saved = *cs;
break; break;
case C_FCN: case C_FCN:
if (STREQ (cs->c_name, ".bf")) { if (STREQ (cs->c_name, ".bf"))
{
bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass, bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
0, cs->c_naux, &main_aux); 0, cs->c_naux, &main_aux);
@ -1473,20 +1582,22 @@ read_xcoff_symtab (objfile, nsyms)
if (new->name != NULL) if (new->name != NULL)
SYMBOL_SECTION (new->name) = cs->c_secnum; SYMBOL_SECTION (new->name) = cs->c_secnum;
} }
else if (STREQ (cs->c_name, ".ef")) { else if (STREQ (cs->c_name, ".ef"))
{
bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass, bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
0, cs->c_naux, &main_aux); 0, cs->c_naux, &main_aux);
/* the value of .ef is the address of epilogue code; /* The value of .ef is the address of epilogue code;
not useful for gdb */ not useful for gdb. */
/* { main_aux.x_sym.x_misc.x_lnsz.x_lnno /* { main_aux.x_sym.x_misc.x_lnsz.x_lnno
contains number of lines to '}' */ contains number of lines to '}' */
fcn_last_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno; fcn_last_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
new = pop_context (); new = pop_context ();
if (context_stack_depth != 0) if (context_stack_depth != 0)
error ("invalid symbol data; .bf/.ef/.bb/.eb symbol mismatch, at symbol %d.", error ("\
invalid symbol data; .bf/.ef/.bb/.eb symbol mismatch, at symbol %d.",
symnum); symnum);
finish_block (new->name, &local_symbols, new->old_blocks, finish_block (new->name, &local_symbols, new->old_blocks,
@ -1497,7 +1608,8 @@ read_xcoff_symtab (objfile, nsyms)
} }
break; break;
case C_BSTAT : /* begin static block */ case C_BSTAT:
/* Begin static block. */
{ {
struct internal_syment symbol; struct internal_syment symbol;
@ -1507,27 +1619,67 @@ read_xcoff_symtab (objfile, nsyms)
} }
break; break;
case C_ESTAT : /* end of static block */ case C_ESTAT:
/* End of static block. */
static_block_base = 0; static_block_base = 0;
static_block_section = -1; static_block_section = -1;
break; break;
case C_ARG : /* These are not implemented. */ case C_ARG:
case C_REGPARM: case C_REGPARM:
case C_TPDEF: case C_TPDEF:
case C_STRTAG: case C_STRTAG:
case C_UNTAG: case C_UNTAG:
case C_ENTAG: case C_ENTAG:
printf_unfiltered ("ERROR: Unimplemented storage class: %d.\n", cs->c_sclass); printf_unfiltered
("ERROR: Unimplemented storage class: %d.\n", cs->c_sclass);
break; break;
case C_HIDEXT : /* ignore these.. */
case C_LABEL: case C_LABEL:
case C_NULL: case C_NULL:
/* Ignore these. */
break; break;
case C_BINCL : /* beginning of include file */ #ifdef STATIC_NODEBUG_VARS
/* This is wrong. These symbols are XMC_TC, which means that
the value of the symbol is the address of the TOC entry, not
the address of the variable itself. */
case C_HIDEXT:
{
/* This is the only place that static variables show up in files
compiled without -g. External variables also have a C_EXT,
so that is why we record everything as mst_file_* here. */
enum minimal_symbol_type ms_type;
CORE_ADDR tmpaddr;
int sec;
sec = cs_to_section (cs, objfile);
tmpaddr = cs->c_value;
switch (sec)
{
case SECT_OFF_TEXT:
case SECT_OFF_RODATA:
ms_type = mst_file_text;
break;
case SECT_OFF_DATA:
ms_type = mst_file_data;
break;
case SECT_OFF_BSS:
ms_type = mst_file_bss;
break;
default:
ms_type = mst_unknown;
break;
}
RECORD_MINIMAL_SYMBOL (cs->c_name, cs->c_value, ms_type,
symname_alloced, cs->c_secnum, objfile);
}
#endif /* STATIC_NODEBUG_VARS */
break;
case C_BINCL:
/* beginning of include file */
/* In xlc output, C_BINCL/C_EINCL pair doesn't show up in sorted /* In xlc output, C_BINCL/C_EINCL pair doesn't show up in sorted
order. Thus, when wee see them, we might not know enough info order. Thus, when wee see them, we might not know enough info
to process them. Thus, we'll be saving them into a table to process them. Thus, we'll be saving them into a table
@ -1536,24 +1688,29 @@ read_xcoff_symtab (objfile, nsyms)
record_include_begin (cs); record_include_begin (cs);
break; break;
case C_EINCL : /* end of include file */ case C_EINCL:
/* see the comment after case C_BINCL. */ /* End of include file. */
/* See the comment after case C_BINCL. */
record_include_end (cs); record_include_end (cs);
break; break;
case C_BLOCK: case C_BLOCK:
if (STREQ (cs->c_name, ".bb")) { if (STREQ (cs->c_name, ".bb"))
{
depth++; depth++;
new = push_context (depth, cs->c_value); new = push_context (depth, cs->c_value);
} }
else if (STREQ (cs->c_name, ".eb")) { else if (STREQ (cs->c_name, ".eb"))
{
new = pop_context (); new = pop_context ();
if (depth != new->depth) if (depth != new->depth)
error ("Invalid symbol data: .bb/.eb symbol mismatch at symbol %d.", error ("\
Invalid symbol data: .bb/.eb symbol mismatch at symbol %d.",
symnum); symnum);
depth--; depth--;
if (local_symbols && context_stack_depth > 0) { if (local_symbols && context_stack_depth > 0)
{
/* Make a block for the local symbols within. */ /* Make a block for the local symbols within. */
finish_block (new->name, &local_symbols, new->old_blocks, finish_block (new->name, &local_symbols, new->old_blocks,
new->start_addr, cs->c_value, objfile); new->start_addr, cs->c_value, objfile);
@ -1566,8 +1723,7 @@ read_xcoff_symtab (objfile, nsyms)
process_xcoff_symbol (cs, objfile); process_xcoff_symbol (cs, objfile);
break; break;
} }
}
} /* while */
if (last_source_file) if (last_source_file)
{ {
@ -1597,6 +1753,9 @@ read_xcoff_symtab (objfile, nsyms)
(ALLOCED) ? (NAME) : obstack_copy0 (&objfile->symbol_obstack, (NAME), strlen (NAME)); (ALLOCED) ? (NAME) : obstack_copy0 (&objfile->symbol_obstack, (NAME), strlen (NAME));
static struct type *func_symbol_type;
static struct type *var_symbol_type;
/* process one xcoff symbol. */ /* process one xcoff symbol. */
static struct symbol * static struct symbol *
@ -1623,14 +1782,14 @@ process_xcoff_symbol (cs, objfile)
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
SYMBOL_SECTION (sym) = cs->c_secnum; SYMBOL_SECTION (sym) = cs->c_secnum;
if (ISFCN (cs->c_type)) { if (ISFCN (cs->c_type))
{
/* At this point, we don't know the type of the function and assume it /* At this point, we don't know the type of the function. This
is int. This will be patched with the type from its stab entry later will be patched with the type from its stab entry later on in
on in patch_block_stabs () */ patch_block_stabs (), unless the file was compiled without -g. */
SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced); SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced);
SYMBOL_TYPE (sym) = lookup_function_type (lookup_fundamental_type (objfile, FT_INTEGER)); SYMBOL_TYPE (sym) = func_symbol_type;
SYMBOL_CLASS (sym) = LOC_BLOCK; SYMBOL_CLASS (sym) = LOC_BLOCK;
SYMBOL_DUP (sym, sym2); SYMBOL_DUP (sym, sym2);
@ -1640,11 +1799,10 @@ process_xcoff_symbol (cs, objfile)
else if (cs->c_sclass == C_HIDEXT || cs->c_sclass == C_STAT) else if (cs->c_sclass == C_HIDEXT || cs->c_sclass == C_STAT)
add_symbol_to_list (sym2, &file_symbols); add_symbol_to_list (sym2, &file_symbols);
} }
else
else { {
/* In case we can't figure out the type, provide default. */
/* in case we can't figure out the type, default is `int'. */ SYMBOL_TYPE (sym) = var_symbol_type;
SYMBOL_TYPE (sym) = lookup_fundamental_type (objfile, FT_INTEGER);
switch (cs->c_sclass) switch (cs->c_sclass)
{ {
@ -1687,11 +1845,12 @@ process_xcoff_symbol (cs, objfile)
case C_STSYM: case C_STSYM:
/* For xlc (not GCC), the 'V' symbol descriptor is used for all /* For xlc (not GCC), the 'V' symbol descriptor is used for
statics and we need to distinguish file-scope versus function-scope all statics and we need to distinguish file-scope versus
using within_function. We do this by changing the string we pass function-scope using within_function. We do this by
to define_symbol to use 'S' where we need to, which is not necessarily changing the string we pass to define_symbol to use 'S'
super-clean, but seems workable enough. */ where we need to, which is not necessarily super-clean,
but seems workable enough. */
if (*name == ':' || (pp = (char *) strchr(name, ':')) == NULL) if (*name == ':' || (pp = (char *) strchr(name, ':')) == NULL)
return NULL; return NULL;
@ -1751,13 +1910,15 @@ process_xcoff_symbol (cs, objfile)
case C_RSYM: case C_RSYM:
pp = (char*) strchr (name, ':'); pp = (char*) strchr (name, ':');
if (pp) { if (pp)
{
sym = 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) if (sym != NULL)
SYMBOL_SECTION (sym) = cs->c_secnum; SYMBOL_SECTION (sym) = cs->c_secnum;
return sym; return sym;
} }
else { else
{
complain (&rsym_complaint, name); complain (&rsym_complaint, name);
return NULL; return NULL;
} }
@ -2245,10 +2406,17 @@ _initialize_xcoffread ()
{ {
add_symtab_fns(&xcoff_sym_fns); add_symtab_fns(&xcoff_sym_fns);
/* Initialize symbol template later used for arguments. */ /* Initialize symbol template later used for arguments. Its other
fields are zero, or are filled in later. */
SYMBOL_NAME (&parmsym) = ""; SYMBOL_NAME (&parmsym) = "";
SYMBOL_INIT_LANGUAGE_SPECIFIC (&parmsym, language_c); SYMBOL_INIT_LANGUAGE_SPECIFIC (&parmsym, language_c);
SYMBOL_NAMESPACE (&parmsym) = VAR_NAMESPACE; SYMBOL_NAMESPACE (&parmsym) = VAR_NAMESPACE;
SYMBOL_CLASS (&parmsym) = LOC_ARG; SYMBOL_CLASS (&parmsym) = LOC_ARG;
/* Its other fields are zero, or are filled in later. */
func_symbol_type = init_type (TYPE_CODE_FUNC, 1, 0,
"<function, no debug info>", NULL);
TYPE_TARGET_TYPE (func_symbol_type) = builtin_type_int;
var_symbol_type =
init_type (TYPE_CODE_INT, TARGET_INT_BIT / HOST_CHAR_BIT, 0,
"<variable, no debug info>", NULL);
} }