[GHC] #7097: linker fails to load package with binding to foreign library

GHC cvs-ghc at haskell.org
Sun Aug 5 12:42:57 CEST 2012


#7097: linker fails to load package with binding to foreign library
-------------------------------+--------------------------------------------
    Reporter:  nus             |       Owner:              
        Type:  bug             |      Status:  new         
    Priority:  normal          |   Milestone:              
   Component:  Runtime System  |     Version:  7.4.2       
    Keywords:                  |          Os:  Windows     
Architecture:  x86             |     Failure:  None/Unknown
  Difficulty:  Unknown         |    Testcase:              
   Blockedby:                  |    Blocking:              
     Related:  2283            |  
-------------------------------+--------------------------------------------

Comment(by nus):

 `libws2_32.a` in MinGW-w64 is an archive combining objects created from a
 `.def` file and the C sources
 [http://sourceforge.net/apps/trac/mingw-w64/browser/trunk/mingw-w64-crt/Makefile.am
 `src_libws2_32`].
 The `.def`
 [http://sourceforge.net/apps/trac/mingw-w64/browser/trunk/mingw-w64-crt/lib32/ws2_32.def
 file] declares the indirection:
 {{{
 ;
 ; Definition file of WS2_32.dll
 ; Automatic generated by gendef
 ; written by Kai Tietz 2008
 ;
 LIBRARY "WS2_32.dll"
 EXPORTS
 [...snip...]
 WSACleanup at 0
 [...snip...]
 }}}
 {{{
 $ objdump -x /c/mingw32/i686-w64-mingw32/lib/libws2_32.a
 [...snip...]
 dajhs00026.o:     file format pe-i386
 rw-r--r-- 1000/100    619 Apr 30 06:54 2012 dajhs00026.o
 architecture: i386, flags 0x00000039:
 HAS_RELOC, HAS_DEBUG, HAS_SYMS, HAS_LOCALS
 start address 0x00000000

 Characteristics 0x104
         line numbers stripped
         32 bit words
 [...snip...]
 Sections:
 Idx Name          Size      VMA       LMA       File off  Algn
   0 .text         00000008  00000000  00000000  0000012c  2**2
                   CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
   1 .data         00000000  00000000  00000000  00000000  2**2
                   ALLOC, LOAD, DATA
   2 .bss          00000000  00000000  00000000  00000000  2**2
                   ALLOC
   3 .idata$7      00000004  00000000  00000000  00000134  2**2
                   CONTENTS, RELOC
   4 .idata$5      00000004  00000000  00000000  00000138  2**2
                   CONTENTS, RELOC
   5 .idata$4      00000004  00000000  00000000  0000013c  2**2
                   CONTENTS, RELOC
   6 .idata$6      0000000e  00000000  00000000  00000140  2**1
                   CONTENTS
 SYMBOL TABLE:
 [  0](sec  1)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000000 .text
 [  1](sec  2)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000000 .data
 [  2](sec  3)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000000 .bss
 [  3](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000000 .idata$7
 [  4](sec  5)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000000 .idata$5
 [  5](sec  6)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000000 .idata$4
 [  6](sec  7)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000000 .idata$6
 [  7](sec  1)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 _WSACleanup at 0
 [  8](sec  5)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000
 __imp__WSACleanup at 0
 [  9](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000
 __head_lib32_libws2_32_a


 RELOCATION RECORDS FOR [.text]:
 OFFSET   TYPE              VALUE
 00000002 dir32             .idata$5


 RELOCATION RECORDS FOR [.idata$7]:
 OFFSET   TYPE              VALUE
 00000000 rva32             __head_lib32_libws2_32_a


 RELOCATION RECORDS FOR [.idata$5]:
 OFFSET   TYPE              VALUE
 00000000 rva32             .idata$6


 RELOCATION RECORDS FOR [.idata$4]:
 OFFSET   TYPE              VALUE
 00000000 rva32             .idata$6

 Contents of section .text:
  0000 ff250000 00009090                    .%......
 Contents of section .idata$7:
  0000 00000000                             ....
 Contents of section .idata$5:
  0000 00000000                             ....
 Contents of section .idata$4:
  0000 00000000                             ....
 Contents of section .idata$6:
  0000 1a005753 41436c65 616e7570 0000      ..WSACleanup..

 }}}

 The produced binary thus depends on `WS2_32.DLL`:
 {{{
 $ objdump -x winsock-load-faiure.exe
 winsock-load-faiure.exe:     file format pei-i386
 winsock-load-faiure.exe
 architecture: i386, flags 0x0000013a:
 EXEC_P, HAS_DEBUG, HAS_SYMS, HAS_LOCALS, D_PAGED
 start address 0x004014d0
 [...snip...]
 The Import Tables (interpreted .idata section contents)
  vma:            Hint    Time      Forward  DLL       First
                  Table   Stamp     Chain    Name      Thunk
   000fe000       000fe08c 00000000 00000000 000ff404 000fe404

         DLL Name: KERNEL32.dll
         vma:  Hint/Ord Member-Name Bound-To
         fe77c      69  CloseHandle
 [...snip...]
  000fe050       000fe37c 00000000 00000000 000ff68c 000fe6f4

         DLL Name: WS2_32.dll
         vma:  Hint/Ord Member-Name Bound-To
         ff164      26  WSACleanup
 [...snip...]
 Sections:
 Idx Name          Size      VMA       LMA       File off  Algn
   0 .text         000bfab8  00401000  00401000  00000600  2**5
                   CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
   1 .data         0000b1d4  004c1000  004c1000  000c0200  2**5
                   CONTENTS, ALLOC, LOAD, DATA
   2 .rodata       00014750  004cd000  004cd000  000cb400  2**2
                   CONTENTS, ALLOC, LOAD, DATA
   3 .rdata        000158d4  004e2000  004e2000  000dfc00  2**5
                   CONTENTS, ALLOC, LOAD, READONLY, DATA
   4 .eh_frame     00000168  004f8000  004f8000  000f5600  2**2
                   CONTENTS, ALLOC, LOAD, DATA
   5 .bss          00004200  004f9000  004f9000  00000000  2**5
                   ALLOC
   6 .idata        000016a8  004fe000  004fe000  000f5800  2**2
                   CONTENTS, ALLOC, LOAD, DATA
   7 .CRT          00000034  00500000  00500000  000f7000  2**2
                   CONTENTS, ALLOC, LOAD, DATA
   8 .tls          00000020  00501000  00501000  000f7200  2**2
                   CONTENTS, ALLOC, LOAD, DATA
   9 .rsrc         0000025c  00502000  00502000  000f7400  2**2
                   CONTENTS, ALLOC, LOAD, DATA
 [...snip...]
 SYMBOL TABLE:
 [  0](sec -2)(fl 0x00)(ty   0)(scl 103) (nx 1) 0x0000002d crtexe.c
 [...snip...]
 [28681](sec  7)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x000006f4
 __imp__WSACleanup at 0
 [...snip...]
 [33283](sec -1)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 _WSACleanup at 0
 [...snip...]
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7097#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the Glasgow-haskell-bugs mailing list