diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-06-03 14:24:59 +0100 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2020-06-16 10:14:02 -1000 |
commit | faaf5f34332290708f3720a5488b3d1549d9e95a (patch) | |
tree | 9ecfe0568fed4747692d7c47f0add63b90ee7908 /meta | |
parent | cf7e02e8cdb3cc4cdb9f155c8bd16dece2805a39 (diff) | |
download | openembedded-core-contrib-faaf5f34332290708f3720a5488b3d1549d9e95a.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.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit e7811c787bbe2f5d49b3506309499acc27189988)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta')
-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 @@ +When running patchelf on some existing patchelf'd binaries to change to longer +RPATHS, ldd would report the binaries as invalid. The output of objdump -x on +those libraryies should show the top of the .dynamic section is getting trashed, +something like: + +0x600000001 0x0000000000429000 +0x335000 0x0000000000335000 +0xc740 0x000000000000c740 +0x1000 0x0000000000009098 +SONAME libglib-2.0.so.0 + +(which should be RPATH and DT_NEEDED entries) + +This was tracked down to the code which injects the PT_LOAD section. + +The issue is that if the program headers were previously relocated to the end +of the file which was how patchelf operated previously, the relocation code +wouldn't work properly on a second run as it now assumes they're located after +the elf header. This change forces them back to immediately follow the elf +header which is where the code has made space for them. + +Upstream-Status: Submitted [https://github.com/NixOS/patchelf/pull/202] +Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> +RP 2020/6/2 + +Index: git/src/patchelf.cc +=================================================================== +--- git.orig/src/patchelf.cc ++++ git/src/patchelf.cc +@@ -762,6 +762,7 @@ void ElfFile<ElfFileParamNames>::rewrite + } + + /* Add a segment that maps the replaced sections into memory. */ ++ wri(hdr->e_phoff, sizeof(Elf_Ehdr)); + phdrs.resize(rdi(hdr->e_phnum) + 1); + wri(hdr->e_phnum, rdi(hdr->e_phnum) + 1); + 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 cc983e033a..e4a604ec70 100644 --- a/meta/recipes-devtools/patchelf/patchelf_0.10.bb +++ b/meta/recipes-devtools/patchelf/patchelf_0.10.bb @@ -1,6 +1,7 @@ SRC_URI = "https://nixos.org/releases/${BPN}/${BPN}-${PV}/${BPN}-${PV}.tar.bz2 \ file://handle-read-only-files.patch \ file://fix-adjusting-startPage.patch \ + file://fix-phdrs.patch \ " LICENSE = "GPLv3" |