Skip to content

specs: document ELF note-merging semantics for dlopen and package metadata#222

Open
xnox wants to merge 1 commit into
uapi-group:mainfrom
xnox:elf-notes-merging
Open

specs: document ELF note-merging semantics for dlopen and package metadata#222
xnox wants to merge 1 commit into
uapi-group:mainfrom
xnox:elf-notes-merging

Conversation

@xnox

@xnox xnox commented Jul 7, 2026

Copy link
Copy Markdown

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.

…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.

## 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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

padded/aligned to what?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


## 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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

padded/aligned to what?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will update in a week

@poettering

Copy link
Copy Markdown
Collaborator

lgtm, but be more precise regarding the padding/alignment, as suggested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants