* irix5-nat.c, osfsolib.c, solib.c (symbol_add_stub): Handle

missing or zero-sized .text sections properly.
	* mdebugread.c:  Handle scRConst and scSUndefined storage classes.
	* stabsread.c (scan_file_globals):  Try to resolve symbols
	for shared libraries from the minimal symbol table of the main
	executable first.
This commit is contained in:
Peter Schauer 1996-11-02 11:59:19 +00:00
parent 61e5b759cd
commit 73b8e6a915
5 changed files with 161 additions and 88 deletions

View file

@ -1,3 +1,12 @@
Sat Nov 2 03:54:13 1996 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
* irix5-nat.c, osfsolib.c, solib.c (symbol_add_stub): Handle
missing or zero-sized .text sections properly.
* mdebugread.c: Handle scRConst and scSUndefined storage classes.
* stabsread.c (scan_file_globals): Try to resolve symbols
for shared libraries from the minimal symbol table of the main
executable first.
start-sanitize-d10v
Fri Nov 1 13:59:28 1996 Martin M. Hunt <hunt@pizza.cygnus.com>

View file

@ -566,9 +566,28 @@ symbol_add_stub (arg)
char *arg;
{
register struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */
CORE_ADDR text_addr = 0;
if (so -> textsection)
text_addr = so -> textsection -> addr;
else
{
asection *lowest_sect;
/* If we didn't find a mapped non zero sized .text section, set up
text_addr so that the relocation in symbol_file_add does no harm. */
lowest_sect = bfd_get_section_by_name (so -> abfd, ".text");
if (lowest_sect == NULL)
bfd_map_over_sections (so -> abfd, find_lowest_section,
(PTR) &lowest_sect);
if (lowest_sect)
text_addr = bfd_section_vma (so -> abfd, lowest_sect)
+ (CORE_ADDR) LM_ADDR (so) - so -> lm.o_base_address;
}
so -> objfile = symbol_file_add (so -> lm.o_path, so -> from_tty,
(unsigned int) so -> textsection -> addr,
text_addr,
0, 0, 0);
return (1);
}

View file

