specs: document ELF note-merging semantics for dlopen and package metadata#222
Open
xnox wants to merge 1 commit into
Open
specs: document ELF note-merging semantics for dlopen and package metadata#222xnox wants to merge 1 commit into
xnox wants to merge 1 commit into
Conversation
…adata Linkers concatenate same-named sections from multiple input files, so a linked binary can carry multiple .note.dlopen or .note.package notes even when each producer emitted only one. Parsers must therefore iterate over one or more Note structures rather than assuming a single note. Add a "Guidance on parsing ELF sections" section to both specs describing this, with a readelf example. Make the two specs share the same parsing procedure: this behavior is forced by the ELF spec and by the binutils ld and LLVM lld implementations, and was already the long-standing status quo for dlopen metadata (one note per dependency or one combined note), so the package metadata spec now inherits it. For package metadata, note the SCA/SBOM/vulnerability-matching implication: multiple notes indicate a likely statically linked binary composed from several packages, all of which must be enumerated.
poettering
reviewed
Jul 8, 2026
|
|
||
| ## Guidance on parsing ELF sections | ||
|
|
||
| When ELF linkers encounter an identical section name across multiple input files, the sections are concatenated in the order they appear, padded and aligned. This merging is standard linker behavior and is generally not under the control of the tool that emits the note. See the [binutils ld](https://sourceware.org/binutils/docs/ld/SECTIONS.html) documentation as well as [LLVM lld](https://releases.llvm.org/22.1.0/tools/lld/docs/ELF/linker_script.html#linker-script-implementation-notes-and-policy), which describe the same behavior. |
Collaborator
There was a problem hiding this comment.
padded/aligned to what?
Author
There was a problem hiding this comment.
it is a bit convoluted - it is 4 bytes; but also the max bytes of all sections being merged if different alignment specified, and could be 8.
will collect precise wording from the ELF spec and ld implementation to be precise & concise.
Will be able to get to this in a weeks time.
poettering
reviewed
Jul 8, 2026
|
|
||
| ## Guidance on parsing ELF sections | ||
|
|
||
| When ELF linkers encounter an identical section name across multiple input files, the sections are concatenated in the order they appear, padded and aligned. This merging is standard linker behavior and is generally not under the control of the tool that emits the note. See the [binutils ld](https://sourceware.org/binutils/docs/ld/SECTIONS.html) documentation as well as [LLVM lld](https://releases.llvm.org/22.1.0/tools/lld/docs/ELF/linker_script.html#linker-script-implementation-notes-and-policy), which describe the same behavior. |
Collaborator
There was a problem hiding this comment.
padded/aligned to what?
Collaborator
|
lgtm, but be more precise regarding the padding/alignment, as suggested |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Linkers concatenate same-named sections from multiple input files, so a
linked binary can carry multiple .note.dlopen or .note.package notes even
when each producer emitted only one. Parsers must therefore iterate over
one or more Note structures rather than assuming a single note.
Add a "Guidance on parsing ELF sections" section to both specs describing
this, with a readelf example. Make the two specs share the same parsing
procedure: this behavior is forced by the ELF spec and by the binutils ld
and LLVM lld implementations, and was already the long-standing status quo
for dlopen metadata (one note per dependency or one combined note), so the
package metadata spec now inherits it.
For package metadata, note the SCA/SBOM/vulnerability-matching implication:
multiple notes indicate a likely statically linked binary composed from
several packages, all of which must be enumerated.