mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-21 10:34:21 +08:00
* dbxread.c (read_dbx_dynamic_symtab): Adjust for recent changes
to BFD handling of dynamic symbols.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
Thu Apr 7 15:11:11 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
|
||||||
|
|
||||||
|
* dbxread.c (read_dbx_dynamic_symtab): Adjust for recent changes
|
||||||
|
to BFD handling of dynamic symbols.
|
||||||
|
|
||||||
Tue Apr 5 15:29:25 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
|
Tue Apr 5 15:29:25 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
|
||||||
|
|
||||||
* hppa-tdep.c (hppa_fix_call_dummy): If FUN is a procedure label,
|
* hppa-tdep.c (hppa_fix_call_dummy): If FUN is a procedure label,
|
||||||
|
179
gdb/dbxread.c
179
gdb/dbxread.c
@ -843,18 +843,17 @@ read_dbx_dynamic_symtab (section_offsets, objfile)
|
|||||||
struct objfile *objfile;
|
struct objfile *objfile;
|
||||||
{
|
{
|
||||||
bfd *abfd = objfile->obfd;
|
bfd *abfd = objfile->obfd;
|
||||||
|
struct cleanup *back_to;
|
||||||
int counter;
|
int counter;
|
||||||
bfd_size_type dynsym_count = 0;
|
long dynsym_size;
|
||||||
struct external_nlist *dynsyms = NULL;
|
long dynsym_count;
|
||||||
char *dynstrs = NULL;
|
asymbol **dynsyms;
|
||||||
bfd_size_type dynstr_size;
|
asymbol **symptr;
|
||||||
struct external_nlist *ext_symptr;
|
arelent **relptr;
|
||||||
bfd_byte *ext_relptr;
|
long dynrel_size;
|
||||||
bfd_size_type dynrel_count = 0;
|
long dynrel_count;
|
||||||
PTR dynrels = NULL;
|
arelent **dynrels;
|
||||||
CORE_ADDR sym_value;
|
CORE_ADDR sym_value;
|
||||||
bfd_vma strx;
|
|
||||||
char *namestring;
|
|
||||||
|
|
||||||
/* Check that the symbol file has dynamic symbols that we know about.
|
/* Check that the symbol file has dynamic symbols that we know about.
|
||||||
bfd_arch_unknown can happen if we are reading a sun3 symbol file
|
bfd_arch_unknown can happen if we are reading a sun3 symbol file
|
||||||
@ -863,56 +862,61 @@ read_dbx_dynamic_symtab (section_offsets, objfile)
|
|||||||
so we ignore the dynamic symbols in this case. */
|
so we ignore the dynamic symbols in this case. */
|
||||||
if (bfd_get_flavour (abfd) != bfd_target_aout_flavour
|
if (bfd_get_flavour (abfd) != bfd_target_aout_flavour
|
||||||
|| (bfd_get_file_flags (abfd) & DYNAMIC) == 0
|
|| (bfd_get_file_flags (abfd) & DYNAMIC) == 0
|
||||||
|| bfd_get_arch (abfd) == bfd_arch_unknown
|
|| bfd_get_arch (abfd) == bfd_arch_unknown)
|
||||||
|| aout_backend_info (abfd)->read_dynamic_symbols == NULL)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dynsym_count = ((*aout_backend_info (abfd)->read_dynamic_symbols)
|
dynsym_size = bfd_get_dynamic_symtab_upper_bound (abfd);
|
||||||
(abfd, &dynsyms, &dynstrs, &dynstr_size));
|
if (dynsym_size < 0)
|
||||||
if (dynsym_count == (bfd_size_type) -1)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
dynsyms = (asymbol **) xmalloc (dynsym_size);
|
||||||
|
back_to = make_cleanup (free, dynsyms);
|
||||||
|
|
||||||
|
dynsym_count = bfd_canonicalize_dynamic_symtab (abfd, dynsyms);
|
||||||
|
if (dynsym_count < 0)
|
||||||
|
{
|
||||||
|
do_cleanups (back_to);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Enter dynamic symbols into the minimal symbol table
|
/* Enter dynamic symbols into the minimal symbol table
|
||||||
if this is a stripped executable. */
|
if this is a stripped executable. */
|
||||||
if (bfd_get_symcount (abfd) <= 0)
|
if (bfd_get_symcount (abfd) <= 0)
|
||||||
{
|
{
|
||||||
ext_symptr = dynsyms;
|
symptr = dynsyms;
|
||||||
for (counter = 0; counter < dynsym_count; counter++, ext_symptr++)
|
for (counter = 0; counter < dynsym_count; counter++, symptr++)
|
||||||
{
|
{
|
||||||
int type = bfd_h_get_8 (abfd, ext_symptr->e_type);
|
asymbol *sym = *symptr;
|
||||||
|
asection *sec;
|
||||||
|
int type;
|
||||||
|
|
||||||
switch (type)
|
sym = *symptr;
|
||||||
|
sym_value = sym->value;
|
||||||
|
|
||||||
|
sec = bfd_get_section (sym);
|
||||||
|
if (bfd_get_section_flags (abfd, sec) & SEC_CODE)
|
||||||
{
|
{
|
||||||
case N_TEXT | N_EXT:
|
sym_value += ANOFFSET (section_offsets, SECT_OFF_TEXT);
|
||||||
sym_value = bfd_h_get_32 (abfd, ext_symptr->e_value)
|
type = N_TEXT;
|
||||||
+ ANOFFSET (section_offsets, SECT_OFF_TEXT);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case N_DATA:
|
|
||||||
case N_DATA | N_EXT:
|
|
||||||
sym_value = bfd_h_get_32 (abfd, ext_symptr->e_value)
|
|
||||||
+ ANOFFSET (section_offsets, SECT_OFF_DATA);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case N_BSS:
|
|
||||||
case N_BSS | N_EXT:
|
|
||||||
sym_value = bfd_h_get_32 (abfd, ext_symptr->e_value)
|
|
||||||
+ ANOFFSET (section_offsets, SECT_OFF_BSS);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
else if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
|
||||||
strx = bfd_h_get_32 (abfd, ext_symptr->e_strx);
|
|
||||||
if (strx >= dynstr_size)
|
|
||||||
{
|
{
|
||||||
complain (&string_table_offset_complaint, counter);
|
sym_value += ANOFFSET (section_offsets, SECT_OFF_DATA);
|
||||||
namestring = "<bad dynamic string table offset>";
|
type = N_DATA;
|
||||||
|
}
|
||||||
|
else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
|
||||||
|
{
|
||||||
|
sym_value += ANOFFSET (section_offsets, SECT_OFF_BSS);
|
||||||
|
type = N_BSS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
namestring = strx + dynstrs;
|
continue;
|
||||||
record_minimal_symbol (namestring, sym_value, type, objfile);
|
|
||||||
|
if (sym->flags & BSF_GLOBAL)
|
||||||
|
type |= N_EXT;
|
||||||
|
|
||||||
|
record_minimal_symbol (bfd_asymbol_name (sym), sym_value,
|
||||||
|
type, objfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -920,81 +924,42 @@ read_dbx_dynamic_symtab (section_offsets, objfile)
|
|||||||
that points to the associated slot in the procedure linkage table.
|
that points to the associated slot in the procedure linkage table.
|
||||||
We make a mininal symbol table entry with type mst_solib_trampoline
|
We make a mininal symbol table entry with type mst_solib_trampoline
|
||||||
at the address in the procedure linkage table. */
|
at the address in the procedure linkage table. */
|
||||||
if (aout_backend_info (abfd)->read_dynamic_relocs == NULL)
|
dynrel_size = bfd_get_dynamic_reloc_upper_bound (abfd);
|
||||||
|
if (dynrel_size < 0)
|
||||||
|
{
|
||||||
|
do_cleanups (back_to);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dynrel_count = ((*aout_backend_info (abfd)->read_dynamic_relocs)
|
dynrels = (arelent **) xmalloc (dynrel_size);
|
||||||
(abfd, &dynrels));
|
make_cleanup (free, dynrels);
|
||||||
if (dynrel_count == (bfd_size_type) -1)
|
|
||||||
|
dynrel_count = bfd_canonicalize_dynamic_reloc (abfd, dynrels, dynsyms);
|
||||||
|
if (dynrel_count < 0)
|
||||||
|
{
|
||||||
|
do_cleanups (back_to);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (counter = 0, ext_relptr = (bfd_byte *) dynrels;
|
for (counter = 0, relptr = dynrels;
|
||||||
counter < dynrel_count;
|
counter < dynrel_count;
|
||||||
counter++, ext_relptr += obj_reloc_entry_size (abfd))
|
counter++, relptr++)
|
||||||
{
|
{
|
||||||
int r_index;
|
arelent *rel;
|
||||||
|
|
||||||
if (bfd_get_arch (abfd) == bfd_arch_sparc)
|
/* FIXME: This probably doesn't work on a Sun3. */
|
||||||
{
|
|
||||||
struct reloc_ext_external *rptr =
|
|
||||||
(struct reloc_ext_external *) ext_relptr;
|
|
||||||
int r_type;
|
|
||||||
|
|
||||||
r_type = (rptr->r_type[0] & RELOC_EXT_BITS_TYPE_BIG)
|
rel = *relptr;
|
||||||
>> RELOC_EXT_BITS_TYPE_SH_BIG;
|
if (rel->howto->type != RELOC_JMP_SLOT)
|
||||||
|
|
||||||
if (r_type != RELOC_JMP_SLOT)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
r_index = (rptr->r_index[0] << 16)
|
prim_record_minimal_symbol (bfd_asymbol_name (*rel->sym_ptr_ptr),
|
||||||
| (rptr->r_index[1] << 8)
|
rel->address,
|
||||||
| rptr->r_index[2];
|
|
||||||
|
|
||||||
sym_value = bfd_h_get_32 (abfd, rptr->r_address);
|
|
||||||
}
|
|
||||||
else if (bfd_get_arch (abfd) == bfd_arch_m68k)
|
|
||||||
{
|
|
||||||
struct reloc_std_external *rptr =
|
|
||||||
(struct reloc_std_external *) ext_relptr;
|
|
||||||
|
|
||||||
if ((rptr->r_type[0] & RELOC_STD_BITS_JMPTABLE_BIG) == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
r_index = (rptr->r_index[0] << 16)
|
|
||||||
| (rptr->r_index[1] << 8)
|
|
||||||
| rptr->r_index[2];
|
|
||||||
|
|
||||||
/* Adjust address in procedure linkage table to point to
|
|
||||||
the start of the bsr instruction. */
|
|
||||||
sym_value = bfd_h_get_32 (abfd, rptr->r_address) - 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r_index >= dynsym_count)
|
|
||||||
continue;
|
|
||||||
ext_symptr = dynsyms + r_index;
|
|
||||||
if (bfd_h_get_8 (abfd, ext_symptr->e_type) != N_EXT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
strx = bfd_h_get_32 (abfd, ext_symptr->e_strx);
|
|
||||||
if (strx >= dynstr_size)
|
|
||||||
{
|
|
||||||
complain (&string_table_offset_complaint, r_index);
|
|
||||||
namestring = "<bad dynamic string table offset>";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
namestring = strx + dynstrs;
|
|
||||||
|
|
||||||
prim_record_minimal_symbol (obsavestring (namestring,
|
|
||||||
strlen (namestring),
|
|
||||||
&objfile -> symbol_obstack),
|
|
||||||
sym_value,
|
|
||||||
mst_solib_trampoline,
|
mst_solib_trampoline,
|
||||||
objfile);
|
objfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_cleanups (back_to);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Given pointers to an a.out symbol table in core containing dbx
|
/* Given pointers to an a.out symbol table in core containing dbx
|
||||||
|
Reference in New Issue
Block a user