Oh-no! Not this!
I'm doing almost everything on base of this import mechanism...
OK, I did some first "investigations" on this topic. Frank, you are completey right, I've to take the -fwin32 option on nasm.exe to have an object file being accepted as such by ld. Trying to link, say the well known HelloWord program using this "tricky" printf function from crtdll.dll, by something like this
ld --format="pe-i386" --entry="HelloWorld" --strip-all --output="HelloWorld.exe" --library-path="<where they are>" --library=crtdll.lib HelloWorld.obj
my favourite problem arises:
HelloWorld.obj:HelloWorld.asm:(.text+0x7): undefined reference to `printf'
But: in crtdll.lib as well as in the crtdll.dll there *is* defined the symbol 'printf' - no "_printf" or even a "@4" or whatever decoration - simply 'printf' (and for sure also the __imp__printf). And with my -fobj + alink solution it works both ways
1. by symbol: extern printf and calling as [printf]
2. by table : import printf and calling as printf
I preferred the 2nd because this way I've no dependency on an annoying "crtdll.lib" or any other lib, which from my experience often are incomplete and generate problems, only - as you can see above ;-)
I struggled around here with "_" and decorations, various syntax variations of the ld command above etc. I tried with kernel32.dll functions instead of crtdll.dll and so forth... no success yet :-(
For the moment, I've to focus on some other projects and will follow up this thread later, again.
So, many thanks for now,