Re:Evolution of the ELF object file format
by MaskRay on Sunday May 26, 2024 @07:48PM
(#40486361)
A few folks have asked me the generic ABI status (unmaintained?) and the available of an up-to-date specification (no). I compiled “History” and “Evolution of the generic ABI” in the blog post.
I have two specific questions:
- Key features (symbol visibility, section groups, SHF_MERGE, etc) were all available as of April 2001. Where can we find the discussion mailing lists? Are they still available?
- How does the ABI end up being “All rights reserved” by SCO?
Re:Evolution of the ELF object file format
by Joker_vD on Monday May 27, 2024 @08:58AM
(#40490322)
> How does the ABI end up being “All rights reserved” by SCO?
Text of the spec is copyrighted by the SCO, they did not put it in public domain. That's what "All rights reserved" was intended to mean even though this phrase has not been meaning anything since 2000.
Re:Evolution of the ELF object file format
by vintagedave on Monday May 27, 2024 @11:18AM
(#40491547)
It's concerning that a huge open source ecosystem like Linux depends on a closed specification. That is, I read it as that the spec cannot be continued, developed, and evolved or republished without full redefinition and respecification.
Has anyone looked at creating a new object format for Linux? A non-open spec seems a minor issue, really, in an era when we put binary blobs in the kernel (hi Nvidia.) But the more decades I work in closed source, the more I value open source, and believe keeping _everything_ open.
Re:Evolution of the ELF object file format
by yjftsjthsd-h on Monday May 27, 2024 @04:24PM
(#40494327)
I wouldn't think you'd need to create a new format, just write up a spec of what all available FOSS implementations are actually doing and agree that that's the standard going forward. Between Linux/*BSD/illumos you should be able to pretty completely describe all currently-active uses of ELF.
(Of course this assumes that doing this is sufficient to make it legally not derived from the original spec as far as copyright law cares about, which is beyond my non-lawyer ability to be that confident in.)
Re:Evolution of the ELF object file format
by skissane on Monday May 27, 2024 @07:45PM
(#40495896)
> Between Linux/*BSD/illumos you should be able to pretty completely describe all currently-active uses of ELF.
OpenVMS uses ELF too. Rather niche proprietary OS but still maintained and in production use. (Not a new thing with x86-64 port, ELF was adopted during the Alpha to Iranian transition.)
As do many RTOS (both open source and proprietary)
Re:Evolution of the ELF object file format
by yjftsjthsd-h on Monday May 27, 2024 @10:43PM
(#40496866)
Lol. Although, Itanium does have an entertaining history of having caused a lot of positive changes even though it crashed and burned itself - it's where we got UEFI, and apparently a good time for some OSs to pick up ELF.
Re:Evolution of the ELF object file format
by aseipp on Monday May 27, 2024 @05:10PM
(#40494748)
> Has anyone looked at creating a new object format for Linux?
No, because that's overkill for this problem, because the de facto standard is "What do modern free Unicies do", where those are basically Linux/BSD/Illumos. Besides, it's not unheard of in Unix history to have free implementations of proprietary standards, where those implementations became de facto standards anyway.
Even if it was a seriously pressing issue, writing a new specification that covers ELF as it exists today is going to be many, many, many times easier than introducing a new executable format across the ecosystem, they're not even in the same league or sport in terms of effort. If you were going to introduce a whole new object file format it would be much better to do it and justify it on the basis of fundamental technical/architectural changes.
Re:Evolution of the ELF object file format
by avar on Tuesday May 28, 2024 @08:53AM
(#40500257)
> It's concerning that a huge open source ecosystem like Linux depends on a closed specification.
Linux is written in C, whose spec is proprietary. The larger stack has countless ISO standard references etc., all of which refer to proprietary standards you need to buy.
Re:Evolution of the ELF object file format
by LegionMammal978 on Monday May 27, 2024 @11:11AM
(#40491479)
Yeah, it's not like they could copyright the ELF format anyway, only that particular description, or any particular implementation they had. Pretty much everyone seems to agree that file formats themselves aren't copyrightable expression, though I have trouble finding any U.S. case law to that effect.
(Personally, that makes me a bit uneasy: for instance, if the copyrighted spec lists the file sections in a certain order, and your implementation happens to output them in the same order even if it doesn't have to, then have you infringed on the owner's copyright of that particular arrangement?)
Meanwhile, they could have gotten a patent on (some parts of) the format, but that doesn't seem to be the case here.
Re:Evolution of the ELF object file format
by Veserv on Monday May 27, 2024 @02:53PM
(#40493498)
The rule in general (not just for software) is that patents are for functional elements where as copyrights are for non-functional elements; they are exclusive, a element can only be patentable or copyrightable, not both.
If it is necessary for operation or inter-operation [1] then they can probably not enforce copyright or trademark.
Re:Evolution of the ELF object file format
by LegionMammal978 on Monday May 27, 2024 @03:47PM
(#40493975)
Sure, but usually in any file format, an encoder has some choice in how to produce its output, with no functional difference either way. For instance, different PNG encoders might include the necessary chunks in a different order in the file. And my concern is that some such choices, if they align with choices described in the copyrighted spec, might be protectable as a creative arrangement or similar. (E.g., a spec might list the chunks in such an order that their names form a creative acronym.)
Of course, the defense against this would be to scramble (or normalize) all non-functional choices compared to anything in the spec. But you have to be careful to make sure there's nothing left of the spec's non-functional influence.
At least Oracle v. Google appears to provide some ammunition here in favor of implementers: the court found the transformative use in that case enough to trump even the byte-for-byte copying of the API signatures. So perhaps interoperability could similarly trump such non-functional copying from the spec. But overall, it's still on shakier ground than I'd like.
Re:Evolution of the ELF object file format
by MaskRay on Monday May 27, 2024 @03:45PM
(#40493944)
I feel that The SCO Group's role in the evolution of the System V ABI seems to have been more of a curator/editor than an innovator, inheriting the System V ABI from previous entities.
Given that the Tool Interface Standard (TIS) Committee has essentially released the ELF-related chapters into the public domain, and others have made changes,
it's unclear what specific rights The SCO Group (and now Xinuos) could claim to reserve.
(That said, their maintenance work needs to be remembered.)
Re:Evolution of the ELF object file format
by jcranmer on Monday May 27, 2024 @10:07AM
(#40490828)
One of the things I've been (very slowly) putting together is a master list of all the references one needs to build a compiler toolchain--such as processor ISA manuals, ABI specifications, language standards, even things like IEEE 754 or DWARF.
While IEEE 754 is an issue because it's not freely available for most people, the only document that has truly stumped me is the ELF specification. From your blog post, it seems like my failure to find the most up-to-date specification is simply because one doesn't exist.
Re:Evolution of the ELF object file format
by jcranmer on Monday May 27, 2024 @06:50PM
(#40495526)
The ELF format isn't the one that I'm the most concerned about, but for example compressed sections were updated in the past decade. The ABI for x86-64 is out-of-date (actually, the site it links to is now a 404, but my recollection was that was a version around 2013)--missing things like _Float16 rules, DWARF register naming for AMX and APX registers, microarchitecture levels, new relocation types,
Re:Evolution of the ELF object file format
by jcranmer on Monday May 27, 2024 @07:23PM
(#40495749)
I'm aware of that (and peeved that they've got runners set up for the x86-64 ABI but not the i386 ABI, so there's no nice PDF version of the i386 version I can use).
Re:Evolution of the ELF object file format
by jcranmer on Monday May 27, 2024 @04:09PM
(#40494181)
So far, the list of resources is a collection of PDFs I've downloaded plus a script to download the latest version of every relevant specification. (Although it does seem that Intel likes breaking its links to the latest ISA PDF every now and then). I don't have a great solution for things that are essentially web-only pages, which is how the Itanium ABI is handled (and unlike C, C++ makes it hard to find the relevant working draft copies, instead preferring to use the HTML-based https://eel.is/c++draft for that).
I probably will make it publicly available eventually, it just hasn't been a priority for me.
Re:Evolution of the ELF object file format
by int_19h on Tuesday May 28, 2024 @12:09AM
(#40497237)
The most widespread standard for archiving collections of web pages is WARC - it is a publicly available ISO standard so it's very future-proof. WACZ (https://specs.webrecorder.net/wacz/1.1.1/) is a more recent take that is basically zipped WARC + index + metadata, and Internet Archive can generate them when archiving is requested (https://web.archive.org/save/).
In addition to that, I would also suggest using https://zimit.kiwix.org. It's a very compact representation that has full text index support for convenient searching, the format is open and documented, and first-party readers are available on all major platforms. And for stuff like this, Kiwix might actually be interested in adding them to their official library at https://library.kiwix.org/ if you contact them.
Re:Evolution of the ELF object file format
by jcranmer on Monday May 27, 2024 @04:06PM
(#40494146)
I file things like linkers, loaders, and debuggers into the same bucket as compilers, so all of the ELF extensions are interesting to me, even if compilers directly don't interact with them. I'm also interested in things like the loader-debugger rendezvous interface. Basically any document anyone who touches any project in llvm-project might need to read.
And then there are things like the layout of .gcc_except_table, which are undocumented except for random blog posts.
Re:Evolution of the ELF object file format
by WalterBright on Monday May 27, 2024 @07:18PM
(#40495713)
> there are things like the layout of .gcc_except_table, which are undocumented except for random blog posts.
The way I dealt with it was write an ELF dumper for the tables, and then run various C++ code snippets through g++ and look at how the tables were constructed.
Re:Evolution of the ELF object file format
by matt_d on Monday May 27, 2024 @07:57PM
(#40495976)
In case this is of interest, here's an attempt at gathering the references, including random blog posts (as well as articles, documentation, papers, software, and talks), on these topics:
Re:Evolution of the ELF object file format
by gumby on Monday May 27, 2024 @10:26PM
(#40496792)
> even if compilers directly don't interact with them
Essentially they do as they put directives into the asm files to put things in specific sections, to define certain symbol visibility etc all of which depend on the object file format (e.g. a classic BSD a.out file, using a format I called “a.out” in BFD, can’t represent most of that). So the compiler does need to know. And the assembler absolutely needs to know since it generates object files!
So yes an a.out file can be an ELF file (always is on Linux) or could be an “a.out” file. Sorry! In retrospect I should have called that format “bsd”.
Re:Evolution of the ELF object file format
by WalterBright on Monday May 27, 2024 @07:14PM
(#40495694)
The first thing I do when porting to a new platform is build an object file format pretty-printer. It's the only way to figure out how it really works.
The written specifications for them are often a bit of a fairy tale. The real specification is whatever the local C compiler generates.
The other gatekeeper is what the linker will accept. That can sometimes be a nightmare.
Re:Evolution of the ELF object file format
by trws on Monday May 27, 2024 @08:25PM
(#40496151)
I fell very far down this rabbit hole trying to figure out the history of library link orders and symbol resolution. One fun outcome of which was finding that the first ever public release of a manpage for ld.so on Linux listed RPATH as deprecated. Finding mailing lists from before the source ware transition is hard, some of it exists if you follow the path back to the Solaris forums, but only some. I’ll look through my archives for the features you listed, but I don’t think I uncovered anything about them specifically. Good luck!
> Second draft published May 3, 1999.
> ...
> New dynamic section tags DT_RUNPATH and DT_FLAGS added. Dynamic section tag DT_RPATH moved to level 2.
In glibc, DT_RPATH and DT_RUNPATH have different semantics regarding precedence related to LD_LIBRARY_PATH. In FreeBSD rtld and musl, DT_RPATH and DT_RUNPATH are equivallent.
Re:Evolution of the ELF object file format
by yjftsjthsd-h on Monday May 27, 2024 @11:52AM
(#40491918)
> Q18: How can you get a single binary to work identically across all these diverse systems?
> Most Unix-on-Intel binary packages are already largely similar. Almost all such operating systems use the "ELF" binary 'packaging'; the various operating systems have small but significant differences, though, that make each system's ELF binary unusable on others'.
Though the scope has diminished with the decline of proprietary unixen, there is a nice bright spot with APE binaries ( https://justine.lol/ape.html ) which are in some regards even more portable since they work on Darwin (which natively uses Mach-O) and NT (which natively uses PE).
Re:Evolution of the ELF object file format
by MaskRay on Tuesday May 28, 2024 @03:09AM
(#40498180)
Yes! I immediately thought about APE when I read The 86open Project's FAQ. However, I feel that APE is less related to the blog post so decide not to add the link to the post.
I have two specific questions:
- Key features (symbol visibility, section groups, SHF_MERGE, etc) were all available as of April 2001. Where can we find the discussion mailing lists? Are they still available?
- How does the ABI end up being “All rights reserved” by SCO?
Text of the spec is copyrighted by the SCO, they did not put it in public domain. That's what "All rights reserved" was intended to mean even though this phrase has not been meaning anything since 2000.
Has anyone looked at creating a new object format for Linux? A non-open spec seems a minor issue, really, in an era when we put binary blobs in the kernel (hi Nvidia.) But the more decades I work in closed source, the more I value open source, and believe keeping _everything_ open.
(Of course this assumes that doing this is sufficient to make it legally not derived from the original spec as far as copyright law cares about, which is beyond my non-lawyer ability to be that confident in.)
OpenVMS uses ELF too. Rather niche proprietary OS but still maintained and in production use. (Not a new thing with x86-64 port, ELF was adopted during the Alpha to Iranian transition.)
As do many RTOS (both open source and proprietary)
No, because that's overkill for this problem, because the de facto standard is "What do modern free Unicies do", where those are basically Linux/BSD/Illumos. Besides, it's not unheard of in Unix history to have free implementations of proprietary standards, where those implementations became de facto standards anyway.
Even if it was a seriously pressing issue, writing a new specification that covers ELF as it exists today is going to be many, many, many times easier than introducing a new executable format across the ecosystem, they're not even in the same league or sport in terms of effort. If you were going to introduce a whole new object file format it would be much better to do it and justify it on the basis of fundamental technical/architectural changes.
Linux is written in C, whose spec is proprietary. The larger stack has countless ISO standard references etc., all of which refer to proprietary standards you need to buy.
(Personally, that makes me a bit uneasy: for instance, if the copyrighted spec lists the file sections in a certain order, and your implementation happens to output them in the same order even if it doesn't have to, then have you infringed on the owner's copyright of that particular arrangement?)
Meanwhile, they could have gotten a patent on (some parts of) the format, but that doesn't seem to be the case here.
If it is necessary for operation or inter-operation [1] then they can probably not enforce copyright or trademark.
[1] https://en.wikipedia.org/wiki/Sega_v._Accolade
Of course, the defense against this would be to scramble (or normalize) all non-functional choices compared to anything in the spec. But you have to be careful to make sure there's nothing left of the spec's non-functional influence.
At least Oracle v. Google appears to provide some ammunition here in favor of implementers: the court found the transformative use in that case enough to trump even the byte-for-byte copying of the API signatures. So perhaps interoperability could similarly trump such non-functional copying from the spec. But overall, it's still on shakier ground than I'd like.
While IEEE 754 is an issue because it's not freely available for most people, the only document that has truly stumped me is the ELF specification. From your blog post, it seems like my failure to find the most up-to-date specification is simply because one doesn't exist.
https://wiki.osdev.org/ELF#External_Links
No matter; but that's the most up-to-date list of references I know about.
I probably will make it publicly available eventually, it just hasn't been a priority for me.
In addition to that, I would also suggest using https://zimit.kiwix.org. It's a very compact representation that has full text index support for convenient searching, the format is open and documented, and first-party readers are available on all major platforms. And for stuff like this, Kiwix might actually be interested in adding them to their official library at https://library.kiwix.org/ if you contact them.
* ISA manual * ELF (generic ABI, psABI (e.g. x86-64-psABI), OSABI) * DWARF * Floating-point * Language standards * Itanium C++ ABI
and probably a few other stuff.
> it seems like my failure to find the most up-to-date specification is simply because one doesn't exist.
While the up-to-date specification is unavailable, hopefully it is not too bad because all essential features have been completed as of 2001:)
RELR is a linker and loader feature, not on the compiler side. Compressed debug sections are a pretty natural extension.
And then there are things like the layout of .gcc_except_table, which are undocumented except for random blog posts.
The way I dealt with it was write an ELF dumper for the tables, and then run various C++ code snippets through g++ and look at how the tables were constructed.
The same executable will also detect and dump Elf, Mach, MScoff, and OMF object files.
Besides, one doesn't learn anything about how to decode the format by using an existing tool that presents it in decoded form.
- assembly & ISA (instruction set architecture):
- Arm: https://github.com/MattPD/cpplinks/blob/master/assembly.arm....
- RISC-V: https://github.com/MattPD/cpplinks/blob/master/assembly.risc...
- x86: https://github.com/MattPD/cpplinks/blob/master/assembly.x86....
- debugging: https://github.com/MattPD/cpplinks/blob/master/debugging.md
- debugging: tracing: https://github.com/MattPD/cpplinks/blob/master/debugging.tra...
- executable and object file formats (ELF, Mach-O, PE); debugging data formats (DWARF, PDB): https://github.com/MattPD/cpplinks/blob/master/executables.m...
- linking and loading: https://github.com/MattPD/cpplinks/blob/master/executables.l...
- compilers: https://github.com/MattPD/cpplinks/blob/master/compilers.md
- compilers correctness: https://github.com/MattPD/cpplinks/blob/master/compilers.cor...
Essentially they do as they put directives into the asm files to put things in specific sections, to define certain symbol visibility etc all of which depend on the object file format (e.g. a classic BSD a.out file, using a format I called “a.out” in BFD, can’t represent most of that). So the compiler does need to know. And the assembler absolutely needs to know since it generates object files!
So yes an a.out file can be an ELF file (always is on Linux) or could be an “a.out” file. Sorry! In retrospect I should have called that format “bsd”.
The written specifications for them are often a bit of a fairy tale. The real specification is whatever the local C compiler generates.
The other gatekeeper is what the linker will accept. That can sometimes be a nightmare.
In llvm-project, obj2yaml pretty prints an object file in YAML and yaml2obj can convert the output back to an object file.
The test cases are a good way to explore the functionality: https://github.com/llvm/llvm-project/tree/main/llvm/test/too... https://github.com/llvm/llvm-project/tree/main/llvm/test/too...
> Second draft published May 3, 1999. > ... > New dynamic section tags DT_RUNPATH and DT_FLAGS added. Dynamic section tag DT_RPATH moved to level 2.
In glibc, DT_RPATH and DT_RUNPATH have different semantics regarding precedence related to LD_LIBRARY_PATH. In FreeBSD rtld and musl, DT_RPATH and DT_RUNPATH are equivallent.
> Most Unix-on-Intel binary packages are already largely similar. Almost all such operating systems use the "ELF" binary 'packaging'; the various operating systems have small but significant differences, though, that make each system's ELF binary unusable on others'.
Though the scope has diminished with the decline of proprietary unixen, there is a nice bright spot with APE binaries ( https://justine.lol/ape.html ) which are in some regards even more portable since they work on Darwin (which natively uses Mach-O) and NT (which natively uses PE).