News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

GoLink not finding symbol (resolved)

Started by akane, August 02, 2008, 01:20:21 PM

Previous topic - Next topic

akane

I have tried your linker today, and stucked while linking to ?CreateCollection@@YGJPBD0@Z function from hhcol.dll (available in the old ddk for xp). The error says:
golink /console install.obj kernel32.dll crtdll.dll hhcol.dll

GoLink.Exe Version 0.26.9d - Copyright Jeremy Gordon 2002/8-JG@JGnet.co.uk

Error!
The following symbol was not defined in the object file or files:-
?CreateCollection
Output file not made


I suppose you cutt off stdcall mangling from the first @ character (I can turn it on and off by single %define). Is there a command line switch to disable it?

jorgon

Hi akane

Well in order to test this I just made a DLL containing a function with this name, called the function from another module and put the whole thing through GoLink.  It was found without problem!

I also tested GoLink's error output and it is definitely not stripping out anything in the error message from this symbol name.

From my tests and your information I would suggest that whatever assembler or compiler you are using to make the call is only trying to call "?CreateCollection" which of course is not being found in the DLL.

You can check this by looking inside the .obj file of the module which makes the call using a PE file viewer such as Wayne Radburn's excellent PEView available from http://www.magma.ca/~wjr/.  If you look at the IMAGE_SYMBOL TABLE the code label actually being called should appear in there.

Is it "?CreateCollection@@YGJPBD0@Z" or is it "?CreateCollection"?
Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

akane

Hello,

The import is "__imp_?CreateCollection@@YGJPBD0@Z", I always use the __imp_ prefix to avoid additional code (jumps) from import libraries, also have direct acces to imported functions entry point. Maybe this prefix causes my problem.

This is a custom installer for CHM collection file (winddk.col), for the old help system from ddk for xp.
I've writen it in nasm, my favorite assembler:
%include "asm.inc"
$use "hhcol.lib"

main:
sub     esp,260
invoke  GetCurrentDirectoryA, 260, esp
mov     eax,esp
invoke  ?CreateCollection@@YGJPBD0@Z, eax, "hh.dat"
add     esp,260
; error handling here


When clicked 'compile and run' using standard import libraries, the executable was created without any problems, but I got problems while linking it with GoLink.

This is the dump of my problematic symbol from the above code: (link -dump /all install.obj):
0000001C  DIR32 00000000 17  __imp_?CreateCollection@@YGJPBD0@Z
(__declspec(dllimport) long __stdcall CreateCollection(char const *,char const *))


I've attached my install.obj file and the original hhcol.dll form ddk setup package.


Edit: I have linked it first with golink 0.26.8, then seeing a problem, i've downloaded 0.26.9d which not helped.
Maybe you find it bad, but using a debugger and searching for all comparisions with '@', the version 0.26.9d after nop'ing in 00403E6A resolved my problem.

[attachment deleted by admin]

jorgon

Thanks for sending this Akane, I'll look at it and come back to you.

Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

jorgon

Hi Akane

Yes, it was the __imp_ stuff which was causing the problems. 
When GoLink sees the following it looks (in the DLLs and other modules) for a symbol without the decoration:-
__imp__MessageBoxA@16
_MessageBoxA@16
__imp_importeddata

But GoLink was not allowing for the possibility of something like:
__imp_?hell@@hdgn@Z
In the above GoLink was looking for the label ?hell when it should have been looking for __imp_?hell@@hdgn@Z.

This ought to work ok now with the attached fix.



[attachment deleted by admin]
Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

akane

Thank you, it is now working :U