Clear up confusion on elf32 vs elf64 notes which in fact are the same #36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The definitions of note sections (and segments) for Elf32 and Elf64 is a bit of a mess. There is a specification saying Elf64 should use 8-byte fields. But noone does that.
(The alignment may however differ, but that is a different thing)
N.B this changes the type of the publically visible
NoteAny.n_type
Sources
linux
LSB elf.h says Elf32_Nhdr and Elf64_Nhdr are identical:
https://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/libc-ddefs.html
But also in Executable And Linking Format (ELF) refers to "System V ABI Update" which specifies it as using 8-byte fields for namesz, descsz and type.
freebsd
Elf32_Nhdr
https://github.com/freebsd/freebsd-src/blob/b9a60d36ba043f313ab98b8dd058d49559254791/sys/sys/elf64.h#L172
and Elf64_Nhdr
https://github.com/freebsd/freebsd-src/blob/b9a60d36ba043f313ab98b8dd058d49559254791/sys/sys/elf32.h#L158
typedeffed to same thing: https://github.com/freebsd/freebsd-src/blob/b9a60d36ba043f313ab98b8dd058d49559254791/sys/sys/elf_common.h#L48
Solaris
https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-18048.html clearly states that it is 4-byte words for both 32-bit and 64-bit systems.
GHC
The best source explaining this mess I found in a comment of GHC's elf module: https://gitlab.haskell.org/ghc/ghc/-/blob/master/compiler/GHC/SysTools/Elf.hs#L81
LLVM
https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Object/ELFTypes.h#L596
everything as Elf_Word (=u32)
Commit message of this commit