Re: Problem Linking (win32)
- From: "Jim Carlock" <spamtrap@xxxxxxxxxx>
- Date: Wed, 23 Jul 2008 18:20:00 -0400
"bwaichu" asked:
: I am not including any macros in my file. I'm using the latest
: version of nasm and the latest version of golink. I want to feel
: out NASM some more before I start to use macros. I'm just
: following the NASM manual for the sections for win32 coff.
Ok, I compiled what you provided to see what was going on myself.
I know I've had some linking problems in the past. I link against
the .lib files. I'm not sure that I can link against .dll files,
but I'm willing to try.
I use the LIB e.v. to identify the path where the .lib files are
located. I didn't see msvcrt.lib in the Platform SDK files, so I
had to find another location for it. And I found that in / with
Pelles C compiler. Once I located the msvcrt.lib file, the rest
of the problems involved making sure a _ gets placed onto the
API declarations. Thus you see the following in the code I posted:
%define MessageBoxA _MessageBoxA@16
%define ExitProcess _ExitProcess@4
%define sprintf _sprintf
extern MessageBoxA
extern ExitProcess
extern sprintf
I wanted to test out Frank's suggestion about the .CODE
and .TEXT so while compiling I happened to remember some
things about the win32.inc file. I knew that file held
some important information in it because I've seen others
use it and I've mimicked what was in it. So while trying
to figure out the .CODE / .TEXT thing, I thought I hit on
a possible bug. And maybe I did, I don't know, I just did
not get what I expected to get.
The %imacro lines expanded, but the %define lines did not
show up in the listing file (test.lst).
(1) You need to make sure the API get an underscore placed
in front of them in some way I think.
(2) I think you need to link against the .lib files, but I
haven't gone that route and tested that. That's how I got
your application to compile, link and run. It presented a
small messagebox with the number 16 in it. I really did
not get into the code so I don't even know what was to get
placed into the MessageBox. I just wanted to compile it
and see if I could get it to run. Shame on me.
: A consistent error occurs upon the loading of my asm. No error
: occurs at loading if I leave out functions that link back to
: msvcrt.dll. I'm not sure if this is a linking problem or a
: loading problem or something else.
:
: I do know that I do not have this problem when building with
: alink and OMF files.
Yeah, I've seen something like that in recent past about 4 months
ago. I'll have to let someone else comment on that though.
There are some issues with compiling to the -f win32. I played
with that a few months ago trying to get dumpbin.exe (comes with
MS VC6 aka MS VC98) to show the imports and exports properly and
I ran into some issues. Unfortunately I didn't document it in a
public place, but I think it's on my laptop (packed away at the
moment). I did get dumpbin.exe /IMPORTS to work. I learned that
dumpbin.exe actually calls LINK.EXE (or perhaps vice versa) to
present the requested information.
LINK0098.EXE /DUMP /?
That's the VC6 (aka VC98) linker. It presents the following:
Microsoft (R) COFF Binary File Dumper Version 5.12.8181
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
usage: DUMPBIN [options] [files]
options:
/ALL
/ARCH
/ARCHIVEMEMBERS
/DEPENDENTS
/DIRECTIVES
/DISASM
/EXPORTS
/FPO
/HEADERS
/IMPORTS
/LINENUMBERS
/LINKERMEMBER[:{1|2}]
/LOADCONFIG
/OUT:filename
/PDATA
/RAWDATA[:{NONE|BYTES|SHORTS|LONGS}[,#]]
/RELOCATIONS
/SECTION:name
/SUMMARY
/SYMBOLS
The /IMPORTS and /EXPORTS are the two switches that help with
win32 files.
: Here's another example. This example results in this error
: being set upon loading:
:
: ERROR_ENVVAR_NOT_FOUND (000000CB)
:
: And this happens every time. Check out the value of eax after
: GetLastError is called. This could just be an issue with MS's
: loader on xp.
:
<code file="atext.asm">
;nasm -f win32 atext.asm
;golink /console atext.obj kernel32.dll user32.dll msvcrt.dll
extern printf
extern ExitProcess
extern GetLastError
section .text text CLASS=TEXT
global start
start:
call [GetLastError]
push dword sText
call printf
add esp, 4
push dword 0
call [ExitProcess]
section .data data CLASS=DATA
sText dd "Test", 0
</code>
:
: Any ideas? Can you reproduce my error on your machines?
:
Did you get the other file to compile and run? I'll take a
look at this later in the evening. I've got some other things
to work out right at the moment.
--
JC
Roses For The Guiness Book Of World Records?
www.associatedcontent.com/article/393251/growing_roses_in_saint_petersburg_fl.html
.
- Follow-Ups:
- Re: Problem Linking (win32)
- From: bwaichu@xxxxxxxxx
- Re: Problem Linking (win32)
- 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
- Problem Linking (win32)
- Prev by Date: Re: Atomic operations in 32 and 64 bit platforms
- 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
|