Author Topic: Problems with Alink  (Read 16765 times)

mark allyn

  • Guest
Problems with Alink
« on: August 26, 2009, 09:56:53 PM »
Hi everyone -

Just for fun I thought I'd give Alink a try.  Here's the source code:

%include "c:\MinGW\myincludes\asm_io.inc"
%include "c:\nasmx\inc\win32\windows.inc"

section .data

greet    db "This is hello from a program linked by ALink", 0
format   db "%s", 0

section .text
   global _main
   extern _printf
_main:
   enter 0,0
   push greet
   push format
   call _printf
   add esp, 8
   mov eax, 0
   leave
   ret

I'm assembling with the -f win32 switch set.  The code creates a nice object file.  However, using this command:

alink -oPE ALinkHello

results in a message saying that _printf is not resolved.  Just for fun, I threw in a -L switch to use the win32.lib that accompanies the alink distribution.  The more complex command line is
 alink -oPE ALinkHello -L c:\MinGW\Lib\WIN32.LIB

doesn't help.  Still get a message regarding unresolved external reference to _printf.

Now, as a matter of fact if I use GCC to do the linking instead, links and runs just ducky.
Ever eager to learn, I am hoping someone can give me a clue.

Regards,
Mark Allyn

Chaz Zeromus

  • Guest
Re: Problems with Alink
« Reply #1 on: August 26, 2009, 10:42:08 PM »
Um, printf isn't defined traditionally in win32, it's more of the POSIX specification.  But anyways its usually the common runtime library that handles those traditional I/O functions.  Try linking libcrtdll.a

mark allyn

  • Guest
Re: Problems with Alink
« Reply #2 on: August 27, 2009, 12:55:11 AM »
Hi Chaz-

I tried your suggestion.  No dice.  The distribution of MinGW I'm using has the archive file you mentioned.  But, when I try to link with -L , I still get the same results.

In addition, when I apply Ollydbg to other .exe files the usual symbol that shows up in _printf is &msvcrt.  So, I remain quite puzzled.

Haven't tried GoLink.  Would like to undestand the problems with ALink before I fool around with anything else.  You know how it is....

Thanks and if you can think of anything else, rest assured I will try it, and I will tell you what happened

Mark

mark allyn

  • Guest
Re: Problems with Alink
« Reply #3 on: August 27, 2009, 11:12:48 PM »
Chazzeromus:

Just to be clear about libcrtdll.a....what it does to me when I issue alink command :

alink -oPE ALinkHello.obj c:\MinGW\lib\libcrtdll.a

is to get part way thru the process in then kick out a windows message box that tells me that windows has encountered an error and has to terminate.  

I have also fooled around with Golink but that seems to have problems dealing with nasm win32 object files.  Doesn't like 'em.  Also, it doesn't like handling lib files.  Wants DLL's or exe's to link.

So.  I've spent a pretty useless day messing with Alink.  Would like to understand what is going on to cause it to crash.

Thanks,
Mark Allyn