Compatability of cross-built COFF files and MSVS

95 views Asked by At

I have cross-built a win32 static library using i686-w64-mingw32-gccon a linux box.

I have inspected the resulting .lib file with nm on the linux side and see:

bsd_offset.o:
         U __assert
00000000 T _bsd_offset
00000000 b .bss
00000000 d .data
00000000 i .drectve
         U _flp3
00000004 C _randNo
00000000 r .rdata
00000000 r .rdata$zzz
00000000 t .text

bsdi.o:
00000000 T _bsdi
00000000 b .bss
         U _clp3
00000000 d .data
00000000 i .drectve
00000004 C _randNo
00000000 r .rdata$zzz
00000000 t .text

...

I have also inspected the .lib file with dumpbin /symbols on the windows side and see:

Microsoft (R) COFF/PE Dumper Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file libLib_rel.lib

File Type: LIBRARY

COFF SYMBOL TABLE
000 00000000 DEBUG  notype       Filename     | .file
    bsd_offset.c
002 00000000 SECT1  notype ()    External     | _bsd_offset
    tag index 00000000 size 00000000 lines 00000000 next function 00000000
004 00000000 SECT1  notype       Static       | .text
    Section length   BF, #relocs    4, #linenums    0, checksum        0
006 00000000 SECT2  notype       Static       | .data
    Section length    0, #relocs    0, #linenums    0, checksum        0
008 00000000 SECT3  notype       Static       | .bss
    Section length    0, #relocs    0, #linenums    0, checksum        0
00A 00000000 SECT4  notype       Static       | .rdata
    Section length   1A, #relocs    0, #linenums    0, checksum        0
00C 00000000 SECT6  notype       Static       | .drectve
    Section length   2C, #relocs    0, #linenums    0, checksum        0
00E 00000000 SECT7  notype       Static       | .rdata$zzz
    Section length   1A, #relocs    0, #linenums    0, checksum        0
010 00000004 UNDEF  notype       External     | _randNo
011 00000000 UNDEF  notype ()    External     | _flp3
012 00000000 UNDEF  notype ()    External     | __assert

String Table Size = 0x35 bytes

COFF SYMBOL TABLE
000 00000000 DEBUG  notype       Filename     | .file
    bsdi.c
002 00000000 SECT1  notype ()    External     | _bsdi
    tag index 00000000 size 00000000 lines 00000000 next function 00000000
004 00000000 SECT1  notype       Static       | .text
    Section length   70, #relocs    1, #linenums    0, checksum        0
006 00000000 SECT2  notype       Static       | .data
    Section length    0, #relocs    0, #linenums    0, checksum        0
008 00000000 SECT3  notype       Static       | .bss
    Section length    0, #relocs    0, #linenums    0, checksum        0
00A 00000000 SECT5  notype       Static       | .drectve
    Section length   26, #relocs    0, #linenums    0, checksum        0
00C 00000000 SECT6  notype       Static       | .rdata$zzz
    Section length   1A, #relocs    0, #linenums    0, checksum        0
00E 00000004 UNDEF  notype       External     | _randNo
00F 00000000 UNDEF  notype ()    External     | _clp3

String Table Size = 0x29 bytes

...

A colleague is attempting to build an exe using the lib using MSVS2008 and is seeing errors like:

1>------ Build started: Project: StaticLinkExample, Configuration: Release Win32 ------

1>Linking...

1>testLib_rel.lib(initialise.o) : warning LNK4229: invalid directive '/aligncomm:_randNo,2' encountered; ignored

1>testLib_rel.lib(lib.o) : warning LNK4229: invalid directive '/aligncomm:_randNo,2' encountered; ignored

...

1>   Creating library D:\Software\ThirdParty\Lib_v230\Trial\StaticLinkExample\Release\StaticLinkExample.lib and object D:\Software\ThirdPart\Lib_v230\Trial\StaticLinkExample\Release\StaticLinkExample.exp

1>testLib_rel.lib(shared.o) : error LNK2001: unresolved external symbol ___ms_vsnprintf

1>testLib_rel.lib(iniparser.o) : error LNK2001: unresolved external symbol ___ms_vsnprintf

1>testLib_rel.lib(utility.o) : error LNK2001: unresolved external symbol ___ms_vsnprintf

1>testLib_rel.lib(load_glf.o) : error LNK2001: unresolved external symbol ___chkstk_ms

1>testLib_rel.lib(utility.o) : error LNK2001: unresolved external symbol ___chkstk_ms

1>testLib_rel.lib(lib.o) : error LNK2001: unresolved external symbol _fmax

1>testLib_rel.lib(lib.o) : error LNK2001: unresolved external symbol _fmin

1>StaticLinkExample.exp : error LNK2001: unresolved external symbol bsd_offset

1>StaticLinkExample.exp : error LNK2001: unresolved external symbol bsdi

Do the nm and dumpbin outputs look sensible. If the symbols are there in the static library why would the link errors be occuring. Could it be that somehow the cross-built lib is not binary compatible with MSVS 2008?

0

There are 0 answers