by MaskRay · 2y ago · 0 comments
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? Tool Interface Standard (TIS) Portable Formats Specification, version 1.2 effectively put the specification in the public domain.
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.
No matter; but that's the most up-to-date list of references I know about.
* 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.
- 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 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.
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.
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.
Section 14 .eh_frame PROGBITS,ALLOC,SIZE=0x0030(48),OFFSET=0x0040,ALIGN=8
offset = 00000000, length = 0x0014(20)
CIE_id = 00000000
version = 1
augmentation = 'zR'
code_alignment_factor = 1
data_alignment_factor = -8
return_address_register = 16
Augmentation_Length = 1
Address pointer encoding = DW_EH_PE_pcrel|sdata4
DW_CFA_def_cfa reg = 7, off = 00000008
DW_CFA_offset_10 off = 1
DW_CFA_nop
DW_CFA_nop
offset = 00000018, length = 0x0014(20)
CIE_pointer = 0000001c offset 00000000
augmentation = 'zR'
PC_Begin = 0
PC_Range = 6
Augmentation_Length = 0
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
0040: 14 0 0 0 0 0 0 0 1 7a 52 0 1 78 10 1 .........zR..x..
0050: 1b c 7 8 90 1 0 0 14 0 0 0 1c 0 0 0 ................
0060: 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 ................
Section 15 .data._D16TypeInfo_S3__C1S6__initZ PROGBITS,WRITE,ALLOC,SIZE=0x0090(144),OFFSET=0x0070,ALIGN=16
0070: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ................
0080: 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ................
0090: 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ................
00a0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ................
00b0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ................
00c0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ................
00d0: 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 ................
00e0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ................
00f0: 0 0 0 0 0 0 0 0 53 33 5f 5f 43 31 53 0 ........S3__C1S.
Section 16 .rela.data._D16TypeInfo_S3__C1S6__initZ RELA,ENTRIES=3,OFFSET=0x06A4,ALIGN=8,LINK=8,INFO=15
0 offset=00000000 addend=0000000000000000 type=R_X86_64_64 sym=24 sym="_D15TypeInfo_Struct6__vtblZ"
1 offset=00000018 addend=0000000000000088 type=R_X86_64_64 sym=21 sym="_D16TypeInfo_S3__C1S6__initZ"
2 offset=00000070 addend=0000000000000000 type=R_X86_64_64 sym=25 sym="_D10TypeInfo_i6__initZ"
Section 17 .bss.__bzeroBytes NOBITS,WRITE,ALLOC,SIZE=0x0080(128),OFFSET=0x0100,ALIGN=16
Section 18 .group GROUP,ENTRIES=2,OFFSET=0x0100,ALIGN=4,LINK=8,INFO=23
0100: 1 0 0 0 13 0 0 0 ........
Section 19 .text.test PROGBITS,ALLOC,EXEC,GROUP,SIZE=0x0008(8),OFFSET=0x0108,ALIGN=4
0108: b8 4 0 0 0 c3 0 0 ........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.
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.
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.