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);
}
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.
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);
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
{
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 ();
}
/* 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)
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;
switch (sh.sc)
{
case scUndefined:
+ case scSUndefined:
case scNil:
case scAbs:
break;
}
/* 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)))
{
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)
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:
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++)
- {
- if (global_sym_chain[hash])
- break;
- }
- if (hash >= HASHSIZE)
- return;
+ /* 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. */
- for (msymbol = objfile -> msymbols;
- msymbol && SYMBOL_NAME (msymbol) != NULL;
- msymbol++)
- {
- QUIT;
+ if (symfile_objfile && objfile != symfile_objfile)
+ resolve_objfile = symfile_objfile;
+ else
+ resolve_objfile = objfile;
- /* Skip static symbols. */
- switch (MSYMBOL_TYPE (msymbol))
+ while (1)
+ {
+ /* Avoid expensive loop through all minimal symbols if there are
+ no unresolved symbols. */
+ for (hash = 0; hash < HASHSIZE; hash++)
{
- case mst_file_text:
- case mst_file_data:
- case mst_file_bss:
- continue;
- default:
- break;
+ if (global_sym_chain[hash])
+ break;
}
+ if (hash >= HASHSIZE)
+ return;
- prev = NULL;
+ for (msymbol = resolve_objfile -> msymbols;
+ msymbol && SYMBOL_NAME (msymbol) != NULL;
+ msymbol++)
+ {
+ QUIT;
- /* Get the hash index and check all the symbols
- under that hash index. */
+ /* Skip static symbols. */
+ switch (MSYMBOL_TYPE (msymbol))
+ {
+ case mst_file_text:
+ case mst_file_data:
+ case mst_file_bss:
+ continue;
+ default:
+ break;
+ }
- hash = hashname (SYMBOL_NAME (msymbol));
+ prev = NULL;
- 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))
+ /* 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;)
{
- /* 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
+ if (SYMBOL_NAME (msymbol)[0] == SYMBOL_NAME (sym)[0] &&
+ STREQ(SYMBOL_NAME (msymbol) + 1, SYMBOL_NAME (sym) + 1))
{
- 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. */
+ /* 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);
- }
+ 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);
+ SYMBOL_SECTION (sym) = SYMBOL_SECTION (msymbol);
+
+ if (prev)
+ {
+ sym = SYMBOL_VALUE_CHAIN (prev);
+ }
+ else
+ {
+ sym = global_sym_chain[hash];
+ }
}
else
{
- sym = global_sym_chain[hash];
+ prev = sym;
+ sym = SYMBOL_VALUE_CHAIN (sym);
}
}
- else
- {
- prev = sym;
- sym = SYMBOL_VALUE_CHAIN (sym);
- }
}
+ if (resolve_objfile == objfile)
+ break;
+ resolve_objfile = objfile;
}
/* Change the storage class of any remaining unresolved globals to
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));