Bug 13682 - delay-load doesn't work for target x86_64-w64-mingw32
Summary: delay-load doesn't work for target x86_64-w64-mingw32
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-11 17:51 UTC by Erik van Pienbroek
Modified: 2012-02-21 16:12 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erik van Pienbroek 2012-02-11 17:51:07 UTC
Generating a delay-load import library using dlltool fails to work for the x86_64-w64-mingw32 target:

$ cat mylib.def 
LIBRARY mylib.dll
EXPORTS
my_func

$ x86_64-w64-mingw32-dlltool --def mylib.def --kill-at --output-delaylib mylib.dll.a -n
dxeuh.s: Assembler messages:
dxeuh.s:5: Error: invalid instruction suffix for `push'
dxeuh.s:6: Error: invalid instruction suffix for `push'
dxeuh.s:7: Error: invalid instruction suffix for `push'
dxeuh.s:8: Error: invalid instruction suffix for `push'
dxeuh.s:10: Error: invalid instruction suffix for `pop'
dxeuh.s:11: Error: invalid instruction suffix for `pop'
dxeuh.s:12: Error: operand type mismatch for `jmp'
x86_64-w64-mingw32-dlltool: x86_64-w64-mingw32-as exited with status 1
x86_64-w64-mingw32-dlltool: failed to open temporary head file: dxeuh.o: No such file or directory

$ cat dxeuh.s 
# Import trampoline
	.section	.text
	.global	__tailMerge_mylib_dll_a
__tailMerge_mylib_dll_a:
	pushl %ecx
	pushl %edx
	pushl %eax
	pushl $__DELAY_IMPORT_DESCRIPTOR_mylib_dll_a
	call ___delayLoadHelper2@8
	popl %edx
	popl %ecx
	jmp *%eax

# DELAY_IMPORT_DESCRIPTOR
.section	.text$2
.global __DELAY_IMPORT_DESCRIPTOR_mylib_dll_a
__DELAY_IMPORT_DESCRIPTOR_mylib_dll_a:
	.long 1	# grAttrs
	.rva	__mylib_dll_a_iname	# rvaDLLName
	.rva	__DLL_HANDLE_mylib_dll_a	# rvaHmod
	.rva	__IAT_mylib_dll_a	# rvaIAT
	.rva	__INT_mylib_dll_a	# rvaINT
	.long	0	# rvaBoundIAT
	.long	0	# rvaUnloadIAT
	.long	0	# dwTimeStamp

.section .data
__DLL_HANDLE_mylib_dll_a:
	.long	0	# Handle

#Stuff for compatibility
	.section	.idata$5
	.long	0
	.long	0
__IAT_mylib_dll_a:
	.section	.idata$4
	.long	0
	.section	.idata$4
__INT_mylib_dll_a:
	.section	.idata$2


If the same command is tried using i686-w64-mingw32-dlltool then the import library is generated without problems.
Comment 1 Sourceware Commits 2012-02-21 16:10:22 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	ktietz@sourceware.org	2012-02-21 16:10:13

Modified files:
	binutils       : ChangeLog NEWS dlltool.c 

Log message:
	PR binutils/13682
	* NEWS: Mention new feature.
	* dlltool.c (i386_x64_dljtab): New stub-code for x64
	delayed-load feature.
	(i386_x64_trampoline): New trampoline-code for x64
	delayed-load feature.
	(make_one_lib_file): Add support for x64 delayed-load
	feature.
	(make_delay_head): Likewis

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/ChangeLog.diff?cvsroot=src&r1=1.1881&r2=1.1882
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/NEWS.diff?cvsroot=src&r1=1.106&r2=1.107
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/dlltool.c.diff?cvsroot=src&r1=1.104&r2=1.105
Comment 2 Kai Tietz 2012-02-21 16:12:37 UTC
Fixed.