Creating Teensy ELF Executables for Linux (Or, "Size Is Everything") (1999)

87 pointsposted 7 days ago
by Bluestein

22 Comments

BruceEel

3 days ago

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 :)

inigyou

2 days ago

There are no relevant security concerns, but they may require page alignment for efficient mapping.

davidwritesbugs

3 days ago

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?

dwattttt

3 days ago

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.

radicaldreamer

3 days ago

First experience with proper ELFs was using PS2 Linux ELFs to run homebrew and games and get past Sony’s restrictions

sylware

2 days ago

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).

Retr0id

2 days ago

> ELF for executables and dynamic libs is obsolete on modern hardware (same for microsoft PE+)

This is... extremely not true?

BruceEel

2 days ago

> 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.

inigyou

2 days ago

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.

Panzerschrek

3 days ago

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.

qsera

3 days ago

Lot of useful info here! Good work!

user

3 days ago

[deleted]