diff options
author | Petr Štetiar <ynezz@true.cz> | 2022-03-31 09:44:25 +0200 |
---|---|---|
committer | Petr Štetiar <ynezz@true.cz> | 2022-03-31 10:22:33 +0200 |
commit | 9aa35fada6522189202c324dd9a97672460b0e4a (patch) | |
tree | 0fdf20860b69c4efcd01b437f72821c79eec1e07 /tools | |
parent | b24905c38a8acc337a08c116b343b6ccc3ba861e (diff) | |
download | upstream-9aa35fada6522189202c324dd9a97672460b0e4a.tar.gz upstream-9aa35fada6522189202c324dd9a97672460b0e4a.tar.bz2 upstream-9aa35fada6522189202c324dd9a97672460b0e4a.zip |
patchelf: backport fix for rpath endianness
This is backport of upstream fix introduced in commit e88d83c8b4e4
("patchelf: Check ELF endianness before writing new runpath") which
fixes broken rpath handling on big endian systems:
$ patchelf --set-rpath '/opt/foo/bar' lxc4-start
$ readelf -d lxc4-start
...
0x1d000000 (<unknown>: 1d000000) 0x72f
...
Expected output, having following patch applied is:
$ readelf -d lxc4-start
...
0x0000001d (RUNPATH) Library runpath: [/opt/foo/bar]
...
Build and runtime tested on mvebu/turris-omnia, ipq40xx/glinet-b1300
and external target xrx500/nec-wx3000hp (MIPS BE).
Signed-off-by: Matthias Van Gestel <matthias.vangestel_ext@softathome.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/patchelf/patches/0001-patchelf-Check-ELF-endianness-before-writing-new-run.patch | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/patchelf/patches/0001-patchelf-Check-ELF-endianness-before-writing-new-run.patch b/tools/patchelf/patches/0001-patchelf-Check-ELF-endianness-before-writing-new-run.patch new file mode 100644 index 0000000000..197a321f72 --- /dev/null +++ b/tools/patchelf/patches/0001-patchelf-Check-ELF-endianness-before-writing-new-run.patch @@ -0,0 +1,41 @@ +From 9c9efd0525ac1e11f83029b8df5303a47ab6fe56 Mon Sep 17 00:00:00 2001 +From: Bryce Ferguson <bryce.ferguson@rockwellcollins.com> +Date: Mon, 25 Jun 2018 13:50:46 -0500 +Subject: [PATCH] patchelf: Check ELF endianness before writing new runpath +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +[ upstream commit e88d83c8b4e42a3358a90b781a5a98efa279ff15 ] + +This commit modifies the way fields are written in the dynamic +section in order to account the architecture of the target ELF +file. Instead of copying the raw data, use the helper functions +to convert endianness. + +Signed-off-by: Bryce Ferguson <bryce.ferguson@rockwellcollins.com> +Signed-off-by: Petr Štetiar <ynezz@true.cz> [version 0.9 backport] +--- + src/patchelf.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/patchelf.cc b/src/patchelf.cc +index 136098fbeeda..383c78a46ee4 100644 +--- a/src/patchelf.cc ++++ b/src/patchelf.cc +@@ -1171,13 +1171,13 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op, string newRPath) + debug("new rpath is `%s'\n", newRPath.c_str()); + + if (!forceRPath && dynRPath && !dynRunPath) { /* convert DT_RPATH to DT_RUNPATH */ +- dynRPath->d_tag = DT_RUNPATH; ++ wri(dynRPath->d_tag, DT_RUNPATH); + dynRunPath = dynRPath; + dynRPath = 0; + } + + if (forceRPath && dynRPath && dynRunPath) { /* convert DT_RUNPATH to DT_RPATH */ +- dynRunPath->d_tag = DT_IGNORE; ++ wri(dynRunPath->d_tag, DT_IGNORE); + } + + if (newRPath.size() <= rpathSize) { |