Bruno Haible wrote:
I have a situation with clang's 'lld-link' linker
in Wget2 where the symbol 'crc32()' in Gnulib is called
instead of the correct symbol 'crc32()' in Zlib.
Are you sure the symbol that is called comes from gnulib?
The only references to 'crc32' in gnulib are in the module 'crc',
and this module is not used by any other module in gnulib nor by
by wget2 [1].
Hello Bruno. Sorry for the delay, but Google moved
your reply to the Spam-folder!?
First, I admit I did build and use Gnulib in an
non-official way; a static-lib of *all* Gnulib functions:
nm --defined-only gnulib-vc.lib | grep ' T _crc32'
00000000 T _crc32
00000040 T _crc32_no_xor
00000020 T _crc32_update
00000060 T _crc32_update_no_xor
But the issue I had while building Wget2 (with '-DWITH_ZLIB');
when compiling using 'clang-cl' and linking with
MSVC's 'link', there is no problem with any .lib order.
From the wget2.map:
0001:000dfcb0 _crc32 004e0cb0 f zlib:crc32.obj
But using 'lld-link' instead, and with 'gnulib-vc.lib'
ahead of 'zlib.lib', the wget2.map has this:
lld-link: Loaded zlib.lib(crc32.obj) for _crc32
...
lld-link: Loaded gnulib-vc.lib(crc.obj) for _crc32
Wget2 will use the latter '_crc32' and crash at run-time:
wget2!crc32_update_no_xor(unsigned int crc = 0xffffffff,
char * buf = 0x00000000 "", unsigned int len = 0xd7bcd10)+0x24
wget2!crc32_update(unsigned int crc = 0, char * buf = 0x00000000 "",
unsigned int len = 0xd7bcd10)+0x17
wget2!crc32(char * buf = 0x00000000 "", unsigned int len = 0xd7bcd10)+0x12
wget2!inflate(struct z_stream_s * strm = 0x0d2dd530, int flush = 0n2)+0x111
wget2!gzip_decompress(struct wget_decompressor_st * dc = <Value unavailable
error>,
char * src = <Value unavailable error>, unsigned int srclen = <Value
unavailable error>)+0x42
But linking with 'zlib.lib' first, there is no problem.
Hence my request to rename those symbols to 'gl_crc32' etc.
Can you show what the machine code of the called function looks like?
Dis-asm of Zlib's crc32.obj:
_crc32:
push ebp
mov ebp,esp
push ecx
mov dword ptr -0x4[ebp],0xcccccccc
cmp dword ptr 0xc[ebp],0x00000000
jne X$1
xor eax,eax
jmp X$8
X$1:
mov eax,0x00000001
test eax,eax
je X$3
mov dword ptr -0x4[ebp],0x00000001
movzx ecx,byte ptr -0x4[ebp]
....
Dis-asm of Gnulib's crc.obj is something else:
_crc32:
push ebp
mov ebp,esp
mov eax,0xc[ebp]
push eax
mov ecx,0x8[ebp]
push ecx
push 0x00000000
call _crc32_update
add esp,0x0000000c
pop ebp
ret
--
--gv