A programming language that makes the smallest executables?

I am looking for a programming language that generates the smallest .exe files.

It also should not have dependencies other than DLLs that are included in the package and are common for the following OSs: release Windows XP, Vista, 7 and 8. for example. C ++ application with static link, Delphi, VB6, RealBasic, etc.

It should also work on all 32-bit and 64-bit Intel + AMD processors released after 2000 with only one EXE.

-3
source share
3 answers

assembler! He cannot be less than this.

+4
source

You will not find the answer to this question. C and assembly will provide you with some of the smallest executables you can find, but they can also provide you with huge executables if you are not careful.

All modern compilers make highly efficient executables.

Do not worry about it. Choose a language that makes your work easier.

+2
source

This is determined by the specific build tools (compiler and linker) that you use, as well as the configuration and content, and not the language itself.

Visual C ++ 2010 can generate small executables if you use simple C and exclude the C runtime library.

If you need to use the C runtime library, you may need to use Visual C ++ 6 (flaw: out of support) or mingw (flaw: generates executable files that are not technically supported), both of which use the runtime library that is built into Windows XP and later.

The executable file size for Visual C ++ 2010 without a runtime library is 1K for up to 512 bytes of code and initialized data. This is just a working Windows executable, because there must be at least one partition, and the minimum offset and size of the partition is 512 bytes.

In general, the size of the executable file will be 512 bytes of service data plus the size of the code and initialized data, rounded to a few bytes per 512 bytes.

To exclude the runtime library in Visual Studio 2010, set the “Ignore all default libraries” option to “Yes” in the “Attachments” → “Enter” section and set the entry point (for example, “NoCRTMain”) in Linker-> Advanced. Signature of the main function in this configuration

void __stdcall NoCRTMain() 

You may also need to set the "Buffer Security Check" to "No" in the C / C ++ → Generation Code section. The buffer security check function uses the library runtime function.

At this point, if you have less than 512 bytes of code and persistent data, the executable will be 3 KB or 3.5 KB if you initialized volatile data.

You can save another 512 bytes, not including the manifest (Linker-> Manifest File).

You can save another 512 bytes by making the image non-moving. Set “Randomized Base Address” to “No” and “Fixed Base Address” to “Yes” in Linker-> Advanced.

To get a value up to 1K, you need to combine code data, constant data, and initialized data sections. To do this, add additional command line options to Linker-> Command Line:

  /SECTION:.text,ERW /MERGE:".rdata=.text" /MERGE:".data=.text" 

For security reasons, you may not combine the initialized data partitions; this partially disables Data Execution Protection (DEP). If yes, just use

  /MERGE:".rdata=.text" 

or set the equivalent option in Linker-> Advanced.

If you did not merge all partitions, you can save another 512 bytes by replacing the default MS-DOS stub with a smaller one, reducing the overall size of the header so that it matches the minimum alignment size by 512 bytes. This can be done by adding the command line option / STUB (Linker-> Command Line) and using the minimum stub available here . If you prefer, you can create your own minimal stub by extracting the first 64 bytes of any Windows executable.

+2
source

Source: https://habr.com/ru/post/1263777/


All Articles