News for hackers. Stuff that matters.
Re:What's in a Linux Executable? by PrinceKropotkin on Thursday October 29, 2020 @12:47AM (#24927333)
Why does linux only support ELF?

Other executable formats, for instance, support multiple architectures per file. Why does Linux not?

Re:What's in a Linux Executable? by pdmccormick on Thursday October 29, 2020 @01:42AM (#24927631)
The Linux kernel actually does allow executing non-ELF executables, via the binfmt_misc (https://en.wikipedia.org/wiki/Binfmt_misc) mechanism.

My favourite use for this feature is via `qemu-user-static`, which allows you to transparently "run" executables compiled for other architectures thanks to QEMU emulation. Very handy for embedded systems development.

Re:What's in a Linux Executable? by pjmlp on Thursday October 29, 2020 @08:32AM (#24929782)
I remember some people using this to launch java applications.
Re:What's in a Linux Executable? by JoshTriplett on Thursday October 29, 2020 @01:49AM (#24927658)
For one thing, lack of demand. Linux distributions can relatively easily ship different packages for different architectures, and doing so is more space-efficient. It seems to me like shipping multiple binaries within a package is mostly useful for the distribution of proprietary software, and even in that case, it isn't that hard to ship two binaries and a shell script.
Re:What's in a Linux Executable? by moonchild on Thursday October 29, 2020 @02:28AM (#24927861)
That's a function of your runtime dynamic linker, which is most likely provided by glibc (on linux). I believe it supports a.out still; at the very least, it used to.
Re:What's in a Linux Executable? by bregma on Thursday October 29, 2020 @06:54AM (#24929131)
Nope. It's a function of the kernel, which needs to know the binary format in order to load the executable. The dynamic linker is invoked at a later phase of execution, and in the case of the ELF file it does that by reading the dynamic linker's name from the PT_INTERP entry in the Dynamic table stored in the PT_DYNAMIC segment. By default, if the kernel doesn't recognize the ELF magic (first 4 bytes in the file are `\0x7fELF`), or can't load the dynamic linker specified in the PT_INTERP entry (eg. wrong architecture), it will launch /bin/sh as the interpreter and feed the loaded file to it assuming it's a text file containing a shell script.

If the kernel has the bin_fmt mod loaded, it can also recognize other binary formats before falling back to /bin/sh.

Re:What's in a Linux Executable? by pjc50 on Thursday October 29, 2020 @06:37AM (#24929016)
https://www.phoronix.com/scan.php?page=news_item&px=Linux-Dr... : >20 years after obsoleting it, it's being dropped. Longer than I would expect!
Re:What's in a Linux Executable? by bregma on Thursday October 29, 2020 @06:45AM (#24929082)
You can only ever run software for one architecture on a single machine, why pay for getting stuff you can't use?
Re:What's in a Linux Executable? by saagarjha on Thursday October 29, 2020 @01:41AM (#24927621)
It seems like you’re really asking two questions. My comment for the first one is that you can use binfmt_misc to add your own executable formats. For the second one, is there anything other than Mach-O that does that?