elf: patch elf files for classic mode
Metadata
Current evaluation
Merged into main. Patches ELF binaries for classic mode to use the base snap interpreter and libraries, or bundled components if libc is staged, when enable-patchelf is enabled. Approved, passed CI, and merged.
Suggested action: —
No scores available.
Issue body
If `enable-patchelf` is listed in the part's build attributes, patch the part's ELF binaries to use the interpreter and libraries from the base snap (or use bundled components if libc is staged).
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] Have you successfully run `make lint`?
- [ ] Have you successfully run `pytest tests/unit`?
-----
CRAFT-1460
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged into main. Patches ELF binaries for classic mode to use the base snap interpreter and libraries, or bundled components if libc is staged, when enable-patchelf is enabled. Approved, passed CI, and merged. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged into main. Patches ELF binaries to use the base snap interpreter and libraries when enable-patchelf is enabled in build attributes, enabling classic mode support. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged into main. Implements ELF binary patching for classic mode when enable-patchelf is enabled, routing binaries to the base snap interpreter and libraries or bundled components. Commit 2094774 merged into d685a23. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #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. | |
| #1873 elf: cleaner patchelf experience | snapcraft | merged | Merged improvements to patchelf handling. The change uses the system patchelf by default, copies files to prevent hard-link conflicts, and provides fallback instructions. Approved by two reviewers and passed CI checks before merging. | |
| #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. | |
| #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. | |
| #1747097 patch fewer elf files | snapcraft (launchpad) | open | Optimization proposal to reduce patchelf usage on ELF files in classic snaps by only patching executables and dlopen targets via DT_SONAME/DT_NEEDED analysis. Open since 2017 with zero comments, labels, or maintainer interaction. | |
| #3840 elf: add handling and patching helpers | snapcraft | merged | Merged into main following reviewer approval and passing CI checks. Introduces ELF binary listing and dynamic linker location helpers, adding handling and patching utilities to the elf module while increasing test coverage. | |
| #1781 many: set rpath for elf files for classic | snapcraft | merged | Merged. Configures rpath for ELF files in classic confinement using $ORIGIN and patchelf to eliminate LD_LIBRARY_PATH dependencies, resolving #1663. Approved after resolving CLA checks and transient CI failures. | |
| #1850 pluginhandler: patch and handle elf files on glibc mismatch | snapcraft | merged | Merged. Resolves glibc mismatches in ELF files by fetching libc6 from the host, priming it, and using its dynamic loader instead of the base snap's. Approved by two reviewers and closes issues #1668 and #1669. | |
| #1959 elf: only patch elf files that aren't referenced by DT_NEEDED | snapcraft | merged | Merged after conflict resolution. Optimizes patchelf usage by only patching ELF files not listed in DT_NEEDED dependencies, reducing unnecessary modifications. Adds architecture extraction to ElfFile to prevent cross-architecture mismatches. Resolves LP #1747097. |