symtab/2228: elfread.c:346: internal-error: sect_index_rodata not initialized

stephen.pope@ubs.com stephen.pope@ubs.com
Tue Feb 13 01:08:00 GMT 2007


>Number:         2228
>Category:       symtab
>Synopsis:       elfread.c:346: internal-error: sect_index_rodata not initialized
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 13 01:08:01 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     stephen.pope@ubs.com
>Release:        gdb-6.6
>Organization:
>Environment:
sun-sparc-solaris10
>Description:
When I started linking an application against the Sun Studio11 fortran runtime system, gdb-6.6 started having this problem when reading symbols for the fortran runtime libraries:

elfread.c:346: internal-error: sect_index_rodata not initialized
A problem internal to GDB has been detected,
further debugging may prove unreliable.

I tracked it down to a problem in elf_symtab_read. If an ELF file does not contain all of the TEXT, DATA, RODATA, and BSS sections, the respective sect_index_* fields of the objfile will be -1. The SECT_OFF_*() macros test for this condition and generate an error.

In the case of dealing with a special local section, however, the code which is computing the max index for any section which may occur (for purposes of allocating a large enough structure) is using the SECT_OFF_*() macros when in fact it should simply access the sect_index_* fields, as it simply want to know the largest index, NOT if all indices are valid (it will never end up trying to access an invalid one).

Patch against the gdb-6.6 release version of elfread.c is attached below.
>How-To-Repeat:
% cat > foo.c
int main(int argc, char** argv)
{
   return 0;
}
^D

% gcc -o foo foo.c -L. -R. -L/usr/local/pkg/SunStudio11/SUNWspro/lib -R/usr/local/pkg/SunStudio11/SUNWspro/lib -lnag_nag -lfui -lfsu -lsunmath -lm -lsocket -lnsl

% gdb foo
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.10"...
(no debugging symbols found)
(gdb) run
Starting program: /home/scp/foo 
(no debugging symbols found)
warning: Temporarily disabling breakpoints for unloaded shared library "/usr/lib/ld.so.1"
(no debugging symbols found)
elfread.c:346: internal-error: sect_index_rodata not initialized
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) y
elfread.c:346: internal-error: sect_index_rodata not initialized
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) n

>Fix:
% gdiff -ub elfread.c.orig elfread.c
--- elfread.c.orig      Tue Feb 21 13:38:48 2006
+++ elfread.c   Mon Feb 12 17:22:28 2007
@@ -341,9 +341,9 @@
                          size_t size;
 
                          max_index 
-                           = max (SECT_OFF_BSS (objfile),
-                                  max (SECT_OFF_DATA (objfile),
-                                       SECT_OFF_RODATA (objfile)));
+                            = max (objfile->sect_index_bss,
+                                   max (objfile->sect_index_data,
+                                        objfile->sect_index_rodata));
 
                          /* max_index is the largest index we'll
                             use into this array, so we must
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gdb-prs mailing list