NNTP-Posting-Date: Mon, 11 Nov 2002 06:54:23 -0600 From: Charles Wilkins Newsgroups: comp.os.msdos.djgpp Subject: Re: i686-pc-msdosdjgpp-g++ problems (long) Date: Mon, 11 Nov 2002 07:56:20 -0500 Message-ID: <6g7vsu05b8d02ebonniuaqolche7npbe7m@4ax.com> References: <85ctsu00ta2hiln51cm74ug0589tk0rp86 AT 4ax DOT com> X-Newsreader: Forte Agent 1.92/32.570 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 203 NNTP-Posting-Host: 68.45.75.113 X-Trace: sv3-2G0DXKZrfdVWfyxGGWfCrXWGIbw7j6rL6xPyhY0AlfimVBtZuUfKDCj6Y5HpDkV2kLPOFSzqn5r70a8!kOFLU7N5Wzw2aHtE1K8BkphSsGfd2Tz9LkDh5U3oBBDjKoVcdSUTUzOcyashODouWlExFEs= X-Complaints-To: abuse AT comcast DOT com X-DMCA-Complaints-To: dmca AT comcast DOT net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com >No, no, no, this is wrong. You should set the breakpoint _before_ >running the program, not after. That is, type "br *0x0001e1df" right >after GDB prints its startup blurb, and _then_ type "run". Ok, here are the results doing it this way. C:\Archives\RIP2\DJGPP\bin>gdb wel-g GNU gdb 5.2.1 Copyright 2002 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 "i386-pc-msdosdjgpp"... (gdb) br *0x0001e1df Breakpoint 1 at 0x1e1df (gdb) run Starting program: c:/Archives/RIP2/DJGPP/bin/wel-g.exe Breakpoint 1, 0x0001e1df in std::ostream::sentry::sentry(std::ostream&) () (gdb) disass 0x0001e1df Dump of assembler code for function _ZNSo6sentryC1ERSo: 0x1e1d0 <_ZNSo6sentryC1ERSo>: push %ebp 0x1e1d1 <_ZNSo6sentryC1ERSo+1>: mov %esp,%ebp 0x1e1d3 <_ZNSo6sentryC1ERSo+3>: push %ebx 0x1e1d4 <_ZNSo6sentryC1ERSo+4>: mov 0xc(%ebp),%ecx 0x1e1d7 <_ZNSo6sentryC1ERSo+7>: mov 0x8(%ebp),%edx 0x1e1da <_ZNSo6sentryC1ERSo+10>: mov (%ecx),%eax 0x1e1dc <_ZNSo6sentryC1ERSo+12>: mov %ecx,0x4(%edx) 0x1e1df <_ZNSo6sentryC1ERSo+15>: mov 0xfffffff4(%eax),%ebx 0x1e1e2 <_ZNSo6sentryC1ERSo+18>: lea (%ebx,%ecx,1),%eax 0x1e1e5 <_ZNSo6sentryC1ERSo+21>: mov 0x14(%eax),%ebx 0x1e1e8 <_ZNSo6sentryC1ERSo+24>: test %ebx,%ebx 0x1e1ea <_ZNSo6sentryC1ERSo+26>: sete %al 0x1e1ed <_ZNSo6sentryC1ERSo+29>: movzbl %al,%eax 0x1e1f0 <_ZNSo6sentryC1ERSo+32>: test %al,%al 0x1e1f2 <_ZNSo6sentryC1ERSo+34>: mov %al,(%edx) 0x1e1f4 <_ZNSo6sentryC1ERSo+36>: je 0x1e210 <_ZNSo6sentryC1ERSo+64> 0x1e1f6 <_ZNSo6sentryC1ERSo+38>: mov (%ecx),%eax 0x1e1f8 <_ZNSo6sentryC1ERSo+40>: mov 0xfffffff4(%eax),%edx 0x1e1fb <_ZNSo6sentryC1ERSo+43>: add %edx,%ecx 0x1e1fd <_ZNSo6sentryC1ERSo+45>: mov 0x70(%ecx),%eax 0x1e200 <_ZNSo6sentryC1ERSo+48>: test %eax,%eax 0x1e202 <_ZNSo6sentryC1ERSo+50>: je 0x1e210 <_ZNSo6sentryC1ERSo+64> 0x1e204 <_ZNSo6sentryC1ERSo+52>: mov %eax,0x8(%ebp) ---Type to continue, or q to quit--- 0x1e207 <_ZNSo6sentryC1ERSo+55>: pop %ebx 0x1e208 <_ZNSo6sentryC1ERSo+56>: pop %ebp 0x1e209 <_ZNSo6sentryC1ERSo+57>: jmp 0x1dde0 <_ZNSo5flushEv> 0x1e20e <_ZNSo6sentryC1ERSo+62>: mov %esi,%esi 0x1e210 <_ZNSo6sentryC1ERSo+64>: pop %ebx 0x1e211 <_ZNSo6sentryC1ERSo+65>: pop %ebp 0x1e212 <_ZNSo6sentryC1ERSo+66>: ret 0x1e213 <_ZNSo6sentryC1ERSo+67>: nop 0x1e214 <_ZNSo6sentryC1ERSo+68>: nop 0x1e215 <_ZNSo6sentryC1ERSo+69>: nop 0x1e216 <_ZNSo6sentryC1ERSo+70>: nop 0x1e217 <_ZNSo6sentryC1ERSo+71>: nop 0x1e218 <_ZNSo6sentryC1ERSo+72>: nop 0x1e219 <_ZNSo6sentryC1ERSo+73>: nop 0x1e21a <_ZNSo6sentryC1ERSo+74>: nop 0x1e21b <_ZNSo6sentryC1ERSo+75>: nop 0x1e21c <_ZNSo6sentryC1ERSo+76>: nop 0x1e21d <_ZNSo6sentryC1ERSo+77>: nop 0x1e21e <_ZNSo6sentryC1ERSo+78>: nop 0x1e21f <_ZNSo6sentryC1ERSo+79>: nop End of assembler dump. (gdb) n Single stepping until exit from function _ZNSo6sentryC1ERSo, which has no line number information. Program received signal SIGSEGV, Segmentation fault. 0x0001e1df in std::ostream::sentry::sentry(std::ostream&) () (gdb) n Single stepping until exit from function _ZNSo6sentryC1ERSo, which has no line number information. Exiting due to signal SIGSEGV General Protection Fault at eip=0001e1df eax=00000000 ebx=00043b58 ecx=00043b58 edx=000c7f60 esi=00000054 edi=00001630 ebp=000c7f28 esp=000c7f24 program=c:\Archives\RIP2\DJGPP\bin\wel-g.exe cs: sel=01ef base=022c0000 limit=000cffff ds: sel=01f7 base=022c0000 limit=000cffff es: sel=01f7 base=022c0000 limit=000cffff fs: sel=01e7 base=00009e10 limit=00003fff gs: sel=0207 base=00000000 limit=0010ffff ss: sel=01f7 base=022c0000 limit=000cffff App stack: [000c7fdc..00047fdc] Exceptn stack: [00047e8c..00045f4c] Call frame traceback EIPs: 0x0001e1df 0x0001e44e 0x0000167e 0x0000d817 Program exited with code 0377. (gdb) > >> Could this problem be resulting from the libstdc++.a archive library >> having a name that defies DOS naming conventions? > >No, but is it possible that libstdc++.a you linked against was compiled >for native GNU/Linux compiler, not as a cross-compiled library for DJGPP? No. Note: that I am using gcc and libstdc++ from this package: bef1ba664e820ee634b55b3f77fcebf3 gcc-3.2.tar.gz Here is the exact command I configured gcc-3.2 and libstdc++-v3 with. cd ~/gcc-3.2-obj ../gcc-3.2-src/configure --target=i686-pc-msdosdjgpp --prefix=/usr/local/compiler/cross2/djgpp --without-newlib --with-headers=/usr/local/compiler/cross2/djgpp/i686-pc-msdosdjgpp/include --with-libs=/usr/local/compiler/cross2/djgpp/lib /usr/local/compiler/cross2/djgpp/i686-pc-msdosdjgpp/lib I have also tried just doing: ../gcc-3.2-src/configure --target=i686-pc-msdosdjgpp --prefix=/usr/local/compiler/cross2/djgpp --with-headers=/usr/local/compiler/cross2/djgpp/i686-pc-msdosdjgpp/include Both above configurations have the same effect WRT the sigsegv. I am able to simply link against against libstdc++.a without getting the SIGSEGV. It is only when I include a libstdc++ header such as that I get the SIGSEGV. ==================================================== When I compile this porgram: #include int main() { printf("Welcome to GNU C++ for Linux programming!\n"); return 0; } like this: (using gcc) /usr/local/compiler/cross2/djgpp/bin/i686-pc-msdosdjgpp-gcc -lstdc++ -lm welcome.c -o welcome.exe no sigsegv.. welcome.exe runs in DOS and Win32. ==================================================== When I compile the above program like this: (using g++) /usr/local/compiler/cross2/djgpp/bin/i686-pc-msdosdjgpp-g++ -lstdc++ -lm welcome.c -o welcome.exe no sigsegv.. welcome.exe runs in DOS and Win32. ==================================================== but when I compile _this_ program that includes the iostream header, I have the problem.. #include int main() { std::cout << "Welcome to GNU C++ for Linux programming!" << std::endl; return 0; } /usr/local/compiler/cross2/djgpp/bin/i686-pc-msdosdjgpp-g++ -lstdc++ -lm welcome.cpp -o welcome.exe yes sigsegv.. welcome.exe does not run in DOS and Win32. ==================================================== Note: when I compile with the header, , I do not get the sigsegv. #include int main() { printf("Welcome to GNU C++ for Linux programming!\n"); return 0; } /usr/local/compiler/cross2/djgpp/bin/i686-pc-msdosdjgpp-g++ -lstdc++ -lm welcome.c -o welcome.exe no sigsegv.. welcome.exe runs in DOS and Win32. ==================================================== Does this answer your questions? Please tell me if it would be helpful to provide more information. Thank you, Charles