4 ms·
It's even more interesting when you consider that it ran under MS-DOS, which had no dynamic linking --- it's a statically linked binary. The touch command unde
by userbinator 7y ago
It's even more interesting when you consider that it ran under MS-DOS, which had no dynamic linking --- it's a statically linked binary.
The touch command under OS X Lion (44,016 bytes).
...and I bet that one is dynamically linked.
I believe the reason why it's so fast is because it has no optimiser, and generates code as it parses. Pascal is also one of the easier languages to compile.
- zozbot234 7y agoTurbo Pascal programs relied on separate on-disk .BGI files that contained object code and effectively implemented a kind of dynamic linking (albeit in a single-task context). It was possible to directly link them into the final executable, but this wasn't the default.
- pcardoso 7y agoPerhaps they were .TPUs instead of BGI? BGIs were the graphic drivers IIRC.
- dragonwriter 7y agoTPUs are closer than BGIs, but still aren't dynamically linked. They are object files which are statically linked into the final exe. It's possible that the author is thinking of pre-TP4.0 chain files (which were used to get around the 64K memory limit of .COM format before TP switched to generating EXEs.)
- api 7y agoWhat is all the weight in that "touch" binary? It can't be code. My guess would be that the format is just not optimized for size and contains a bunch of boilerplate records whose minimum size is in the kilobytes.
- haberman 7y agoI just ran Bloaty (https://github.com/google/bloaty https://github.com/google/bloaty) on /usr/bin/touch from Catalina, and I got this: $ bloaty `which touch` -d segments,sections --domain=file FILE SIZE --------------- 55.1% 19.6Ki __LINKEDIT 91.7% 18.0Ki Code Signature 2.7% 544 Symbol Table 1.9% 376 Lazy Binding Info 1.6% 328 String Table 1.2% 232 Indirect Symbol Table 0.6% 112 Binding Info 0.2% 32 Export Info 0.1% 24 Function Start Addresses 0.0% 8 Rebase Info 0.0% 8 Table of Non-instructions 0.0% 0 [__LINKEDIT] 22.2% 7.90Ki __TEXT 35.0% 2.77Ki __TEXT,__text 33.6% 2.65Ki [__TEXT] 17.2% 1.36Ki [Mach-O Headers] 4.2% 339 __TEXT,__cstring 3.4% 274 __TEXT,__const 3.3% 266 __TEXT,__stub_helper 1.9% 150 __TEXT,__stubs 1.5% 120 __TEXT,__unwind_info 11.2% 4.00Ki __DATA 94.9% 3.80Ki [__DATA] 4.9% 200 __DATA,__la_symbol_ptr 0.2% 8 __DATA,__data 11.2% 4.00Ki __DATA_CONST 98.4% 3.94Ki [__DATA_CONST] 1.6% 64 __DATA_CONST,__got 0.3% 104 [Mach-O Headers] 100.0% 35.6Ki TOTAL So 2.77Ki of actual code in "__TEXT,__text". Those [__TEXT], [__DATA], and [__DATA_CONST] sections are the part that is lost to padding, so 10.4Ki or so. Disclosure: I am the author of Bloaty.
- ken 7y agoHere is touch.c [1] from macOS. The only change since Lion is the addition of the __used attribute on a couple of consts at the beginning. It's very similar to the FreeBSD one, though they've diverged slightly in the past 2 decades. It supports 8 different flags (plus an undocumented -? flag), with support for using absolute or relative times, setting various timestamps on a file, and options for dealing with symlinks and permissions and such. More features than I'll ever need, but not outrageously so. On Mojave, this file is only 23392 bytes, so it's no longer bigger than Turbo Pascal. Plus, automatic filesystem compression shrinks this down to only 7340 bytes on disk. Since blocks are 4096 bytes, this is actually the second-smallest (non-empty) file! [1]: https://opensource.apple.com/source/file_cmds/file_cmds-287.40.2/touch/touch.c.auto.html https://opensource.apple.com/source/file_cmds/file_cmds-287....
- ksherlock 7y ago'?' isn't an undocumented flag; that's the getopt() return value to indicate a bad option or a missing argument.
- FpUser 7y agoIt did have overlays that were relatives of dll