From: gunther DOT ebert AT ixos-leipzig DOT de (Gunther Ebert) Subject: Have I found the b17 C++ problem? 9 Dec 1996 16:19:08 -0800 Sender: daemon AT cygnus DOT com Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <32AC4545.D75.cygnus.gnu-win32@ixos-leipzig.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0Gold (WinNT; I) Original-To: gnu-win32 AT cygnus DOT com Original-Sender: owner-gnu-win32 AT cygnus DOT com Hi, I think I have found the c++ problem of b16 and b17 (invalid executable when using exceptions). If you compile the following simple file /* hello.cc */ #include int main() { printf("Hello, world\n"); return 0; } /* end of hello.cc */ with exceptions enabled ( gcc -fexceptions -c hello.cc ) you will get an object file with an invalid section ..gcc_except_table $ objdump --section-headers hello.o hello.exe: file format pei-i386 Sections: Idx Name Size VMA LMA File off Algn 0 .text 00001e00 00401000 00001dac 00000400 2**2 CONTENTS, ALLOC, LOAD, CODE 1 .bss 000001cc 00403000 00000000 00000000 2**2 ALLOC 2 .data 00000200 00404000 000000a8 00002200 2**2 CONTENTS, ALLOC, LOAD, DATA 3 .idata 00000200 00405000 0000012c 00002400 2**2 CONTENTS, ALLOC, LOAD, DATA 4 .stab 00007e00 00406000 00007c20 00002600 2**2 CONTENTS, DEBUGGING, NEVER_LOAD 5 .stabstr 00035000 0040e000 00034e99 0000a400 2**0 CONTENTS, DEBUGGING, NEVER_LOAD 6 .gcc_except_table 00000200 00442e9c 000001b0 0003f49c 2**2 CONTENTS, ALLOC, LOAD, CODE $ The problem is that the Win32 PE format does only support section names up to 8 characters (quoted from the original MS WINNT.H): #define IMAGE_SIZEOF_SHORT_NAME 8 typedef struct _IMAGE_SECTION_HEADER { BYTE Name[IMAGE_SIZEOF_SHORT_NAME]; <<<<<<<<<<<<< union { DWORD PhysicalAddress; DWORD VirtualSize; } Misc; DWORD VirtualAddress; DWORD SizeOfRawData; DWORD PointerToRawData; DWORD PointerToRelocations; DWORD PointerToLinenumbers; WORD NumberOfRelocations; WORD NumberOfLinenumbers; DWORD Characteristics; } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER; (quoted from include/coff/i386.h): /********************** SECTION HEADER **********************/ struct external_scnhdr { char s_name[8]; /* section name */ char s_paddr[4]; /* physical address, aliased s_nlib */ char s_vaddr[4]; /* virtual address */ char s_size[4]; /* section size */ char s_scnptr[4]; /* file ptr to raw data for section */ char s_relptr[4]; /* file ptr to relocation */ char s_lnnoptr[4]; /* file ptr to line numbers */ char s_nreloc[2]; /* number of relocation entries */ char s_nlnno[2]; /* number of line number entries*/ char s_flags[4]; /* flags */ }; Generating assembler files and replacing the .gcc_except_table by ..gcc_exc does not work because there is at least one library (libgcc.a) which contains the .gcc_except_table section too. It seems to be a general compiler problem when generating COFF code. The compiler should not use section names which are longer than 8 characters in this case. Just a guess, Gunther - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".