Jeremy Gordon's GoLink can be used to link Masm object files, it doesn't need of import libraries :
\masm32\bin\ml /c /coff Win.asm
\goasm\golink Win.obj kernel32.dll user32.dll
[attachment deleted by admin]
Vortex,
Have you tried it out with both DLLs and static libraries ? Jeremy's linker sound very useful here so it would be interesting to know if it can do both.
Hi Hutch,
I tried it with masm32.lib but GoLink doesn't doesn't support static libraries :
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
.data
message db "Masm + GoLink",0
.code
start:
invoke StdOut,ADDR message
invoke ExitProcess,0
END start
GoLink.Exe Version 0.25.4 - Copyright Jeremy Gordon 2002/4 - JG@JGnet.co.uk
Error!
The following symbol was not defined in the object file or files:-
StdOut
Output file not made
GoAsm supports static libs, it extracts the required object modules from the static libs and attaches them to the main object file so that GoLink can process all of them without any problem.
Hi Hutch,
This technique below works fine :
\masm32\bin\polib /extract:stdout.obj \masm32\lib\masm32.lib
\masm32\bin\polib /extract:strlen.obj \masm32\lib\masm32.lib
\masm32\bin\ml /c /coff Hello.asm
\goasm\golink /console Hello.obj stdout.obj strlen.obj kernel32.dll user32.dll
[attachment deleted by admin]
GoLink works also with Pelle's C compiler.
[attachment deleted by admin]
Vortex,
Interesting stuff.
Hi greg,
GoLink should also work with the VC++ compiler.
Vortex,
Yeah, I use both MSVC/C++ 2003 and Pelles C. I really like Pelles C, as I prefer C over C++, I like the C99 support and it's just an excellent C compiler.
Hi Greg,
Here is the same example compiled with VC++ toolkit 2003
[attachment deleted by admin]
GoAsm declares defaulty all invoked functions as externals. Based on the GoAsm approach, the apicall macro eliminates the use of include files and import libraries but there is no parameter checking.
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include apicall.inc
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
.data
ClassName db "WndClass",0
Application db "Simple Window",0
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
.code
start:
apicall GetModuleHandleA, NULL
mov hInstance,eax
apicall GetCommandLineA
mov CommandLine,eax
apicall WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
apicall ExitProcess,eax
.
.
apicall MACRO name:REQ,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15
local pos,counter
counter=0
FOR arg,<p15,p14,p13,p12,p11,p10,p9,p8,p7,p6,p5,p4,p3,p2,p1>
IFNB <arg>
counter=counter+1
pos=@InStr(1,arg,<ADDR>) OR @InStr(1,arg,<addr>) OR @InStr(1,arg,<Addr>)
IF pos
IF (OPATTR(@SubStr(arg,%pos+5))) EQ 98
lea eax,@SubStr(<arg>,%pos+5)
push eax
ELSE
push OFFSET @SubStr(<arg>,%pos+5)
ENDIF
ELSE
push arg
ENDIF
ENDIF
ENDM
API_function TEXTEQU @CatStr(name,<@>,%4*counter)
EXTERNDEF API_function:proc
call API_function
ENDM
\masm32\bin\ml /c /coff SimpleWnd.asm
\goasm\golink SimpleWnd.obj kernel32.dll user32.dll
Notice that it's possible to link the object file with Polink or MS link.
[attachment deleted by admin]
Time a go I have played with Golink for do the assembly of my nasm files (basic ones, included some of the iczelions), you should note that GoLink let to his assembler pass a flag or something about where a section is shared, the tutorial about Hooks was not able to run OK (even that is linked OK), because I dont find any flag in the Linker, the only way that I can think of is a hex editor and reverse the section???
Geremy know about this issue, tought dont know if new version of GoLink support this now???
Quote from: rea on October 16, 2005, 03:19:13 PM
Time a go I have played with Golink for do the assembly of my nasm files (basic ones, included some of the iczelions), you should note that GoLink let to his assembler pass a flag or something about where a section is shared, the tutorial about Hooks was not able to run OK (even that is linked OK), because I dont find any flag in the Linker, the only way that I can think of is a hex editor and reverse the section???
When I was experimenting with the mouse hook tutorial I couldn't find any GoLink flag to do this, but using GoAsm (0.51) in combination with GoLink (0.25.1) I had no problems adding a shared attribute for the data section of my DLL. See "How to declare a section" and "Adding a shared attribute" in the GoAsm Manual.
A ya, but will be nice for use it with other assemblers, like in this case masm (you will turn to goasm?), you can link all the icz tuts but the results of the Hook one are a problem ;).
The shared flag is done in the code in GoAsm. (The assmebler does something with the object file created, as to what, I'm unsure)
eg.
DATA SECTION "NAME" SHARED
Using the latest version of Golink, you can specify DLL names instead of import libraries :
includelib user32.dll
includelib kernel32.dll
includelib comctl32.dll
To get GoLink V0.26.6 :
http://www.masm32.com/board/index.php?topic=6146.0
[attachment deleted by admin]
The same can now be done with GoAsm + GoLink.
Instead of using includelib as you would if you were using MASM+GoLink, if you are using GoAsm+GoLink the syntax is:-
#dynamiclinkfile user32.dll, kernel32.dll, comctl32.dll
the comma is optional and separate lines are ok, too.
The above declaration is in the asm source. It works the same way as MASM's includelib (the information is passed to the linker by the assembler using the .drectve section in the object file). So this avoids having to refer to the dll in the linker's command line or command file. #dynamiclinkfile only works if you use GoAsm+GoLink. Use includelib if you are using MASM+GoLink. The reason why in both cases you specify the dll itself rather than a lib file, is that GoLink does not refer to lib files when finding out which dlls provide the functions required. Instead at link-time it looks inside the dll itself. Since most of these dlls are already in memory anyway this is also efficient.
Hi Jeremy,
Thanks for the info :U