Jump to page: 1 2 3
Thread overview
438-byte "Hello, world" Win32 EXE in D
Sep 07, 2014
Vladimir Panteleev
Sep 07, 2014
deadalnix
Sep 08, 2014
Andrej Mitrovic
Sep 08, 2014
eles
Sep 08, 2014
Kagamin
Sep 08, 2014
Kagamin
Sep 09, 2014
Don
Sep 10, 2014
Marco Leise
Sep 10, 2014
ketmar
Sep 11, 2014
Don
Sep 08, 2014
ponce
Sep 08, 2014
Vladimir Panteleev
Sep 09, 2014
Trass3r
Sep 20, 2014
Vladimir Panteleev
Sep 15, 2014
dcrepid
Sep 16, 2014
Vladimir Panteleev
Sep 16, 2014
dcrepid
Sep 17, 2014
Vladimir Panteleev
Sep 18, 2014
dcrepid
Sep 18, 2014
Vladimir Panteleev
Aug 12, 2015
Georgy Shepelev
September 07, 2014
I've picked up an older project for using D on barebones Win32 as a "better C".

Thanks to recent advances in DMD (-betterC and -m32mscoff), I could get a "Hello, world" program on Win32 down to just 438 bytes when compiled. This is without assembly, linker scripts, custom Phobos/Druntime, or manual post-build tweaks.

-betterC allows stripping things like ModuleInfo, and as of recently it also strips file/module names used for asserts/range check errors (which were emitted even in -release mode). A better alternative would be a DMD equivalent to -fdata-sections, though, so unneeded variables, constants, and data generated by the compiler could be garbage-collected by the linker.

-m32mscoff allows using more linkers. Specifically, the Microsoft Linker and Crinkler, which only understand COFF, can both generate executables which are much smaller than those created by OPTLINK.

The 438-byte "Hello, world" program is achieved using Crinkler, which is a COFF linker with aggressive compression and header optimization. It was created for compressing 4K demos.

Without compression on header optimization, you can reach 630 bytes using Unilink, a freeware linker which is compatible with both COFF and OMF.

The source code is not much to look at, most of the "magic" is in the makefiles:

https://github.com/CyberShadow/SlimD

See samples/01-msgbox for more commentary. The figures above are for samples/02-console.

The motivation for this project is mostly hack value and aesthetical (a 500 KB EXE with 5 KB worth of actual functionality is not pretty).
September 07, 2014
One step down that road: https://www.youtube.com/watch?v=RCh3Q08HMfs&list=PLA5E2FF8E143DA58C
September 08, 2014
On 9/7/14, 2:03 PM, Vladimir Panteleev wrote:
> I've picked up an older project for using D on barebones Win32 as a
> "better C".
>
> Thanks to recent advances in DMD (-betterC and -m32mscoff), I could get
> a "Hello, world" program on Win32 down to just 438 bytes when compiled.
> This is without assembly, linker scripts, custom Phobos/Druntime, or
> manual post-build tweaks.

Awesome. Blog post -> reddit -> win. -- Andrei

September 08, 2014
On Sunday, 7 September 2014 at 21:03:17 UTC, Vladimir Panteleev wrote:
> I've picked up an older project for using D on barebones Win32 as a "better C".
>
> Thanks to recent advances in DMD (-betterC and -m32mscoff), I could get a "Hello, world" program on Win32 down to just 438 bytes when compiled. This is without assembly, linker scripts, custom Phobos/Druntime, or manual post-build tweaks.

YES.

That's what I expect to be possible with a systems programming language!

Very pleasing to see that it is also possible with D, so D seems to be really a systems programming language :-)
September 08, 2014
On 9/7/14, Vladimir Panteleev via Digitalmars-d-announce <digitalmars-d-announce@puremagic.com> wrote:
> Thanks to recent advances in DMD (-betterC and -m32mscoff), I could get a "Hello, world" program on Win32 down to just 438 bytes when compiled. This is without assembly, linker scripts, custom Phobos/Druntime, or manual post-build tweaks.

I guess this is great news for virus writers. :P

And, I guess scene devs. ^^
September 08, 2014
On Monday, 8 September 2014 at 07:01:19 UTC, Andrej Mitrovic via Digitalmars-d-announce wrote:
> On 9/7/14, Vladimir Panteleev via Digitalmars-d-announce
> <digitalmars-d-announce@puremagic.com> wrote:

> I guess this is great news for virus writers. :P

A std.virus or core.virus module? ;;)
Nothing sweeter than having it as a standard...
September 08, 2014
On Sunday, 7 September 2014 at 21:03:17 UTC, Vladimir Panteleev wrote:
>
> The 438-byte "Hello, world" program is achieved using Crinkler, which is a COFF linker with aggressive compression and header optimization. It was created for compressing 4K demos.
>

Pretty cool! Up to now D had little chance to compete in 4k and 64k demo competitions because of the inability to use Crinkler.
September 08, 2014
On Monday, 8 September 2014 at 07:01:19 UTC, Andrej Mitrovic via Digitalmars-d-announce wrote:
> I guess this is great news for virus writers. :P

Why? Modern viruses are bloatware: https://www.virustotal.com/en/file/73559b15d1f55a9f08a5674fd4320a7ba9ff4e98f0949a1b2a756ec8eafd5caf/analysis/
September 08, 2014
On Monday, 8 September 2014 at 07:40:29 UTC, Kagamin wrote:
> Why? Modern viruses are bloatware: https://www.virustotal.com/en/file/73559b15d1f55a9f08a5674fd4320a7ba9ff4e98f0949a1b2a756ec8eafd5caf/analysis/

That sucks.

«Smallest PE file that downloads a file over WebDAV and executes it: 133 bytes»

http://www.phreedom.org/research/tinype/
September 08, 2014
On Sunday, 7 September 2014 at 21:03:17 UTC, Vladimir Panteleev wrote:
> The 438-byte "Hello, world" program is achieved using Crinkler, which is a COFF linker with aggressive compression and header optimization. It was created for compressing 4K demos.

Pretty nice! Is the format correct too, or can it break on OS upgrades?

« First   ‹ Prev
1 2 3