elf: fix parsing of notes after patchelf mangling
Metadata
Current evaluation
Merged fix for ELF note parsing after patchelf modifications. Iterates over sections instead of the note segment to reliably extract note data, resolving snapcraft build-time failures with patched binaries. Fixes SNAPCRAFT-1K4 and SNAPCRAFT-1ET.
Suggested action: —
No scores available.
Issue body
We cannot rely on iterating on the notes via the note segment.
Patchelf may move note sections into other segments, and worse
yet, possibly leave the note segment standing with invalid data.
Here we instead iterate over each section and (more) reliably
gather the note information.
There is some improvement that should be done on the patchelf
side, as `readelf` complains on these binaries, and other issues
have surfaced in the past (e.g. mesa in classic snaps). However,
this will hopefully address snapcraft build-time issues with not
only our patched files for classic snaps, but externally patched
binaries that are being packaged.
Add a couple of developer logs to indicate when we are parsing
an ELF, so future investigations are easier when something explodes.
Signed-off-by: Chris Patterson <chris.patterson@canonical.com>
- [ ] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [ ] Have you successfully run `./runtests.sh static`?
- [ ] Have you successfully run `./runtests.sh tests/unit`?
-----
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged fix for ELF note parsing after patchelf modifications. Iterates over sections instead of the note segment to reliably extract note data, resolving snapcraft build-time failures with patched binaries. Fixes SNAPCRAFT-1K4 and SNAPCRAFT-1ET. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged fix for ELF note parsing after patchelf modifications. Iterates over sections instead of the note segment to reliably extract data. Resolves snapcraft build-time failures with patched binaries and adds debug logging. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged ELF note parsing fix after patchelf modifications. Iterates over sections instead of the note segment to reliably extract data, resolving snapcraft build-time failures with patched binaries. Resolves SNAPCRAFT-1K4 and SNAPCRAFT-1ET |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1798 elf: strip the .note.go.buildid to make room for patching elf | snapcraft | merged | Merged. Strips the .note.go.buildid section from ELF binaries to resolve patchelf compatibility issues and fix build failures. Approved after passing CI checks. Introduces a newer patchelf build-snap dependency to ensure correct header patching. | |
| #3841 elf: add elf file patcher | snapcraft | merged | Merged an ELF file patcher using patchelf, ported from Snapcraft 6.x. Approved by one reviewer, passed CI checks, and increased test coverage by 0.26%. Resolves CRAFT-1191. | |
| #3149 elf: search dynamic tags within sections, not segment | snapcraft | merged | Merged fix resolving snapcraft failures on invalid tag data caused by patchelf mangling. Resolved by iterating over dynamic sections instead of segments. Successfully merged into master. | |
| #2081 elf: patch everything instead of a subset of elf files | snapcraft | merged | Merged a pull request that restores Snapcraft 2.39 behavior by patching all ELF files instead of a subset, reverting a prior change. Approved and passed CI. | |
| #1888 elf: make patchelf a dependency | snapcraft | merged | Merged after reviewer approval and CI checks. The change corrects patchelf handling by removing it from build_tools and properly configuring it as a dependency via debian/control for deb packages and snapcraft bundling for snaps. |