Re: Problem Linking (win32)
- From: "Jim Carlock" <spamtrap@xxxxxxxxxx>
- Date: Thu, 24 Jul 2008 17:53:59 -0400
07/24/2008 03:58 PM 521 bwaichu2.asm
07/24/2008 03:58 PM 1,536 bwaichu2.exe
07/24/2008 03:58 PM 1,669 bwaichu2.lst
07/24/2008 03:58 PM 448 bwaichu2.obj
Q:\bwaichu2>bwaichu2.exe
Test
Q:\bwaichu2>
The files are available here as zip'd files.
http://www.microcosmotalk.com/tech/asm/bwaichu/
And the second file that you posted, I modified it a little, but here
it is. It compiled fine and worked fine and presented the message test
as seen above.
I used PoLink to link.
<file name="bwaichu2.asm">
;nasm.exe -f win32 -l bwaichu2.lst bwaichu2.asm
;golink /console bwaichu2.obj kernel32.dll user32.dll msvcrt.dll
;polink /ENTRY:start /SUBSYSTEM:CONSOLE bwaichu2.obj kernel32.lib user32.lib msvcrt.lib
;
%define GetLastError _GetLastError@0
%define ExitProcess _ExitProcess@4
%define printf _printf
extern printf
extern ExitProcess
extern GetLastError
section .text
global start
start:
call GetLastError
push dword sText
call printf
add esp, 4
push dword 0
call ExitProcess
section .data
sText dd "Test", 0
<bwaichu2>
I didn't have any problems running it. I will mention, in case I have
not mentioned this in the past, that NASM does NOT make a valid PE
object file. Meaning specifically, meaning that dumpbin.exe and link.exe
can not extract the /IMPORTS and /EXPORTS. This is more for those that
develop the compiler than for us lay people. But perhaps someone else
other than I would be interested in seeing this?
<dump file="bwaichu2.obj">
Microsoft (R) COFF Binary File Dumper Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Dump of file bwaichu2.obj
File Type: COFF OBJECT
Summary
8 .data
1F .text
</dump>
<dump file="bwaichu2.exe">
Microsoft (R) COFF Binary File Dumper Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Dump of file bwaichu2.exe
File Type: EXECUTABLE IMAGE
Section contains the following imports:
KERNEL32.dll
402058 Import Address Table
402044 Import Name Table
0 time date stamp
0 Index of first forwarder reference
0 GetLastError
0 ExitProcess
MSVCRT.dll
402064 Import Address Table
402050 Import Name Table
0 time date stamp
0 Index of first forwarder reference
29E printf
Summary
1000 .data
1000 .text
</dump>
I'm not sure what it will take to get that in place, but the .exe
seems to dump properly.
And back to Brian, I'm linking against LIB files, i.e. files with
..lib extensions. If you want those files I got the msvcrt.lib from
the PO C compiler, and for the Windows files, I use either the MS
DDK, the MS PSDK, or one of the many other sources, which I think
even nasm provides.
http://www.microsoft.com/whdc/DevTools/ddk/
http://www.smorgasbordet.com/pellesc/ (polink/c compiler/make/etc)
Forgive me for not trying to link against dll's.
: Is the setting of the error value a bug with the linker, a
: bug with the creation of the obj file, a bug with the ms
: loader, or something else? Should I clear the error value
: whenever I assemble a file that links back to msvcrt.dll after
: a prologue?
I'm not sure. Someone else needs to jump in and see if they can
think of something. I know the API functions all have an underscore
prefixed. I've been using the %define statements to make sure the
underscore goes into place, even on the printf and sprintf functions.
Since you're pushing the parameters yourself, I don't think we need
to worry about left to right or right to left order. See if you can
link against the .lib files and see if that changes anything for you?
--
JC
Natural Cure For Pink-Eye (Conjunctivitis)
http://www.associatedcontent.com/article/381336/saliva_a_natural_cure_for_conjunctivitis.html
.
- References:
- Problem Linking (win32)
- From: bwaichu@xxxxxxxxx
- Re: Problem Linking (win32)
- From: Frank Kotler
- Re: Problem Linking (win32)
- From: Jim Carlock
- Re: Problem Linking (win32)
- From: bwaichu@xxxxxxxxx
- Re: Problem Linking (win32)
- From: Jim Carlock
- Re: Problem Linking (win32)
- From: bwaichu@xxxxxxxxx
- Problem Linking (win32)
- Prev by Date: Re: 32-bit drivers, 64-bit OS
- Next by Date: Re: Problem Linking (win32)
- Previous by thread: Re: Problem Linking (win32)
- Next by thread: Re: Problem Linking (win32)
- Index(es):
Relevant Pages
|