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 :)
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.
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).
Discussed here a couple months ago: https://news.ycombinator.com/item?id=48654411
Part 3: https://www.muppetlabs.com/~breadbox/software/tiny/somewhat....
reply