@ -721,6 +721,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
switch (sh->sc)
{
case scText:
case scRConst:
/* Do not relocate relative values.
The value of a stEnd symbol is the displacement from the
corresponding start symbol value.
@ -790,7 +791,8 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
add_symbol (s, b);
/* Type could be missing if file is compiled without debugging info. */
if (sh->sc == scUndefined || sh->sc == scNil || sh->index == indexNil)
if (sh->sc == scUndefined || sh->sc == scSUndefined
|| sh->sc == scNil || sh->index == indexNil)
SYMBOL_TYPE (s) = nodebug_var_symbol_type;
else
SYMBOL_TYPE (s) = parse_type (cur_fd, ax, sh->index, 0, bigend, name);
@ -849,7 +851,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
SYMBOL_NAMESPACE (s) = VAR_NAMESPACE;
SYMBOL_CLASS (s) = LOC_BLOCK;
/* Type of the return value */
if (sh->sc == scUndefined || sh->sc == scNil)
if (sh->sc == scUndefined || sh->sc == scSUndefined || sh->sc == scNil)
t = mdebug_type_int;
else
{
@ -898,7 +900,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
add_block (b, top_stack->cur_st);
/* Not if we only have partial info */
if (sh->sc == scUndefined || sh->sc == scNil)
if (sh->sc == scUndefined || sh->sc == scSUndefined || sh->sc == scNil)
break;
push_parse_stack ();
@ -2081,7 +2083,8 @@ parse_external (es, bigend, section_offsets)
}
/* Reading .o files */
if (es->asym.sc == scUndefined || es->asym.sc == scNil)
if (es->asym.sc == scUndefined || es->asym.sc == scSUndefined
|| es->asym.sc == scNil)
{
char *what;
switch (es->asym.st)
@ -2387,7 +2390,8 @@ parse_partial_symbols (objfile, section_offsets)
extern_tab[fdr_to_pst[ext_in->ifd].globals_offset
+ fdr_to_pst[ext_in->ifd].n_globals++] = *ext_in;
if (ext_in->asym.sc == scUndefined || ext_in->asym.sc == scNil)
if (ext_in->asym.sc == scUndefined || ext_in->asym.sc == scSUndefined
|| ext_in->asym.sc == scNil)
continue;
name = debug_info->ssext + ext_in->asym.iss;
@ -2612,6 +2616,7 @@ parse_partial_symbols (objfile, section_offsets)
switch (sh.sc)
{
case scUndefined:
case scSUndefined:
case scNil:
case scAbs:
break;
@ -2677,7 +2682,8 @@ parse_partial_symbols (objfile, section_offsets)
}
/* Non absolute static symbols go into the minimal table. */
if (sh.sc == scUndefined || sh.sc == scNil
if (sh.sc == scUndefined || sh.sc == scSUndefined
|| sh.sc == scNil
|| (sh.index == indexNil
&& (sh.st != stStatic || sh.sc == scAbs)))
{
@ -2691,6 +2697,7 @@ parse_partial_symbols (objfile, section_offsets)
switch (sh.sc)
{
case scText:
case scRConst:
/* The value of a stEnd symbol is the displacement from the
corresponding start symbol value, do not relocate it. */
if (sh.st != stEnd)
@ -2895,13 +2902,15 @@ parse_partial_symbols (objfile, section_offsets)
psh = &ext_ptr->asym;
/* Do not add undefined symbols to the partial symbol table. */
if (psh->sc == scUndefined || psh->sc == scNil)
if (psh->sc == scUndefined || psh->sc == scSUndefined
|| psh->sc == scNil)
continue;
svalue = psh->value;
switch (psh->sc)
{
case scText:
case scRConst:
svalue += ANOFFSET (section_offsets, SECT_OFF_TEXT);
break;
case scData:

View file

@ -566,9 +566,27 @@ symbol_add_stub (arg)
char *arg;
{
register struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */
CORE_ADDR text_addr = 0;
if (so -> textsection)
text_addr = so -> textsection -> addr;
else
{
asection *lowest_sect;
/* If we didn't find a mapped non zero sized .text section, set up
text_addr so that the relocation in symbol_file_add does no harm. */
lowest_sect = bfd_get_section_by_name (so -> abfd, ".text");
if (lowest_sect == NULL)
bfd_map_over_sections (so -> abfd, find_lowest_section,
(PTR) &lowest_sect);
if (lowest_sect)
text_addr = bfd_section_vma (so -> abfd, lowest_sect) + LM_OFFSET (so);
}
so -> objfile = symbol_file_add (so -> so_name, so -> from_tty,
so -> textsection -> addr,
text_addr,
0, 0, 0);
return (1);
}

View file

@ -4491,87 +4491,105 @@ scan_file_globals (objfile)
int hash;
struct minimal_symbol *msymbol;
struct symbol *sym, *prev;
struct objfile *resolve_objfile;
/* Avoid expensive loop through all minimal symbols if there are
no unresolved symbols. */
for (hash = 0; hash < HASHSIZE; hash++)
/* SVR4 based linkers copy referenced global symbols from shared
libraries to the main executable.
If we are scanning the symbols for a shared library, try to resolve
them from the minimal symbols of the main executable first. */
if (symfile_objfile && objfile != symfile_objfile)
resolve_objfile = symfile_objfile;
else
resolve_objfile = objfile;
while (1)
{
if (global_sym_chain[hash])
/* Avoid expensive loop through all minimal symbols if there are
no unresolved symbols. */
for (hash = 0; hash < HASHSIZE; hash++)
{
if (global_sym_chain[hash])
break;
}
if (hash >= HASHSIZE)
return;
for (msymbol = resolve_objfile -> msymbols;
msymbol && SYMBOL_NAME (msymbol) != NULL;
msymbol++)
{
QUIT;
/* Skip static symbols. */
switch (MSYMBOL_TYPE (msymbol))
{
case mst_file_text:
case mst_file_data:
case mst_file_bss:
continue;
default:
break;
}
prev = NULL;
/* Get the hash index and check all the symbols
under that hash index. */
hash = hashname (SYMBOL_NAME (msymbol));
for (sym = global_sym_chain[hash]; sym;)
{
if (SYMBOL_NAME (msymbol)[0] == SYMBOL_NAME (sym)[0] &&
STREQ(SYMBOL_NAME (msymbol) + 1, SYMBOL_NAME (sym) + 1))
{
/* Splice this symbol out of the hash chain and
assign the value we have to it. */
if (prev)
{
SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym);
}
else
{
global_sym_chain[hash] = SYMBOL_VALUE_CHAIN (sym);
}
/* Check to see whether we need to fix up a common block. */
/* Note: this code might be executed several times for
the same symbol if there are multiple references. */
if (SYMBOL_CLASS (sym) == LOC_BLOCK)
{
fix_common_block (sym, SYMBOL_VALUE_ADDRESS (msymbol));
}
else
{
SYMBOL_VALUE_ADDRESS (sym)
= SYMBOL_VALUE_ADDRESS (msymbol);
}
SYMBOL_SECTION (sym) = SYMBOL_SECTION (msymbol);
if (prev)
{
sym = SYMBOL_VALUE_CHAIN (prev);
}
else
{
sym = global_sym_chain[hash];
}
}
else
{
prev = sym;
sym = SYMBOL_VALUE_CHAIN (sym);
}
}
}
if (resolve_objfile == objfile)
break;
}
if (hash >= HASHSIZE)
return;
for (msymbol = objfile -> msymbols;
msymbol && SYMBOL_NAME (msymbol) != NULL;
msymbol++)
{
QUIT;
/* Skip static symbols. */
switch (MSYMBOL_TYPE (msymbol))
{
case mst_file_text:
case mst_file_data:
case mst_file_bss:
continue;
default:
break;
}
prev = NULL;
/* Get the hash index and check all the symbols
under that hash index. */
hash = hashname (SYMBOL_NAME (msymbol));
for (sym = global_sym_chain[hash]; sym;)
{
if (SYMBOL_NAME (msymbol)[0] == SYMBOL_NAME (sym)[0] &&
STREQ(SYMBOL_NAME (msymbol) + 1, SYMBOL_NAME (sym) + 1))
{
/* Splice this symbol out of the hash chain and
assign the value we have to it. */
if (prev)
{
SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym);
}
else
{
global_sym_chain[hash] = SYMBOL_VALUE_CHAIN (sym);
}
/* Check to see whether we need to fix up a common block. */
/* Note: this code might be executed several times for
the same symbol if there are multiple references. */
if (SYMBOL_CLASS (sym) == LOC_BLOCK)
{
fix_common_block (sym, SYMBOL_VALUE_ADDRESS (msymbol));
}
else
{
SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msymbol);
}
SYMBOL_SECTION (sym) = SYMBOL_SECTION (msymbol);
if (prev)
{
sym = SYMBOL_VALUE_CHAIN (prev);
}
else
{
sym = global_sym_chain[hash];
}
}
else
{
prev = sym;
sym = SYMBOL_VALUE_CHAIN (sym);
}
}
resolve_objfile = objfile;
}
/* Change the storage class of any remaining unresolved globals to
@ -4593,7 +4611,7 @@ scan_file_globals (objfile)
SYMBOL_CLASS (prev) = LOC_UNRESOLVED;
else
complain (&unresolved_sym_chain_complaint,
objfile->name, SYMBOL_NAME (prev));
objfile -> name, SYMBOL_NAME (prev));
}
}
memset (global_sym_chain, 0, sizeof (global_sym_chain));