From 9438d64262d8f6faebebf9f32d0229a5d60e5b6b Mon Sep 17 00:00:00 2001 From: Jim Kingdon Date: Tue, 12 Oct 1993 20:02:11 +0000 Subject: [PATCH] * stabsread.h, stabsread.c, dbxread.c (common_block*, copy_pending): Move common block handling from dbxread.c to stabsread.c. Use the name from the BCOMM instead of the ECOMM. Allocate things on the symbol_obstack. * xcoffread.c (process_xcoff_symbol): Process C_BCOMM, C_ECOMM, and C_ECOML. On unrecognized storage classes, go ahead and call define_symbol (after the complaint). * dbxread.c (process_one_symbol): Don't relocate 'S' symbols by the text offset. --- gdb/ChangeLog | 13 +++++++ gdb/stabsread.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++ gdb/stabsread.h | 12 ++---- gdb/xcoffread.c | 27 +++++++------ 4 files changed, 131 insertions(+), 21 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 09e957f4514..82a446ebcc1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +Tue Oct 12 08:59:15 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * stabsread.h, stabsread.c, dbxread.c (common_block*, copy_pending): + Move common block handling from dbxread.c to stabsread.c. + Use the name from the BCOMM instead of the ECOMM. + Allocate things on the symbol_obstack. + * xcoffread.c (process_xcoff_symbol): Process C_BCOMM, C_ECOMM, + and C_ECOML. On unrecognized storage classes, go ahead and call + define_symbol (after the complaint). + + * dbxread.c (process_one_symbol): Don't relocate 'S' symbols by + the text offset. + Tue Oct 12 12:33:09 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) * osfsolib.c (solib_create_inferior_hook): Reset stop_soon_quietly diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 5731e69f7c1..667f5192904 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -3388,6 +3388,103 @@ read_args (pp, end, objfile) memcpy (rval, types, n * sizeof (struct type *)); return rval; } + +/* Common block handling. */ + +/* List of symbols declared since the last BCOMM. This list is a tail + of local_symbols. When ECOMM is seen, the symbols on the list + are noted so their proper addresses can be filled in later, + using the common block base address gotten from the assembler + stabs. */ + +static struct pending *common_block; +static int common_block_i; + +/* Name of the current common block. We get it from the BCOMM instead of the + ECOMM to match IBM documentation (even though IBM puts the name both places + like everyone else). */ +static char *common_block_name; + +/* Process a N_BCOMM symbol. The storage for NAME is not guaranteed + to remain after this function returns. */ + +void +common_block_start (name, objfile) + char *name; + struct objfile *objfile; +{ + if (common_block_name != NULL) + { + static struct complaint msg = { + "Invalid symbol data: common block within common block", + 0, 0}; + complain (&msg); + } + common_block = local_symbols; + common_block_i = local_symbols ? local_symbols->nsyms : 0; + common_block_name = obsavestring (name, strlen (name), + &objfile -> symbol_obstack); +} + +/* Process a N_ECOMM symbol. */ + +void +common_block_end (objfile) + struct objfile *objfile; +{ + /* Symbols declared since the BCOMM are to have the common block + start address added in when we know it. common_block and + common_block_i point to the first symbol after the BCOMM in + the local_symbols list; copy the list and hang it off the + symbol for the common block name for later fixup. */ + int i; + struct symbol *sym; + struct pending *new = 0; + struct pending *next; + int j; + + if (common_block_name == NULL) + { + static struct complaint msg = {"ECOMM symbol unmatched by BCOMM", 0, 0}; + complain (&msg); + return; + } + + sym = (struct symbol *) + obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symbol)); + memset (sym, 0, sizeof (struct symbol)); + SYMBOL_NAME (sym) = common_block_name; + SYMBOL_CLASS (sym) = LOC_BLOCK; + + /* Now we copy all the symbols which have been defined since the BCOMM. */ + + /* Copy all the struct pendings before common_block. */ + for (next = local_symbols; + next != NULL && next != common_block; + next = next->next) + { + for (j = 0; j < next->nsyms; j++) + add_symbol_to_list (next->symbol[j], &new); + } + + /* Copy however much of COMMON_BLOCK we need. If COMMON_BLOCK is + NULL, it means copy all the local symbols (which we already did + above). */ + + if (common_block != NULL) + for (j = common_block_i; j < common_block->nsyms; j++) + add_symbol_to_list (common_block->symbol[j], &new); + + SYMBOL_NAMESPACE (sym) = (enum namespace)((long) new); + + /* Should we be putting local_symbols back to what it was? + Does it matter? */ + + i = hashname (SYMBOL_NAME (sym)); + SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i]; + global_sym_chain[i] = sym; + common_block_name = NULL; +} /* Add a common block's start address to the offset of each symbol declared to be in it (by being between a BCOMM/ECOMM pair that uses @@ -3624,6 +3721,9 @@ void start_stabs () n_this_object_header_files = 1; type_vector_length = 0; type_vector = (struct type **) 0; + + /* FIXME: If common_block_name is not already NULL, we should complain(). */ + common_block_name = NULL; } /* Call after end_symtab() */ diff --git a/gdb/stabsread.h b/gdb/stabsread.h index 67cefc250d3..3b890d80584 100644 --- a/gdb/stabsread.h +++ b/gdb/stabsread.h @@ -44,6 +44,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ EXTERN struct symbol *global_sym_chain[HASHSIZE]; +extern void common_block_start PARAMS ((char *, struct objfile *)); +extern void common_block_end PARAMS ((struct objfile *)); + /* Kludge for xcoffread.c */ struct pending_stabs @@ -55,15 +58,6 @@ struct pending_stabs EXTERN struct pending_stabs *global_stabs; -/* List of symbols declared since the last BCOMM. This list is a tail - of local_symbols. When ECOMM is seen, the symbols on the list - are noted so their proper addresses can be filled in later, - using the common block base address gotten from the assembler - stabs. */ - -EXTERN struct pending *common_block; -EXTERN int common_block_i; - /* The type code that process_one_symbol saw on its previous invocation. Used to detect pairs of N_SO symbols. */ diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index c6a138aeaaa..3ecdf1869cd 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -1598,19 +1598,26 @@ process_xcoff_symbol (cs, objfile) break; #endif - case C_DECL: /* a type decleration?? */ - - sym = define_symbol (cs->c_value, cs->c_name, 0, 0, objfile); - if (sym != NULL) - SYMBOL_SECTION (sym) = cs->c_secnum; - return sym; - case C_GSYM: add_stab_to_list (name, &global_stabs); break; + case C_BCOMM: + common_block_start (cs->c_name, objfile); + break; + + case C_ECOMM: + common_block_end (objfile); + break; + + default: + complain (&storclass_complaint, cs->c_sclass); + /* FALLTHROUGH */ + + case C_DECL: case C_PSYM: case C_RPSYM: + case C_ECOML: sym = define_symbol (cs->c_value, cs->c_name, 0, 0, objfile); if (sym != NULL) @@ -1624,7 +1631,7 @@ process_xcoff_symbol (cs, objfile) /* If we are going to use Sun dbx's define_symbol(), we need to massage our stab string a little. Change 'V' type to 'S' to be comparible with Sun. */ - /* FIXME: I believe this is to avoid a Sun-specific hack somewhere. + /* FIXME: Is this to avoid a Sun-specific hack somewhere? Needs more investigation. */ if (*name == ':' || (pp = (char *) strchr(name, ':')) == NULL) @@ -1694,10 +1701,6 @@ process_xcoff_symbol (cs, objfile) complain (&rsym_complaint, name); return NULL; } - - default : - complain (&storclass_complaint, cs->c_sclass); - return NULL; } } return sym2; -- 2.30.2