Linking with MSVCRT.DLL versus the newer CRT DLLS

Started by GregL, August 31, 2008, 09:26:04 PM

Previous topic - Next topic

Vortex

Further optimization by removing crt0.lib :


cl /c /Oty2 /Zl /Gs /GS- /FoHello.obj Hello.c
\masm32\bin\polink /SUBSYSTEM:CONSOLE /NODEFAULTLIB /LIBPATH:\masm32\lib /MERGE:.data=.text /MERGE:.rdata=.text /ENTRY:main Hello.obj kernel32.lib msvcrt.lib

mitchi

My lightweight Visual build environment is complete.

You can set it like this :

Copy your VC include directory
Copy your VC bin directory
Install the VC 2005 redistributable package
http://www.microsoft.com/downloads/details.aspx?FamilyId=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&displaylang=en
Install the VC 2008 redistributable package
http://www.microsoft.com/downloads/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&displaylang=en
Install the mspdb80.dll to your BIN folder or system32

The total size is 33 meg and it could be shrinked even more if we remove things from the BIN directory.
It looks like this



And the batch file is


SET PATH=C:\dev-env\bin
SET INCLUDE=C:\dev-env\include

cl /c /Oty2 /Zl /Gs /GS- /FoHello.obj Hello.c
C:\masm32\bin\polink /SUBSYSTEM:CONSOLE /NODEFAULTLIB /LIBPATH:C:\masm32\lib /MERGE:.data=.text /MERGE:.rdata=.text Hello.obj crt0.lib kernel32.lib msvcrt.lib













mitchi

Just an update on this. I've add a few problems in the past because of some linker error about a security cookie.
Well, I just found out what it is.
http://support.microsoft.com/?scid=kb;en-us;894573&x=7&y=18

It's basically a anti-buffer overflow runtime check. If you build your code from Visual Studio, it's always enabled and the option is hard to find.
If you disable it, you can link to MSVCRT.DLL perfectly and statically link your C modules with Assembly.



Manos

Quote from: hutch-- on September 01, 2008, 04:25:28 AM
Interesting read. Now I know why I write assembler and from time to time build a little C directly in C without a great gaggle of runtimes. The only thint I have seen the numbered vcrt DLLs perform is to break the backwards compatibility so the app will not run on an older version of Windows. I do see the old format mxvcrt.dll as a useful standard but I am very wary of the gaggle of new stuff around as it seems to be all over the place.

I think that MSVCRT.DLL is running always.
If it is true, why do not use this in assembly projects ?

Manos.

KeepingRealBusy

One thing I recently found out - MASM 9.0 does not support the /GS option - no more generated code (for INVOKE, PROLOG, or EPILOG) listed on the .lst file.

Dave.