j...@wxcvbn.org (Jeremie Courreges-Anglas) writes: > I bumped into this problem using gdb: > > (gdb) r > Starting program: /usr/obj/pobj/surf-0.7/surf-0.7/surf www.google.fr > symfile.c:973: internal-error: sect_index_text not initialized > A problem internal to GDB has been detected, > further debugging may prove unreliable. > Quit this debugging session? (y or n) n > > The issue is that gdb assumes that it can find an entry point in > a shared library, but libicudata.so doesn't have a .text section, only > data.
To reproduce the issue, here a trivial testcase. Just run ./prog under egdb.
gdb-testcase.tgz
Description: Binary data
> There are other SECT_OFF_TEXT assumptions in dwarf2read.c that > prevent egdb from being useful on a shared lib built with debug symbols. > But the patch below should at least help running egdb against all > programs that link against libicudata.so. Tested against www/surf, > www/vimb and sysutils/dwdiff. > > Comments / ok? > > Index: Makefile > =================================================================== > RCS file: /cvs/ports/devel/gdb/Makefile,v > retrieving revision 1.41 > diff -u -p -r1.41 Makefile > --- Makefile 7 May 2016 12:40:56 -0000 1.41 > +++ Makefile 12 Jun 2016 00:34:26 -0000 > @@ -4,7 +4,7 @@ COMMENT= GNU debugger > CATEGORIES= devel > > DISTNAME= gdb-7.11 > -REVISION= 0 > +REVISION= 1 > > HOMEPAGE= https://www.gnu.org/software/gdb/ > > Index: patches/patch-gdb_symfile_c > =================================================================== > RCS file: patches/patch-gdb_symfile_c > diff -N patches/patch-gdb_symfile_c > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ patches/patch-gdb_symfile_c 12 Jun 2016 00:34:26 -0000 > @@ -0,0 +1,20 @@ > +$OpenBSD$ > + > +Don't crash if a shared lib doesn't have code at all (eg libicudata.so). > + > +--- gdb/symfile.c.orig Wed Feb 10 04:19:39 2016 > ++++ gdb/symfile.c Sun Jun 12 02:33:28 2016 > +@@ -970,7 +970,12 @@ init_entry_point_info (struct objfile *objfile) > + } > + > + if (!found) > +- ei->the_bfd_section_index = SECT_OFF_TEXT (objfile); > ++ { > ++ if (objfile->sect_index_text == -1) > ++ ei->entry_point_p = 0; > ++ else > ++ ei->the_bfd_section_index = objfile->sect_index_text; > ++ } > + } > + } > + -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE