[Bug ld/2729] New: ld terminated with signal 11 [Segmentation fault]
Hello, I tried to build a cross compiler on linux to build tools for interix 3.5. I managed to build such a compiler and linker, and the compiler seems to work fine, but the linker doesn't. Linux platform is Debian etch, kernel 2.6.11, gcc-4.0. I used binutils 2.16.91 20060413 (currently ships with debian etch) and configured with --target=i586-pc-interix3 --with-gnu-as --with-gnu-ld For cross-gcc, I used gcc-4.1.0 and configured with --target=i586-pc-interix3 --enable-languages=c --enable-threads=no --disable-shared --with-stabs --enable-nls --disable-libssp --with-gnu-as --with-gnu-ld I tried the following short program: int main() { return 3; } and got: $ i586-pc-interix3-gcc -c hello.c so compiling is ok, but ... $ i586-pc-interix3-gcc hello.o collect2: ld terminated with signal 11 [Segmentation fault] /usr/local/lib/gcc/i586-pc-interix3/4.1.0/libgcc.a(__main.o): In function `__do_global_ctors': /srv/src/gcc-4.1/build2/gcc/../../src/gcc/libgcc2.c:1956: undefined reference to `_atexit' /usr/local/lib/gcc/i586-pc-interix3/4.1.0/../../../../i586-pc-interix3/lib/libpsxdll.a(PSXDLL.dll.a):(.idata$2+0x0): undefined reference to `.idata$4' ... linking segfaults. (The .../lib/libpsxdll.a and all other libs I copied over from an interix 3.5 installation's /usr/lib/* to /usr/local/i586-pc-interix3/lib/*.) (The only binutils bug related to interix I could find is Bug 324, but it is old and marked resolved.) -- Summary: ld terminated with signal 11 [Segmentation fault] Product: binutils Version: 2.16 Status: NEW Severity: normal Priority: P2 Component: ld AssignedTo: unassigned at sources dot redhat dot com ReportedBy: mkoeppe at gmx dot de CC: bug-binutils at gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i586-pc-interix3 http://sourceware.org/bugzilla/show_bug.cgi?id=2729 --- You are receiving this mail because: --- You are on the CC list for the bug, or are watching someone who is. ___ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/2729] ld terminated with signal 11 [Segmentation fault]
--- Additional Comments From mkoeppe at gmx dot de 2006-06-08 19:37 --- Created an attachment (id=1066) --> (http://sourceware.org/bugzilla/attachment.cgi?id=1066&action=view) object file that fails linking ok, here is my object file from this tiny program: int main() { return 3; } The gcc link command with -v shows: $ LANG=C i586-pc-interix3-gcc -v hello.o Using built-in specs. Target: i586-pc-interix3 Configured with: ../src/configure --target=i586-pc-interix3 --enable-languages=c --enable-threads=no --disable-shared --with-stabs --enable-nls --disable-libssp --with-gnu-as --with-gnu-ld Thread model: single gcc version 4.1.0 /usr/local/libexec/gcc/i586-pc-interix3/4.1.0/collect2 -stack 0x40,0x1 -subsystem posix /usr/local/lib/gcc/i586-pc-interix3/4.1.0/../../../../i586-pc-interix3/lib/crt0.o -L/usr/local/lib/gcc/i586-pc-interix3/4.1.0 -L/usr/local/lib/gcc/i586-pc-interix3/4.1.0/../../../../i586-pc-interix3/lib hello.o -lgcc -lc -lpsxdll -lc -lpsxdll -v -lgcc collect2 version 4.1.0 (i386 Interix) /usr/local/lib/gcc/i586-pc-interix3/4.1.0/../../../../i586-pc-interix3/bin/ld -stack 0x40,0x1 -subsystem posix /usr/local/lib/gcc/i586-pc-interix3/4.1.0/../../../../i586-pc-interix3/lib/crt0.o -L/usr/local/lib/gcc/i586-pc-interix3/4.1.0 -L/usr/local/lib/gcc/i586-pc-interix3/4.1.0/../../../../i586-pc-interix3/lib hello.o -lgcc -lc -lpsxdll -lc -lpsxdll -v -lgcc collect2: ld terminated with signal 11 [Segmentation fault] /usr/local/lib/gcc/i586-pc-interix3/4.1.0/libgcc.a(__main.o): In function `__do_global_ctors': /srv/src/gcc-4.1/build2/gcc/../../src/gcc/libgcc2.c:1956: undefined reference to `_atexit' /usr/local/lib/gcc/i586-pc-interix3/4.1.0/../../../../i586-pc-interix3/lib/libpsxdll.a(PSXDLL.dll.a):(.idata$2+0x0): undefined reference to `.idata$4' -- http://sourceware.org/bugzilla/show_bug.cgi?id=2729 --- You are receiving this mail because: --- You are on the CC list for the bug, or are watching someone who is. ___ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/2729] ld terminated with signal 11 [Segmentation fault]
--- Additional Comments From mkoeppe at gmx dot de 2006-06-08 19:53 --- The libraries I copied from the self extracting archive SFU35SEL_EN.exe which can be obtained from here (you need a MS passport account): http://www.microsoft.com/downloads/details.aspx?FamilyID=896c9688-601b-44f1-81a4-02878ff11778&DisplayLang=en >From this archive I copied BaseUtils/usr/lib/* and SDK/usr/lib/* to /usr/local/i586-pc-interix3/lib (You need to make the symlinks manually, symlinks in the sfx archive are shown as small regular files) There is a new interix version (5.2) included in W2K3R2. The tools for that can be obtained from here (no passport needed): http://www.microsoft.com/downloads/details.aspx?FamilyID=8b4987e6-d960-49a2-bf52-d3fbd654254c&DisplayLang=en Utilities and SDK for UNIX-based Applications_X86.exe With these files, ld segfaults nevertheless. -- http://sourceware.org/bugzilla/show_bug.cgi?id=2729 --- You are receiving this mail because: --- You are on the CC list for the bug, or are watching someone who is. ___ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/2729] ld terminated with signal 11 [Segmentation fault]
--- Additional Comments From mkoeppe at gmx dot de 2006-06-22 22:08 --- Hi Nick, (In reply to comment #5) > Created an attachment (id=1112) --> (http://sourceware.org/bugzilla/attachment.cgi?id=1112&action=view) > Cope with missing .idata sections when building DataDictionary is this the complete patch? It does apply and build, but ld segfaults nevertheless. :-( (In reply to comment #4) > If you want to, try changing the "result = > FALSE" statements in the patch to "result = TRUE" and see if the resulting > linked executable actually works. Where do I find these statements? Martin -- http://sourceware.org/bugzilla/show_bug.cgi?id=2729 --- You are receiving this mail because: --- You are on the CC list for the bug, or are watching someone who is. ___ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/2729] ld terminated with signal 11 [Segmentation fault]
--- Additional Comments From mkoeppe at gmx dot de 2006-06-24 01:29 --- Hi Nick, thank you very much. Now it does apply and build, and the segfault is away. Unfortunately, linking is not yet successful, even with result=TRUE, due to missing symbols, namely ".idata$4" and "atexit". I now linked exactly the same files (besides libgcc.a) with --cref, once on original interix with their version of gnu ld, where linking succeeds, and once with my cross compiled ld, and produced 2 cref tables. There is a difference just at these 2 symbols. Could you please have a look? Martin -- http://sourceware.org/bugzilla/show_bug.cgi?id=2729 --- You are receiving this mail because: --- You are on the CC list for the bug, or are watching someone who is. ___ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/2729] ld terminated with signal 11 [Segmentation fault]
--- Additional Comments From mkoeppe at gmx dot de 2006-06-24 01:31 --- Created an attachment (id=1119) --> (http://sourceware.org/bugzilla/attachment.cgi?id=1119&action=view) cref table from working interix ld -- http://sourceware.org/bugzilla/show_bug.cgi?id=2729 --- You are receiving this mail because: --- You are on the CC list for the bug, or are watching someone who is. ___ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/2729] ld terminated with signal 11 [Segmentation fault]
--- Additional Comments From mkoeppe at gmx dot de 2006-06-24 01:32 --- Created an attachment (id=1120) --> (http://sourceware.org/bugzilla/attachment.cgi?id=1120&action=view) cref table from failing cross ld -- http://sourceware.org/bugzilla/show_bug.cgi?id=2729 --- You are receiving this mail because: --- You are on the CC list for the bug, or are watching someone who is. ___ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/2729] ld terminated with signal 11 [Segmentation fault]
--- Additional Comments From mkoeppe at gmx dot de 2006-07-24 21:34 --- Hi Nick, > I am intrigued by the absence of the atexit symbol. Looking at the cross > reference files it appears that the Interix linker is obtainign it from a file > called wk_atexit.o. What is this file ? Is it included in the gcc linker's > command line ? Does it contain a weak definition of the atexit symbol ? yes, it is included, i.e. it's part of interix's libc.a. In between, I had a closer look at the problem, and I already had contact with Aaron W. LaFramboise who I think wrote ld's PECOFF weak linkage support. For a working interix ld there is some stuff missing in upstream bfd/ld (not just a few lines of code!), which can be obtained from the MS patches (e.g. weak alias support and shared lib support). I'm not sure why the MS patches didn't go back to upstream in 2002 or 2003. If this was appreciated now, I could help. I wrote to Aaron the text below and am currently waiting for his response. Martin I now had a closer look at my weak symbol linkage problem. First I decoded the symbol table entries for wk_atexit.o, part of libc.a, where the weak symbol "atexit" is, and which fails during link: There is an normal undefined symbol "__atexit" at index 4 in the coff symbol table. Entry 5 is the weak symbol entry "_atexit". Value=0, SectionNumber=0, Type=0, StorageClass=0x69=105= WEAK EXTERNAL, AuxSymbols=1 Entry 6 (i.e. aux entry): Tag index = 4, i.e. "__atexit" Characteristic = 3 = IMAGE_WEAK_EXTERN_SEARCH_ALIAS Currently cofflink.c says it supports only IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY, however. I think the guys at MS applied their patches before you applied your PECOFF stuff, and unfortunately, these patches didn't go back to upstream binutils. In their patches you can read some interesting comments, i.e. that they only support WEAK ALIAS, see below. It seems to me that they have added these WEAK ALIASES to PECOFF in order to be able to emulate the unix weak symbol behaviour. So maybe WEAK ALIAS support should be added to ld officially. And this seems to be compatible with LINK.EXE, too. The full MS patches are available from MS, or, if you want to, I can send them to you. ### Add support for .alias pseudo for C_NT_WEAK alias symbols. * config/obj-coff.c (obj_coff_weak): change conditional comp. (obj_coff_alias): New function. (op_pseudo_table): add it. diff -drupP --exclude-from=/M/donn/diffs/exclude.files gas.orig/config/obj-coff.c gas/conf ig/obj-coff.c --- gas.orig/config/obj-coff.c Tue Apr 11 13:03:19 2000 +++ gas/config/obj-coff.c Tue Apr 11 14:05:11 2000 @@ -217,12 +217,8 @@ obj_coff_weak (ignore) S_SET_WEAK (symbolP); #endif -#ifdef TE_PE - S_SET_STORAGE_CLASS (symbolP, C_NT_WEAK); -#else S_SET_STORAGE_CLASS (symbolP, C_WEAKEXT); -#endif - + if (c == ',') { input_line_pointer++; @@ -1437,6 +1433,78 @@ obj_coff_section (ignore) demand_empty_rest_of_line (); } +#ifdef TE_PE +/* Parse .alias directives, which is how PE does weak symbols: + An alias defines a "weak" name for an exising symbol; it does + not label an entry point directly. There are 3 types of PE + weak; we only support the alias form (IMAGE_WEAK_EXTERN_SEARCH_ALIAS) + + Syntax: .alias , + + */ + # bfd/cofflink.c: + /* PE weak symbols are aliases... we need to get the aliased +real symbol. */ + if (obj_pe(abfd) && sym.n_sclass == C_NT_WEAK) + { + /* It's a PE weak symbol (type IMAGE_WEAK_EXTERN_SEARCH_ALIAS) +That's implemented as an indirect in our parlance. +Find the aux entry, get the referenced symbol, and insert +its name. */ + + int target_idx; + union internal_auxent auxent; + + BFD_ASSERT (sym.n_numaux == 1); + + /* Read in the aux information */ + + bfd_coff_swap_aux_in (abfd, (PTR) (esym + symesz), sym.n_type, + sym.n_sclass, 0, sym.n_numaux, + (PTR) &auxent); + /* From the aux information, get the backing "strong" +local symbol index. */ + target_idx = auxent.x_sym.x_tagndx.l; + + /* Check for IMAGE_WEAK_EXTERN_SEARCH_ALIAS; it's all +we currently support. (See the 3/98 or later PE docs; +there used to be only two types.) */ + BFD_ASSERT (auxent.x_sym.x_misc.x_fsize == 3); + + /* Now that we've caught it... + +For the moment (u
[Bug ld/2729] ld terminated with signal 11 [Segmentation fault]
--- Additional Comments From mkoeppe at gmx dot de 2006-09-07 21:44 --- (In reply to comment #14) Hi Nick, the following text is from the README file in the patch dir. So MS seems to be willing to have these patches included. The copyright issue is still open, of course... Martin gcc.tgz/gcc-source/queued/README: [...] Reminder: all the code herein, and the sources that these apply to, are subject to the GPL. You should understand the obligations it creates for you. The patches herein have had the appropriate releases signed and accepted by the FSF for them, and could be included in the official gcc trees over time. It is our hope that that does happen. Of course, consistent with the GPL, no warranty of any form is expressed or implied. Microsoft provides no support for these instructions, the patches, or the binaries and is not responsible for errors or omissions in them. Ada Core Technologies (www.gnatpro.com) has assisted Microsoft in the development of the Interix version of GCC and in proposing the patches for inclusion into the FSF GCC source tree. [...] -- http://sourceware.org/bugzilla/show_bug.cgi?id=2729 --- You are receiving this mail because: --- You are on the CC list for the bug, or are watching someone who is. ___ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils