This is the mail archive of the
cygwin@sources.redhat.com
mailing list for the Cygwin project.
ld -shared and @ordinals in .def files
- To: <cygwin at sources dot redhat dot com>
- Subject: ld -shared and @ordinals in .def files
- From: "Danny Smith" <danny_r_smith at hotmail dot com>
- Date: Tue, 25 Jul 2000 11:18:58 +1200
Hi
ld -shared (prerelease binutils-20000722-1) appears to ignore the
ordinal values supplied in a .def when building dlls.
For example (modified from Mumit's dllhelpers-0.2.5/c):
This def (mycdll.def)
EXPORTS
dll_global_int_var @1 DATA
dll_int_square @2
dll_set_global_int_var @3
dll_double_square @4
dll_get_global_int_var @5
dll_float_square @6
and this command
gcc -shared -Wl,--out-implib,libimpcdll.a mycdll.def cdll.o
dllinit.o
successfully builds a working dll and import lib.
But this is what is in the dll (partial output from Dependency Walker
2.0):
Export Ordinal Hint Function Entry Point
------ ---------- ---------- ---------------------- -----------
[C ] 1 (0x0001) 1 (0x0001) dll_float_square 0x00001074
[C ] 2 (0x0002) 2 (0x0002) dll_get_global_int_var 0x00001094
[C ] 3 (0x0003) 3 (0x0003) dll_global_int_var 0x00003000
[C ] 4 (0x0004) 4 (0x0004) dll_int_square 0x00001048
[C ] 5 (0x0005) 5 (0x0005) dll_set_global_int_var 0x00001084
[C ] 6 (0x0006) 0 (0x0000) dll_double_square 0x0000105C
The ordinals do not match what was requested. This occurs when using
only the def file to mark symbols for export and when using
__declspec(dllexport) in code + a user-supplied .def.
Using dllwrap:
dllwrap --def mycdll.def --implib libimpcdll.a -o cdll.dll cdll.o
dllinit.o
The ordinals are as requested:
Export Ordinal Hint Function Entry Point
------ ---------- ---------- ---------------------- -----------
[C ] 1 (0x0001) 3 (0x0003) dll_global_int_var 0x00002000
[C ] 2 (0x0002) 4 (0x0004) dll_int_square 0x00001048
[C ] 3 (0x0003) 5 (0x0005) dll_set_global_int_var 0x00001084
[C ] 4 (0x0004) 0 (0x0000) dll_double_square 0x0000105C
[C ] 5 (0x0005) 2 (0x0002) dll_get_global_int_var 0x00001094
[C ] 6 (0x0006) 1 (0x0001) dll_float_square 0x00001074
[BTW I have found Dependency Walker (depends.exe) a very useful tool to
sort out problems with dlls, and can trace explicit run-time calls
(LoadLibrary/GetProcAddress) as well as load-time links. Latest version
(improved over the one that ships with MSVC++6) can be downloaded from
the author at:
http://stevemiller.net/apps.html ]
Regards
Danny
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com