diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-06-03 14:24:59 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-06-04 13:27:32 +0100 |
commit | 07223656d2060464b6830562b1bb8c7cbd230896 (patch) | |
tree | 0132ec28e8079df3278527c7874ad882b81eef12 /meta/recipes-devtools/patchelf | |
parent | 5cbf053481642a820b9f4c6bed9ac79246719087 (diff) | |
download | poky-07223656d2060464b6830562b1bb8c7cbd230896.tar.gz |
patchelf: Add patch to address corrupt shared library issue
patchelf can corrupt shared libraries if the program headers don't
immediately follow the elf header. Add a patch submitted upstream
to address this.
(From OE-Core rev: e7811c787bbe2f5d49b3506309499acc27189988)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/patchelf')
-rw-r--r-- | meta/recipes-devtools/patchelf/patchelf/fix-phdrs.patch | 37 | ||||
-rw-r--r-- | meta/recipes-devtools/patchelf/patchelf_0.10.bb | 1 |
2 files changed, 38 insertions, 0 deletions
diff --git a/meta/recipes-devtools/patchelf/patchelf/fix-phdrs.patch b/meta/recipes-devtools/patchelf/patchelf/fix-phdrs.patch new file mode 100644 index 0000000000..d087bd7855 --- /dev/null +++ b/meta/recipes-devtools/patchelf/patchelf/fix-phdrs.patch | |||
@@ -0,0 +1,37 @@ | |||
1 | When running patchelf on some existing patchelf'd binaries to change to longer | ||
2 | RPATHS, ldd would report the binaries as invalid. The output of objdump -x on | ||
3 | those libraryies should show the top of the .dynamic section is getting trashed, | ||
4 | something like: | ||
5 | |||
6 | 0x600000001 0x0000000000429000 | ||
7 | 0x335000 0x0000000000335000 | ||
8 | 0xc740 0x000000000000c740 | ||
9 | 0x1000 0x0000000000009098 | ||
10 | SONAME libglib-2.0.so.0 | ||
11 | |||
12 | (which should be RPATH and DT_NEEDED entries) | ||
13 | |||
14 | This was tracked down to the code which injects the PT_LOAD section. | ||
15 | |||
16 | The issue is that if the program headers were previously relocated to the end | ||
17 | of the file which was how patchelf operated previously, the relocation code | ||
18 | wouldn't work properly on a second run as it now assumes they're located after | ||
19 | the elf header. This change forces them back to immediately follow the elf | ||
20 | header which is where the code has made space for them. | ||
21 | |||
22 | Upstream-Status: Submitted [https://github.com/NixOS/patchelf/pull/202] | ||
23 | Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> | ||
24 | RP 2020/6/2 | ||
25 | |||
26 | Index: git/src/patchelf.cc | ||
27 | =================================================================== | ||
28 | --- git.orig/src/patchelf.cc | ||
29 | +++ git/src/patchelf.cc | ||
30 | @@ -762,6 +762,7 @@ void ElfFile<ElfFileParamNames>::rewrite | ||
31 | } | ||
32 | |||
33 | /* Add a segment that maps the replaced sections into memory. */ | ||
34 | + wri(hdr->e_phoff, sizeof(Elf_Ehdr)); | ||
35 | phdrs.resize(rdi(hdr->e_phnum) + 1); | ||
36 | wri(hdr->e_phnum, rdi(hdr->e_phnum) + 1); | ||
37 | Elf_Phdr & phdr = phdrs[rdi(hdr->e_phnum) - 1]; | ||
diff --git a/meta/recipes-devtools/patchelf/patchelf_0.10.bb b/meta/recipes-devtools/patchelf/patchelf_0.10.bb index d29e094edd..84e640773b 100644 --- a/meta/recipes-devtools/patchelf/patchelf_0.10.bb +++ b/meta/recipes-devtools/patchelf/patchelf_0.10.bb | |||
@@ -1,6 +1,7 @@ | |||
1 | SRC_URI = "git://github.com/NixOS/patchelf;protocol=https \ | 1 | SRC_URI = "git://github.com/NixOS/patchelf;protocol=https \ |
2 | file://handle-read-only-files.patch \ | 2 | file://handle-read-only-files.patch \ |
3 | file://fix-adjusting-startPage.patch \ | 3 | file://fix-adjusting-startPage.patch \ |
4 | file://fix-phdrs.patch \ | ||
4 | " | 5 | " |
5 | 6 | ||
6 | LICENSE = "GPLv3" | 7 | LICENSE = "GPLv3" |