It can definitely be explained! For instant your tiny ELF tutorial is currently missing any explanation at all - it says what you're trying to do, and a dump of code to do it, and a demo of it working but nothing about why it works.
But it's easy to add. From skimming the code I think the explanation should be something like this:
All four operating systems support the ELF executable format, and we're using the same x86 hardware in all four cases. When you compile a function like `int fib(...` the exact same x86 instructions end up running on all OSes. So why doesn't a Linux binary run out of the box on OpenBSD?
There are a few reasons.
First, the ELF format itself requires us to specify the OS ABI (conventions for how to functions at a binary/register level). Fortunately we can get around this by just setting it to the FreeBSD ABI because (insert explanation here).
There are a few other minor differences in how the OSes interpret ELF fields, like (insert explanation here) But they are broadly compatible and the following ELF header will allow us to start executing x86 instructions on all four OSes.
At that point we can run our `fib()` code and it will work! But the second issue occurs when we actually want to print the result.
The print a string on all four OSes you can use their `write()` syscalls to tell the kernel to write a string to stdout (file descriptor 1 on all the OSes).
Unfortunately although they all have the same ABI for making syscalls (maybe this is standard on x86??) they gave the write syscall different ID numbers - on Linux it is 1, but on the BSDs it is 4. If we were to try to execute Linux's `write()` on BSD it would actually call `exit()` - not what we want!
So we need some way of detecting the OS at runtime. There are probably many ways to do this but I have done it by detecting differences in how the OSes set up the registers and program arguments before calling `start()`. Specifically... (insert explanation here).
Totally doable! I'm sure some of that is wrong, but hopefully you get the point.
It definitely is harder to explain something when you are an expert on it, but it's still possible. Probably the best way to do it is to work with someone who is interested but doesn't understand it and then they'll ask questions that you assumed they new the answer to.
Anyway I'm not saying you need do this - it does take some time. I just wanted to impart that it could be explained if you wanted to.