This is the mail archive of the glibc-linux@ricardo.ecn.wfu.edu mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

libstdc++ and glibc 2.1.1


Hi,

I got a problem to get libstdc++.a to work with glibc 2.1.1. In
particular, I can't get binaries that were compiled under Redhat 5.2
to run under Redhat 6.0.

RH 5.2 has libstdc++ 2.8.0 and glibc 2.0.7, RH 6.0 has some weird
version which calls itself libstdc++-2-libc6.1-1-2.9.0.so, and glibc
2.1.1.

It seems that the problem turns out to be the string streams. (I
understand that there is some magic going on under the hood where the
iostreams and libio are talking to each other, but I never figured out
how that thing works. "vtable thunks" is a buzzword that shows up
sometimes, but ...)

The code that it's all about is

#include <strstream.h>
main() {
   char x ;
   istrstream beitl (&x, 1) ;
   char y ;
   beitl.read (&y, 1) ;
}

Find appended the several things I tried. Additionally I tried
installing the "compat" package from Redhat which just seems to
install the glibc 2.0.7, and where you have to explicitly start your
binaries with the 2.0.7 loader. Works, of course, but this is not a
feasible solution for us for some reasons I don't want to explain
here.

I also read the FAQ 2.21, where HJ and AJ suggest to use libstdc++ as
of egcs 1.1, which I tried (egcs 1.1.2, see below), and where UD
states that everything is fine when you use a shared libstdc++ (which
isn't, see below).

I'd be glad to receive any input on this, positive or negative or
explanatory (although I prefer positive, maybe combined with
explanatory :-).

Thanks in advance,
Joerg

(Kernel is 2.2.6, btw.)

===============================================================
#1: egcs 1.0.3 + shared libstdc++ 2.8.0 as it comes with RH 5.2
===============================================================

---------------------------------------------------------------
~/tmp>g++ -v -g c.C
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.29/specs
gcc version egcs-2.90.29 980515 (egcs-1.0.3 release)
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.29/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=90 -Di386 -D__ELF__ -Dunix -Dlinux -D__i386__ -D__ELF__ -D__unix__ -D__linux__ -D__i386 -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -g -Di386 -Asystem(unix) -Acpu(i386) -Amachine(i386) -D__i386__ -Asystem(unix) -Acpu(i386) -Amachine(i386) c.C /tmp/cca23195.ii
GNU CPP version egcs-2.90.29 980515 (egcs-1.0.3 release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++
 /usr/local/include
 /usr/i386-redhat-linux/include
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.29/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.29/cc1plus /tmp/cca23195.ii -quiet -dumpbase c.cc -g -version -o /tmp/cca23195.s
GNU C++ version egcs-2.90.29 980515 (egcs-1.0.3 release) (i386-redhat-linux) compiled by GNU C version egcs-2.90.29 980515 (egcs-1.0.3 release).
 as -V -Qy -o /tmp/cca231951.o /tmp/cca23195.s
GNU assembler version 2.9.1 (i686-pc-linux-gnu), using BFD version 2.9.1.0.15
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.29/ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.29/crtbegin.o -L/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.29 -L/usr/i386-redhat-linux/lib /tmp/cca231951.o -lstdc++ -lm -lgcc -lc -lgcc /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.29/crtend.o /usr/lib/crtn.o

---------------------------------------------------------------
~/tmp>ldd a.out
        libstdc++.so.2.8 => /usr/lib/libstdc++.so.2.8 (0x40004000)
        libm.so.6 => /lib/libm.so.6 (0x40045000)
        libc.so.6 => /lib/libc.so.6 (0x4005e000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x2aaaa000)

---------------------------------------------------------------
Execute under RH 6.0, I get a segfault, btw with no stacktrace (?):

(gdb) bt
#0  0xbffff3bd in ?? ()
#1  0x744003ca in ?? ()

~/tmp>ldd a.out
        /lib/libNoVersion.so.1 => /lib/libNoVersion.so.1 (0x40014000)
        libstdc++.so.2.8 => /usr/lib/libstdc++.so.2.8 (0x4001a000)
        libm.so.6 => /lib/libm.so.6 (0x4005b000)
        libc.so.6 => /lib/libc.so.6 (0x40077000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

---------------------------------------------------------------
Remark: one of our binaries that was made under RH 5.2 got me a trace
as follows

(gdb) bt
#0  0x400de7e1 in _IO_sgetn (fp=0x821c8f4, data=0xbfffdddb, n=1)
    at genops.c:431
#1  0x4004da6d in istream::read ()
#2  0x815a614 in HWIVBinaryRpcIRequest::read (this=0x821c840, 
    s=0xbfffde34 "\002c\e\b\031(\030\b¨8!\b\034")
    at /usr2/hyperg-rel/RELEASE_5_01/src/common/Dispatch/hwivrpcrequest.C:356

Where the this pointer at frame #1 was complete nonsense. The istream
in frame #1 is an istrstream, actually.

===============================================================
#2: egcs 1.1.2 (handmade) under RH 5.2, with static libstdc++
===============================================================

---------------------------------------------------------------
~/tmp>/usr/local/egcs-1.1.2/bin/g++ -v -g c.C
Reading specs from /usr/local/egcs-1.1.2/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
 /usr/local/egcs-1.1.2/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -D__ELF__ -Dunix -Di386 -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__i386__ -D__linux__ -D__unix -D__i386 -D__linux -Asystem(posix) -D__EXCEPTIONS -g -Asystem(unix) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ c.C /tmp/ccnB9R1o.ii
GNU CPP version egcs-2.91.66 19990314 (egcs-1.1.2 release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/egcs-1.1.2/include/g++
 /usr/local/include
 /usr/local/egcs-1.1.2/i686-pc-linux-gnu/include
 /usr/local/egcs-1.1.2/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/include
 /usr/include
End of search list.
 /usr/local/egcs-1.1.2/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/cc1plus /tmp/ccnB9R1o.ii -quiet -dumpbase c.cc -g -version -o /tmp/ccgItNFE.s
GNU C++ version egcs-2.91.66 19990314 (egcs-1.1.2 release) (i686-pc-linux-gnu) compiled by GNU C version egcs-2.91.66 19990314 (egcs-1.1.2 release).
 as -V -Qy -o /tmp/cc9u9KW9.o /tmp/ccgItNFE.s
GNU assembler version 2.9.1 (i686-pc-linux-gnu), using BFD version 2.9.1.0.15
 /usr/local/egcs-1.1.2/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o /usr/local/egcs-1.1.2/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/crtbegin.o -L/usr/local/egcs-1.1.2/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66 -L/usr/local/egcs-1.1.2/i686-pc-linux-gnu/lib -L/usr/local/egcs-1.1.2/lib /tmp/cc9u9KW9.o -lstdc++ -lm -lgcc -lc -lgcc /usr/local/egcs-1.1.2/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/crtend.o /usr/lib/crtn.o

---------------------------------------------------------------
ldd a.out
        libm.so.6 => /lib/libm.so.6 (0x40004000)
        libc.so.6 => /lib/libc.so.6 (0x4001d000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x2aaaa000)

---------------------------------------------------------------
execute under RH 6.0, again segfault, again with no trace.

(gdb) bt
#0  0xbffff3bd in ?? ()
#1  0x740804a6 in ?? ()

~/tmp>ldd a.out
        /lib/libNoVersion.so.1 => /lib/libNoVersion.so.1 (0x40014000)
        libm.so.6 => /lib/libm.so.6 (0x4001a000)
        libc.so.6 => /lib/libc.so.6 (0x40036000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

===============================================================
#3: egcs 1.1.2 (handmade) under RH 5.2, shared libstdc++ (configure --enable-shared)
===============================================================

(as UD suggests in FAQ 2.21)

Failed loading under RH 6.0 because there I got no libstdc++ 2.9. If I
copy libstdc++.so.2.9 (as I would when I distribute it with our
binaries) and use LD_PRELOAD (is this the right way?), then ldd, ls
and all others segfault immediately.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]