aboutsummaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>2002-05-12 18:13:33 +0000
committerFred Fish <fnf@specifix.com>2002-05-12 18:13:33 +0000
commitbbcd32adda2a0f5690371ac8002da2e3fc598656 (patch)
treeb9ba0ce68212ec3cd4dda3d99f1c0c6e1da909fa /gdb/symfile.c
parent1aee598a775ab7ae1e334b3c0f8dff8ee6a5aca5 (diff)
downloadgdb-bbcd32adda2a0f5690371ac8002da2e3fc598656.zip
gdb-bbcd32adda2a0f5690371ac8002da2e3fc598656.tar.gz
gdb-bbcd32adda2a0f5690371ac8002da2e3fc598656.tar.bz2
Approved by ezannoni@redhat.com:
2002-05-12 Fred Fish <fnf@redhat.com> * symfile.c (default_symfile_offsets): Arrange for uninitialized sect_index_xxx members to index the first slot in section_offsets if all of the section_offsets are zero.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 7c7141d..8303f3c 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -539,6 +539,34 @@ default_symfile_offsets (struct objfile *objfile,
if (sect)
objfile->sect_index_rodata = sect->index;
+ /* This is where things get really weird... We MUST have valid
+ indices for the various sect_index_* members or gdb will abort.
+ So if for example, there is no ".text" section, we have to
+ accomodate that. Except when explicitly adding symbol files at
+ some address, section_offsets contains nothing but zeros, so it
+ doesn't matter which slot in section_offsets the individual
+ sect_index_* members index into. So if they are all zero, it is
+ safe to just point all the currently uninitialized indices to the
+ first slot. */
+
+ for (i = 0; i < objfile->num_sections; i++)
+ {
+ if (ANOFFSET (objfile->section_offsets, i) != 0)
+ {
+ break;
+ }
+ }
+ if (i == objfile->num_sections)
+ {
+ if (objfile->sect_index_text == -1)
+ objfile->sect_index_text = 0;
+ if (objfile->sect_index_data == -1)
+ objfile->sect_index_data = 0;
+ if (objfile->sect_index_bss == -1)
+ objfile->sect_index_bss = 0;
+ if (objfile->sect_index_rodata == -1)
+ objfile->sect_index_rodata = 0;
+ }
}
/* Process a symbol file, as either the main file or as a dynamically