← Back to issue list

elf: avoid duplicating rpath entries

View original Github issue

Metadata

Project
snapcraft
Number
#2019
Type
pull request
State
merged
Author
sergiusens
Labels
Created
Updated
Closed

Current evaluation

Merged fix preventing duplicate $ORIGIN rpath entries in ELF binaries. Approved by reviewer, passed unit and integration tests, and updated two files to generate a single rpath entry.

Suggested action:

No scores available.

Issue body

One path is enough for '$ORIGIN' based rpaths. Signed-off-by: Sergio Schvezov <sergio.schvezov@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] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)? - [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)? - [x] Have you successfully run `./runtests.sh static`? - [x] Have you successfully run `./runtests.sh unit`? ----- On `bionic`: ``` (snapcraft) ubuntu@snapcraft-bionic-dev:~/source/snapcraft$ SNAPCRAFT_TEST_KEEP_DATA_PATH=/home/ubuntu/test python3 -m unittest -v -b run tests.integration.general.test_elf.OriginRPATHTestCase run (unittest.loader._FailedTest) ... ok test_origin (tests.integration.general.test_elf.OriginRPATHTestCase) tests.integration.general.test_elf.OriginRPATHTestCase.test_origin ... ok ---------------------------------------------------------------------- Ran 2 tests in 161.552s OK ``` On `xenial`: ``` (snapcraft) ubuntu@snapcraft-xenial-dev:~/source/snapcraft$ SNAPCRAFT_TEST_KEEP_DATA_PATH=/home/ubuntu/test python3 -m unittest -v -b run tests.integration.general.test_elf.OriginRPATHTestCase run (unittest.loader._FailedTest) ... ok test_origin (tests.integration.general.test_elf.OriginRPATHTestCase) tests.integration.general.test_elf.OriginRPATHTestCase.test_origin ... ok ---------------------------------------------------------------------- Ran 2 tests in 163.682s OK ``` And without the fix we see something like ``` $ readelf -d prime/usr/bin/python3 Dynamic section at offset 0x270 contains 31 entries: Tag Type Name/Value 0x000000000000000f (RPATH) Library rpath: [$ORIGIN/../../lib/x86_64-linux-gnu:$ORIGIN/../../lib/x86_64-linux-gnu:$ORIGIN/../../lib/x86_64-linux-gnu:$ORIGIN/../../lib/x86_64-linux-gnu:$ORIGIN/../../lib/x86_64-linux-gnu:$ORIGIN/../../lib/x86_64-linux-gnu:/snap/core/current/lib/x86_64-linux-gnu] ... ``` Instead of ``` $ readelf -d prime/usr/bin/python3 Dynamic section at offset 0x270 contains 31 entries: Tag Type Name/Value 0x000000000000000f (RPATH) Library rpath: [$ORIGIN/../../lib/x86_64-linux-gnu:/snap/core/current/lib/x86_64-linux-gnu] ... ```

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Merged fix preventing duplicate $ORIGIN rpath entries in ELF binaries. Approved by reviewer, passed unit and integration tests, and updated two files to generate a single rpath entry.
qwen3.6-35b-a3b-mtp-q6 Merged fix preventing duplicate $ORIGIN rpath entries in ELF binaries. The change ensures a single rpath is set, verified by passing integration tests on Bionic and Xenial.
qwen3.6-35b-a3b-mtp-q6 Merged fix preventing duplicate $ORIGIN rpath entries in ELF binaries. Ensures only a single $ORIGIN path is set in the dynamic section, eliminating redundant library search paths.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#1896 elf: do not strip rpaths that contain $ORIGIN snapcraft merged Merged to preserve ELF rpaths containing $ORIGIN during stripping. This allows custom runtime library paths that snapcraft would otherwise fail to resolve. Approved by reviewer and passed CI checks.
82%
#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.
76%
#2085 elf: clear the current runpath before setting the rpath snapcraft merged Merged changes that clear existing RUNPATH before setting RPATH in ELF files, resolving issue #2071. Approved and passed CI.
76%
#1988 elf: only set rpaths to libs of the same arch snapcraft merged Merged after reviewer approval. Fixes LP #1752964 by restricting ELF rpath resolution to libraries matching the target architecture alongside soname, preventing incorrect selection when multiple architectures exist in the core snap.
73%