Minimum Sized C/C++ applications

Started by Twister, February 01, 2011, 01:24:17 AM

Previous topic - Next topic

Antariy

Quote from: japheth on February 01, 2011, 08:02:04 AM
Quote from: Antariy on February 01, 2011, 07:50:48 AM
MemInfoMicro smaller that 1024 bytes ...

1. Another contest of "Who has the smallest ....?"  :bg

2. I can't compete, so I won't participate  :snooty:

3. It's also the wrong focus, because who cares nowadays about super-small sizes. All you are likely to get with such binaries are problems with various anti-virus software.

4. The true issues with PB are:
- no support for an object format. You're stuck in the little PB world.
- you have to buy 2 compilers to get the full functionality.

Quote
P.S. I'm fan of PB, too, you know this :bg

5. I like toys, that's why I'm also a fan.

1. That's not contest for me :bg - I just made it as powerful remake of thing included into examples of MASM32 package :bg
That's reason for "The Return" :bg

2. It is interesting anyway to know what peoples are think about it. Still, I've not see anything interest to it. Or too small interest.

3. I've uploaded it to virustotal, and only 7 antiviruses from ~40 (do not remember exact count) get it "suspect" - that was a crappy ones who think that anything advanced file format is a virus. All the commercial powerful AVs do not said anything. Norton said "strage stuff" - or similar, but not a virus. All others (KAV, MS's AV etc etc etc) said it is OK :bg
As about small size... Well, I'm care about it :bg

4. Also it generated some garbage, too. For example ~99 bytes of unusable code at start of file (401000h) - that code required for debugging build only, but included into anything build with no reason.
Also relocations for standard base adrress is strage stuff to do.

5. Yes, it is very convenient for fast writing of useful tools :U

TmX

Quote from: Antariy on February 01, 2011, 03:21:39 AM
751 bytes C++ proggie. Without "dirty" tricks!!!

MSVC10 compiler. Should work on ALL Windows versions - msvcrt independed.


How do you build it?
Care to share the batch script?


Antariy

Quote from: TmX on February 01, 2011, 11:17:32 AM
Quote from: Antariy on February 01, 2011, 03:21:39 AM
751 bytes C++ proggie. Without "dirty" tricks!!!

MSVC10 compiler. Should work on ALL Windows versions - msvcrt independed.


How do you build it?
Care to share the batch script?

Have a look into Horton's posts, things like:

#pragma comment(linker, "/MERGE:.rdata=.text")

are switches used to linker. I'm prefer to not specify them in the source file itself, because MSVC10 linker have some problems with long strings from this pragma.
But you still may specify these switches on the linker's command line:


LINK.EXE /MERGE:.rdata=.text /MERGE:.data=.text ...


to get small output file size (to 1 KB).

TmX

Quote from: Antariy on February 02, 2011, 02:05:00 AM
Have a look into Horton's posts, things like:

#pragma comment(linker, "/MERGE:.rdata=.text")

are switches used to linker. I'm prefer to not specify them in the source file itself, because MSVC10 linker have some problems with long strings from this pragma.
But you still may specify these switches on the linker's command line:


LINK.EXE /MERGE:.rdata=.text /MERGE:.data=.text ...


to get small output file size (to 1 KB).

like this?
Quote
cl /c cpptest.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cpptest.cpp

C:\Users\Andre\Desktop>link /MERGE:.rdata=.text /MERGE:.data=.text user32.lib cpptest.obj
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : warning LNK4254: section '.data' (C0000040) merged into '.text' (60000020) with differen
t attributes

Antariy

Quote from: TmX on February 02, 2011, 03:16:26 AM
like this?
Quote
cl /c cpptest.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cpptest.cpp

C:\Users\Andre\Desktop>link /MERGE:.rdata=.text /MERGE:.data=.text user32.lib cpptest.obj
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : warning LNK4254: section '.data' (C0000040) merged into '.text' (60000020) with differen
t attributes

Yes :bg
Also, specify /FIXED switch to a linker for EXEs, since you have using MSVC10, too.

dedndave

modern computers use cluster sizes of at least 8 Kb
anything less than that, and it's all the same - one cluster   :P

Antariy

Quote from: dedndave on February 04, 2011, 03:31:32 AM
modern computers use cluster sizes of at least 8 Kb
anything less than that, and it's all the same - one cluster   :P

Network bandwidth, network bandwidth :P