Given: prog.c with an entry point prog
I normally do
cl.exe /MD /LD /Fe"prog.dll" /Fo"prog" "prog.c" /link ext.lib
or
cl.exe /MD /Fo"prog.obj"
cl.exe /MD /LD /Fe"prog.dll" "prog.obj" /link ext.lib
in both cases the resulting prog.dll works fine.
Now I did the following to get an asm file instead of the obj file:
cl.exe /c /MD /Fa"prog"
This "works" so far, too. But I cannot figure out how to make a dll of this file.
Tried:
ml.exe /c /Cx /coff prog.asm
cl.exe /MD /LD /Fe"prog.dll" "prog.obj" /link ext.lib
Result: prog.dll without entry point prog
Tried again:
ml.exe /c /Cx /coff prog.asm
cl.exe /MD /LD /Fe"prog.dll" "prog.obj" /link /entry:prog ext.lib
Result: compiler warning about wrong entry point _prog not being stdcall with 12 byte arguments and a compiler error about unresolved symbol _memcpy.
Question: Is there any way to compile the asm file which cl.exe generates by /Fa to a dll (preferably via cl.exe, if not possible with ml.exe)?
Is there any way to compile the asm file which cl.exe generates by
/Fa
to a dll (preferably via cl.exe, if not possible with ml.exe)?
No:
It is very unclear to me why you are even wanting to do this in the first place. If your source code is either C or C++, and can be compiled and linked by MSVC, then what is the point of introducing the additional intermediate step of converting it to and from assembly language? Just use cl.exe directly to make a DLL.
If you absolutely must do this, you will have to take the ASM listing file generated by MSVC and manually clean it up before running it through MASM. You can make this clean-up task easier by turning off whole program optimization, turning off exception handling, turning off security checks/cookies, and indicating to the linker that the image does not contain safe SEH handlers. Note that some of these may break or change the behavior of your code! You'll also need to add EXTERN
definitions for functions that you call from runtime libraries.