Browse Source

Fix code in elf_symtab_read which attempts to read the standard ELF

symbol table and add symbol information to the misc function vector.
This allows minimum functionality with non -g compiled code, and is
vital for use with shared libraries (non of which are currently
compiled with -g).

Note to anyone doing any SVR4/gdb work.  This bug was introduced into
gdb just prior to the gdb 4.4 release, thus any versions currently
in the field will have broken shared library support since no symbol
information at all will be available for the shared library.  This
fix, along with one about to go into bfd's elf.c should fix that
problem.
gdb-4_18-branch
Fred Fish 35 years ago
parent
commit
d35bf52d93
  1. 5
      gdb/ChangeLog
  2. 19
      gdb/elfread.c

5
gdb/ChangeLog

@ -1,3 +1,8 @@
Thu Feb 13 17:14:28 1992 Fred Fish (fnf at cygnus.com)
* elfread.c (elf_symtab_read): Fix code to correctly track
changes in bfd for absolute symbols.
Thu Feb 13 12:43:29 1992 Stu Grossman (grossman at cygnus.com) Thu Feb 13 12:43:29 1992 Stu Grossman (grossman at cygnus.com)
* xm-vaxbsd.h: Close off comment. * xm-vaxbsd.h: Close off comment.

19
gdb/elfread.c

@ -195,25 +195,28 @@ DEFUN (elf_symtab_read, (abfd, addr, mainline),
for (i = 0; i < number_of_symbols; i++) for (i = 0; i < number_of_symbols; i++)
{ {
sym = *symbol_table++; sym = *symbol_table++;
/* Select global symbols that are defined in a specific section /* Select global/weak symbols that are defined in a specific section.
or are absolute. */ Note that bfd now puts abs symbols in their own section, so
if (sym -> flags & BSF_GLOBAL all symbols we are interested in will have a section. */
&& (sym -> section == &bfd_abs_section)) if ((sym -> flags & (BSF_GLOBAL | BSF_WEAK))
&& (sym -> section != NULL))
{ {
symaddr = sym -> value; symaddr = sym -> value;
if (!mainline) /* Relocate all non-absolute symbols by base address.
FIXME: Can we eliminate the check for mainline now,
since shouldn't addr be 0 in this case? */
if (!mainline && (sym -> section != &bfd_abs_section))
{ {
/* Relocate all symbols by base address */
symaddr += addr; symaddr += addr;
} }
/* For non-absolute symbols, use the type of the section /* For non-absolute symbols, use the type of the section
they are relative to, to intuit text/data. Bfd provides they are relative to, to intuit text/data. Bfd provides
no way of figuring this out for absolute symbols. */ no way of figuring this out for absolute symbols. */
if (sym -> section && (sym -> section -> flags & SEC_CODE)) if (sym -> section -> flags & SEC_CODE)
{ {
mf_type = mf_text; mf_type = mf_text;
} }
else if (sym -> section && (sym -> section -> flags & SEC_DATA)) else if (sym -> section -> flags & SEC_DATA)
{ {
mf_type = mf_data; mf_type = mf_data;
} }

Loading…
Cancel
Save