News for hackers. Stuff that matters.
Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by BruceEel on Sunday August 30, 2026 @01:34AM (#49495978)
This is actually a lot of fun. Never did it on Linux, but Windows PE EXE files make similar tricks possible. Windows 95 in particular was very permissive. Using a (very primitive, by today's standards) hex editor I tried making the ".text" section begin halfway through the header and bang! ..it worked, a revelation of sorts. I imagine today's loaders may be a bit more strict because of security but I guess you can always make your own loader :)
Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by inigyou on Sunday August 30, 2026 @01:11PM (#49500576)
There are no relevant security concerns, but they may require page alignment for efficient mapping.
Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by Panzerschrek on Sunday August 30, 2026 @01:39AM (#49495999)
The program described in this article is as simple as possible. What about something more complex, like basic "hello world"? It requires at least one more syscall and several bytes more data.
Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by stevekemp on Sunday August 30, 2026 @03:32AM (#49496520)
Take a look at the collections by the same author:

https://www.muppetlabs.com/~breadbox/software/tiny/home.html

There are some more complete programs there.

Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by Retr0id on Sunday August 30, 2026 @08:46AM (#49498184)
My approach to crafting "small" ELFs (in the hundreds-of-bytes range, written in relatively normal C) is like so: https://github.com/DavidBuchanan314/kurl/blob/main/golfed/el...
Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by davidwritesbugs on Sunday August 30, 2026 @01:47AM (#49496031)
I wonder how much of this could be done by a clever linker? There’s a lot of skill in there but how would an llm do, for the rest of us?
Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by dwattttt on Sunday August 30, 2026 @05:42AM (#49497150)
A linker could do this, but "clever" isn't the adjective I'd use when something randomly breaks due to it not working to standard.
Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by mrlonglong on Sunday August 30, 2026 @02:42AM (#49496250)
i386 are perhaps starting to die out. Has anything like this been done for amd64? Can we play such tricks with arm and aarch64?
Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by enoent on Sunday August 30, 2026 @03:31AM (#49496518)
84 byte aarch64 ELF: https://tmpout.sh/2/14.html
Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by Retr0id on Sunday August 30, 2026 @08:45AM (#49498177)
57 byte x86-64 ELF https://tmpout.sh/5/3.html
Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by 1001111 on Sunday August 30, 2026 @10:17AM (#49498887)
4 byte x86 .mut ELF https://tmpout.sh/4/13.html
Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by mrlonglong on Sunday August 30, 2026 @04:38PM (#49502531)
Fantastic, well done you lot.
Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by WalterGR on Sunday August 30, 2026 @02:47AM (#49496273)
Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by qsera on Sunday August 30, 2026 @02:50AM (#49496288)
Lot of useful info here! Good work!
Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by radicaldreamer on Sunday August 30, 2026 @03:48AM (#49496608)
First experience with proper ELFs was using PS2 Linux ELFs to run homebrew and games and get past Sony’s restrictions
Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by guenthert on Sunday August 30, 2026 @04:14AM (#49496734)
Oh, ELF file manipulation. I thought this would be about getting Linux to run on a Teensy.

https://forum.pjrc.com/index.php?threads/linux-on-teensy-4-x...

Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by sylware on Sunday August 30, 2026 @07:45AM (#49497845)
This is the wrong end of the issue. ELF for executables and dynamic libs is obsolete on modern hardware (same for microsoft PE+).

I am now using for most of my projects a exe/dynamic lib format of my own. This file format is so miminal a simple RFC will suffice. BUT, I will need to build dynamic libs which are system interfaces (for instance userland drivers like mesa) with this file format: problem, c++ and its runtime (and probably other similar languages with their runtimes)... as usual...

Well, I am still removing stuff from my file format, because I think this is not yet "minimal and enough" on modern hardware architecture (I think I have still too much complexity in the tracker of loaded dynamic libs).

Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by Retr0id on Sunday August 30, 2026 @08:48AM (#49498194)
> ELF for executables and dynamic libs is obsolete on modern hardware (same for microsoft PE+)

This is... extremely not true?

Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by sylware on Tuesday September 08, 2026 @07:29AM (#49608829)
Then you are of extremely bad faith?

come on...

Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by BruceEel on Sunday August 30, 2026 @10:33AM (#49499021)
> I am now using for most of my projects a exe/dynamic lib format of my own. This file format is so miminal a simple RFC will suffice.

That's great! Have you published it? If not, please consider doing so.

Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by sylware on Wednesday September 02, 2026 @05:58AM (#49534108)
Well, everything is open source, I have a partial and very limited (but currently enough for my needs) linker for x86_64 and RISC-V 64bits (but written in plain and simple C which compiles with tinycc and cproc/qbe!).

I even have an ELF capsule for executables (for x86_64, written in assembly).

So it is out there, but not "tidy" (aka a wip messy tarball), as I said, I am not sorta sure about how to handle the in-process loader, which is beyond simple, but I still believe I can make it even simpler (yeah, not more gigantic external "interpreter"/"loader).

Once I am satisfied, I'll ship that to a nicely tidied GIT repo (but with support of noscript/basic HTML browsers, unlike ... you know which ones...).

Re:Creating Teensy ELF Executables for Linux (Or, "Size Is E... by inigyou on Sunday August 30, 2026 @01:09PM (#49500551)
if you want to do this yourself, definitely read the actual Linux ELF loader linux/fs/binfmt_elf.c instead of making guesses based on the specification. Because it's open source, you can do this.