Hacker News

The Teensy Executable Revisited

59 points by ankitg12 ago | 6 comments

AdamH12113 |next [-]

I didn't know there was a sequel! Looks like there's also a part 3 that covers teensy dynamic linking:

https://www.muppetlabs.com/~breadbox/software/tiny/somewhat....

benj111 |root |parent [-]

[flagged]

inigyou |next |previous [-]

System calls on Linux are stable ABI. They have to be, because you can statically link libc. This is different from Windows.

Joker_vD |root |parent [-]

I can (in fact, must when using MSVC) statically link kernel32.lib on Windows as well. It's not a C runtime/standard library, of course, but who ties their OS's user-level API to a particular implementation of a standard library of some random programming language anyhow?

inigyou |root |parent [-]

kernel32.lib is an "import library" for kernel32.dll. This is a windows toolchain concept. The import library contains the placeholder references to the DLL loaded at runtime.

If you actually statically linked kernel32.dll somehow it'll break on future windows versions. kernel32 doesn't contain any syscalls anyway since they're all in ntdll.

Joker_vD |previous [-]

I don't think a file can actually take less than 4 KiB of disk space on most popular file systems. Can it?

dspillett |root |parent [-]

Some have methods for reducing the effect of small files.

NTFS stores small files (how small depends on the amount of metadata associated with them, technically up to approximately 1KB but the limit could be <700 bytes).

Depending on options at filesystem creation time, ext4 can store small files inline in the file's inode (up to 128 bytes by default IIRC, again less depending on the presence of extra metadata, more if you have inodes larger than the default 256bytes).

Some filesystem (ZFS for one) support block sub-allocation for small files. Tail packing is available in some filesystems which not only affects small files but larger files that are just a little over a multiple of the current blocksize in length (heuristics are commonly used to determine if this is a good idea rather than applying it to all files, as it can lead to notable latency due to fragmentation on traditional storage (less so with solid-state storage)).