]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Merge from mainline:
authorJim Blandy <jimb@codesourcery.com>
Sun, 21 Sep 2003 01:44:39 +0000 (01:44 +0000)
committerJim Blandy <jimb@codesourcery.com>
Sun, 21 Sep 2003 01:44:39 +0000 (01:44 +0000)
2003-09-12  Jim Blandy  <jimb@redhat.com>

* dbxread.c (read_dbx_symtab): Don't report an internal error if
the file has no .data, .bss, or .rodata sections.  Instead wait
until we see a variable alleged to live in one of those sections.

2003-09-12  Jim Blandy  <jimb@redhat.com>

* dbxread.c (read_dbx_symtab): If we have no .data section and no
.bss section, presume that any variables we find live in the
.rodata section.

2003-09-12  Jim Blandy  <jimb@redhat.com>

* dbxread.c (read_dbx_symtab): Add FIXME about finding section
offsets for global and static variables.

2003-09-09  Jim Blandy  <jimb@redhat.com>

* dbxread.c (read_dbx_symtab): The N_DATA and N_DATA | N_EXT
symbol types are, by definition, in the .data section, so it is
correct to use SECT_OFF_DATA (objfile) here, not data_sect_index.
If there is no .data section, there should be no N_DATA or N_DATA
| N_EXT symbols.

2003-07-10  Jim Blandy  <jimb@redhat.com>

* Makefile.in (dbxread.o): Note new dependency on $(gdb_assert_h).
* dbxread.c: #include "gdb_assert.h".
(read_dbx_symtab): If the objfile has no .data section, use the
section index for the .bss section instead.

gdb/ChangeLog
gdb/dbxread.c

index c9ff6775b551f4efdaf6b26c774a6b9a9c7b56a4..5e84f50ca19bef25de3a0588f9cce19d57ec6652 100644 (file)
@@ -1,3 +1,39 @@
+2003-09-19  Jim Blandy  <jimb@redhat.com>
+
+       Merge from mainline:
+       
+       2003-09-12  Jim Blandy  <jimb@redhat.com>
+
+       * dbxread.c (read_dbx_symtab): Don't report an internal error if
+       the file has no .data, .bss, or .rodata sections.  Instead wait
+       until we see a variable alleged to live in one of those sections.
+
+       2003-09-12  Jim Blandy  <jimb@redhat.com>
+
+       * dbxread.c (read_dbx_symtab): If we have no .data section and no
+       .bss section, presume that any variables we find live in the
+       .rodata section.
+
+       2003-09-12  Jim Blandy  <jimb@redhat.com>
+
+       * dbxread.c (read_dbx_symtab): Add FIXME about finding section
+       offsets for global and static variables.
+
+       2003-09-09  Jim Blandy  <jimb@redhat.com>
+
+       * dbxread.c (read_dbx_symtab): The N_DATA and N_DATA | N_EXT
+       symbol types are, by definition, in the .data section, so it is
+       correct to use SECT_OFF_DATA (objfile) here, not data_sect_index.
+       If there is no .data section, there should be no N_DATA or N_DATA
+       | N_EXT symbols.
+
+       2003-07-10  Jim Blandy  <jimb@redhat.com>
+
+       * Makefile.in (dbxread.o): Note new dependency on $(gdb_assert_h).
+       * dbxread.c: #include "gdb_assert.h".
+       (read_dbx_symtab): If the objfile has no .data section, use the
+       section index for the .bss section instead.
+
 2003-09-19  Christopher Faylor  <cgf@redhat.com>
  
        * win32-nat.c (mappings): Remove HAVE_SSE conditional.
index fbfd1a987b6ab73b04e0c400c0d09aa9511d8879..bc243e73981d8496e7c6a5fb788754c1e48089c7 100644 (file)
@@ -58,6 +58,7 @@
 #include "language.h"          /* Needed for local_hex_string */
 #include "complaints.h"
 #include "cp-abi.h"
+#include "gdb_assert.h"
 
 #include "aout/aout64.h"
 #include "aout/stab_gnu.h"     /* We always use GNU stabs, not native, now */
@@ -1304,6 +1305,7 @@ read_dbx_symtab (struct objfile *objfile)
   struct cleanup *back_to;
   bfd *abfd;
   int textlow_not_set;
+  int data_sect_index;
 
   /* Current partial symtab */
   struct partial_symtab *pst;
@@ -1355,6 +1357,38 @@ read_dbx_symtab (struct objfile *objfile)
   textlow_not_set = 1;
   has_line_numbers = 0;
 
+  /* FIXME: jimb/2003-09-12: We don't apply the right section's offset
+     to global and static variables.  The stab for a global or static
+     variable doesn't give us any indication of which section it's in,
+     so we can't tell immediately which offset in
+     objfile->section_offsets we should apply to the variable's
+     address.
+
+     We could certainly find out which section contains the variable
+     by looking up the variable's unrelocated address with
+     find_pc_section, but that would be expensive; this is the
+     function that constructs the partial symbol tables by examining
+     every symbol in the entire executable, and it's
+     performance-critical.  So that expense would not be welcome.  I'm
+     not sure what to do about this at the moment.
+
+     What we have done for years is to simply assume that the .data
+     section's offset is appropriate for all global and static
+     variables.  Recently, this was expanded to fall back to the .bss
+     section's offset if there is no .data section, and then to the
+     .rodata section's offset.  */
+  data_sect_index = objfile->sect_index_data;
+  if (data_sect_index == -1)
+    data_sect_index = SECT_OFF_BSS (objfile);
+  if (data_sect_index == -1)
+    data_sect_index = SECT_OFF_RODATA (objfile);
+
+  /* If data_sect_index is still -1, that's okay.  It's perfectly fine
+     for the file to have no .data, no .bss, and no .text at all, if
+     it also has no global or static variables.  If it does, we will
+     get an internal error from an ANOFFSET macro below when we try to
+     use data_sect_index.  */
+
   for (symnum = 0; symnum < DBX_SYMCOUNT (objfile); symnum++)
     {
       /* Get the symbol for this run and pull out some info */
@@ -1757,7 +1791,7 @@ read_dbx_symtab (struct objfile *objfile)
          switch (p[1])
          {
          case 'S':
-           nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
+           nlist.n_value += ANOFFSET (objfile->section_offsets, data_sect_index);
 #ifdef STATIC_TRANSFORM_NAME
            namestring = STATIC_TRANSFORM_NAME (namestring);
 #endif
@@ -1768,7 +1802,7 @@ read_dbx_symtab (struct objfile *objfile)
                                 psymtab_language, objfile);
            continue;
          case 'G':
-           nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
+           nlist.n_value += ANOFFSET (objfile->section_offsets, data_sect_index);
            /* The addresses in these entries are reported to be
               wrong.  See the code that reads 'G's for symtabs. */
            add_psymbol_to_list (namestring, p - namestring,