summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorElena Zannoni <ezannoni@kwikemart.cygnus.com>2000-08-07 15:16:15 +0000
committerElena Zannoni <ezannoni@kwikemart.cygnus.com>2000-08-07 15:16:15 +0000
commit90de6394c32139cb88650b15d0570d54e1246e96 (patch)
treeca4954ec8dd44a04e7ffe35e723cd7d1aa64f558 /gdb
parent62504dc330152a23dd4a49e063faea3605008c28 (diff)
downloadgdb-90de6394c32139cb88650b15d0570d54e1246e96.tar.gz
2000-08-07 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* objfiles.h (SECT_OFF_BSS): Don't detect invalid sect_index_bss here, let the users of the macro do it. * symtab.h (ANOFFSET): Detect here if the section index is not initialized. * xcoffread.c (find_targ_sec): Don't treat .bss as special, because some objfiles may not have that section at all. * coffread.c (cs_to_section): Ditto. * elfread.c (elf_symtab_read): Detect an uninitialized index value. (elfstab_offset_sections): The macro ANOFFSET cannot be used as an lvalue anymore. * remote.c (get_offsets, remote_cisco_objfile_relocate): Don't use ANOFFSET as an lvalue. * objfiles.c (objfile_relocate, objfile_relocate): Don't use ANOFFSET as an lvalue. * symfile.c (default_symfile_offsets): Don't use ANOFFSET as an lvalue.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog20
-rw-r--r--gdb/coffread.c3
-rw-r--r--gdb/elfread.c20
-rw-r--r--gdb/objfiles.c4
-rw-r--r--gdb/objfiles.h7
-rw-r--r--gdb/remote.c12
-rw-r--r--gdb/symfile.c2
-rw-r--r--gdb/symtab.h4
-rw-r--r--gdb/xcoffread.c2
9 files changed, 53 insertions, 21 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6c687cb83d4..4bafc70828c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,23 @@
+2000-08-07 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * objfiles.h (SECT_OFF_BSS): Don't detect invalid sect_index_bss
+ here, let the users of the macro do it.
+ * symtab.h (ANOFFSET): Detect here if the section index is not
+ initialized.
+ * xcoffread.c (find_targ_sec): Don't treat .bss as special,
+ because some objfiles may not have that section at all.
+ * coffread.c (cs_to_section): Ditto.
+ * elfread.c (elf_symtab_read): Detect an uninitialized index
+ value.
+ (elfstab_offset_sections): The macro ANOFFSET cannot be used as an
+ lvalue anymore.
+ * remote.c (get_offsets, remote_cisco_objfile_relocate): Don't use
+ ANOFFSET as an lvalue.
+ * objfiles.c (objfile_relocate, objfile_relocate): Don't use
+ ANOFFSET as an lvalue.
+ * symfile.c (default_symfile_offsets): Don't use ANOFFSET as an
+ lvalue.
+
Mon Aug 7 10:24:30 2000 David Taylor <taylor@texas.cygnus.com>
* parse.c (build_parse): don't write off the end of the std_regs
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 75f6fc5011e..f35609d0a8a 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -347,7 +347,8 @@ cs_to_section (struct coff_symbol *cs, struct objfile *objfile)
else if (bfd_get_section_flags (abfd, sect) & SEC_LOAD)
off = SECT_OFF_DATA (objfile);
else
- off = SECT_OFF_BSS (objfile);
+ /* Just return the bfd section index. */
+ off = sect->index;
}
return off;
}
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 3de6b5eb23b..b964552ea00 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -474,11 +474,16 @@ elf_symtab_read (struct objfile *objfile, int dynamic)
(char *) filesym->name;
}
}
- if (sectinfo->sections[index] != 0)
- {
- complain (&section_info_dup_complaint,
- sectinfo->filename);
+ if (index != -1)
+ {
+ if (sectinfo->sections[index] != 0)
+ {
+ complain (&section_info_dup_complaint,
+ sectinfo->filename);
+ }
}
+ else
+ internal_error ("Section index uninitialized.");
/* Bfd symbols are section relative. */
symaddr = sym->value + sym->section->vma;
/* Relocate non-absolute symbols by the section offset. */
@@ -486,7 +491,10 @@ elf_symtab_read (struct objfile *objfile, int dynamic)
{
symaddr += offset;
}
- sectinfo->sections[index] = symaddr;
+ if (index != -1)
+ sectinfo->sections[index] = symaddr;
+ else
+ internal_error ("Section index uninitialized.");
/* The special local symbols don't go in the
minimal symbol table, so ignore this one. */
continue;
@@ -790,7 +798,7 @@ elfstab_offset_sections (struct objfile *objfile, struct partial_symtab *pst)
pst->section_offsets = (struct section_offsets *)
obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS);
for (i = 0; i < SECT_OFF_MAX; i++)
- ANOFFSET (pst->section_offsets, i) = maybe->sections[i];
+ (pst->section_offsets)->offsets[i] = maybe->sections[i];
return;
}
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index f5b1119acf7..e0228f55c99 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -520,7 +520,7 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets)
int something_changed = 0;
for (i = 0; i < objfile->num_sections; ++i)
{
- ANOFFSET (delta, i) =
+ delta->offsets[i] =
ANOFFSET (new_offsets, i) - ANOFFSET (objfile->section_offsets, i);
if (ANOFFSET (delta, i) != 0)
something_changed = 1;
@@ -639,7 +639,7 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets)
{
int i;
for (i = 0; i < objfile->num_sections; ++i)
- ANOFFSET (objfile->section_offsets, i) = ANOFFSET (new_offsets, i);
+ (objfile->section_offsets)->offsets[i] = ANOFFSET (new_offsets, i);
}
{
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 86b77a5b303..90a17403df2 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -597,8 +597,9 @@ extern int is_in_import_list (char *, struct objfile *);
((objfile->sect_index_text == -1) ? \
(internal_error ("sect_index_text not initialized"), -1) : objfile->sect_index_text)
-#define SECT_OFF_BSS(objfile) \
- ((objfile->sect_index_bss == -1) ? \
- (internal_error ("sect_index_bss not initialized"), -1) : objfile->sect_index_bss)
+/* Sometimes the .bss section is missing from the objfile, so we don't
+ want to die here. Let the users of SECT_OFF_BSS deal with an
+ uninitialized section index. */
+#define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss
#endif /* !defined (OBJFILES_H) */
diff --git a/gdb/remote.c b/gdb/remote.c
index 8c3d694565c..9fe2a29ed10 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1835,14 +1835,14 @@ get_offsets (void)
offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS);
memcpy (offs, symfile_objfile->section_offsets, SIZEOF_SECTION_OFFSETS);
- ANOFFSET (offs, SECT_OFF_TEXT (symfile_objfile)) = text_addr;
+ offs->offsets[SECT_OFF_TEXT (symfile_objfile)] = text_addr;
/* This is a temporary kludge to force data and bss to use the same offsets
because that's what nlmconv does now. The real solution requires changes
to the stub and remote.c that I don't have time to do right now. */
- ANOFFSET (offs, SECT_OFF_DATA (symfile_objfile)) = data_addr;
- ANOFFSET (offs, SECT_OFF_BSS (symfile_objfile)) = data_addr;
+ offs->offsets[SECT_OFF_DATA (symfile_objfile)] = data_addr;
+ offs->offsets[SECT_OFF_BSS (symfile_objfile)] = data_addr;
objfile_relocate (symfile_objfile, offs);
}
@@ -1948,9 +1948,9 @@ remote_cisco_objfile_relocate (bfd_signed_vma text_off, bfd_signed_vma data_off,
offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS);
memcpy (offs, symfile_objfile->section_offsets, SIZEOF_SECTION_OFFSETS);
- ANOFFSET (offs, SECT_OFF_TEXT (symfile_objfile)) = text_off;
- ANOFFSET (offs, SECT_OFF_DATA (symfile_objfile)) = data_off;
- ANOFFSET (offs, SECT_OFF_BSS (symfile_objfile)) = bss_off;
+ offs->offsets[SECT_OFF_TEXT (symfile_objfile)] = text_off;
+ offs->offsets[SECT_OFF_DATA (symfile_objfile)] = data_off;
+ offs->offsets[SECT_OFF_BSS (symfile_objfile)] = bss_off;
/* First call the standard objfile_relocate. */
objfile_relocate (symfile_objfile, offs);
diff --git a/gdb/symfile.c b/gdb/symfile.c
index e28158ae021..a353c5fef52 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -521,7 +521,7 @@ default_symfile_offsets (struct objfile *objfile,
/* Record all sections in offsets */
/* The section_offsets in the objfile are here filled in using
the BFD index. */
- ANOFFSET (objfile->section_offsets, osp->sectindex) = osp->addr;
+ (objfile->section_offsets)->offsets[osp->sectindex] = osp->addr;
}
/* Remember the bfd indexes for the .text, .data, .bss and
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 101759f22de..55db0f82a9d 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -829,7 +829,9 @@ struct section_offsets
CORE_ADDR offsets[1]; /* As many as needed. */
};
-#define ANOFFSET(secoff, whichone) (secoff->offsets[whichone])
+#define ANOFFSET(secoff, whichone) \
+ ((whichone == -1) ? \
+ (internal_error ("Section index is uninitialized"), -1) : secoff->offsets[whichone])
/* The maximum possible size of a section_offsets table. */
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 53e546958f8..47d44a52616 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -274,7 +274,7 @@ find_targ_sec (bfd *abfd, asection *sect, PTR obj)
else if (bfd_get_section_flags (abfd, sect) & SEC_LOAD)
*args->resultp = SECT_OFF_DATA (objfile);
else
- *args->resultp = SECT_OFF_BSS (objfile);
+ *args->resultp = sect->index;
*args->bfd_sect = sect;
}
}