Two patches were merged upstream, the other needed refreshing. Signed-off-by: Richard Purdie <richard.pur...@linuxfoundation.org> --- .../patchelf/fix-adjusting-startPage.patch | 45 ------------------- .../patchelf/patchelf/fix-phdrs.patch | 37 --------------- .../patchelf/handle-read-only-files.patch | 18 ++++---- .../{patchelf_0.10.bb => patchelf_0.11.bb} | 4 +- 4 files changed, 11 insertions(+), 93 deletions(-) delete mode 100644 meta/recipes-devtools/patchelf/patchelf/fix-adjusting-startPage.patch delete mode 100644 meta/recipes-devtools/patchelf/patchelf/fix-phdrs.patch rename meta/recipes-devtools/patchelf/{patchelf_0.10.bb => patchelf_0.11.bb} (73%)
diff --git a/meta/recipes-devtools/patchelf/patchelf/fix-adjusting-startPage.patch b/meta/recipes-devtools/patchelf/patchelf/fix-adjusting-startPage.patch deleted file mode 100644 index a0988423fee..00000000000 --- a/meta/recipes-devtools/patchelf/patchelf/fix-adjusting-startPage.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 1630d3f846c7721b1e7cd3b005bb2b34816e1d0f Mon Sep 17 00:00:00 2001 -From: Ed Bartosh <ed.bart...@linux.intel.com> -Date: Fri, 21 Jul 2017 12:33:53 +0300 -Subject: [PATCH] patchelf: fix segfault for binaries linked by gold - -commit 1cc234fea5600190d872329aca60e2365cefc39e - -fix adjusting startPage - -startPage is adjusted unconditionally for all executables. -This results in incorrect addresses assigned to INTERP and LOAD -program headers, which breaks patched executable. - -Adjusting startPage variable only when startOffset > startPage -should fix this. - -This change is related to the issue NixOS#10 - -Signed-off-by: Ed Bartosh <ed.bart...@linux.intel.com> - -Github PR: https://github.com/NixOS/patchelf/pull/127 - -Upstream-Status: Submitted - ---- - src/patchelf.cc | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -diff --git a/src/patchelf.cc b/src/patchelf.cc -index a63e3a11c61f..2483d25d78f1 100644 ---- a/src/patchelf.cc -+++ b/src/patchelf.cc -@@ -756,10 +756,8 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary() - since DYN executables tend to start at virtual address 0, so - rewriteSectionsExecutable() won't work because it doesn't have - any virtual address space to grow downwards into. */ -- if (isExecutable) { -- if (startOffset >= startPage) { -- debug("shifting new PT_LOAD segment by %d bytes to work around a Linux kernel bug\n", startOffset - startPage); -- } -+ if (isExecutable && startOffset > startPage) { -+ debug("shifting new PT_LOAD segment by %d bytes to work around a Linux kernel bug\n", startOffset - startPage); - startPage = startOffset; - } - diff --git a/meta/recipes-devtools/patchelf/patchelf/fix-phdrs.patch b/meta/recipes-devtools/patchelf/patchelf/fix-phdrs.patch deleted file mode 100644 index d087bd7855c..00000000000 --- a/meta/recipes-devtools/patchelf/patchelf/fix-phdrs.patch +++ /dev/null @@ -1,37 +0,0 @@ -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.pur...@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/handle-read-only-files.patch b/meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch index 03b0d18a89f..bf721c1af86 100644 --- a/meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch +++ b/meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch @@ -14,30 +14,32 @@ Signed-off-by: Fabio Berton <fabio.ber...@ossystems.com.br> src/patchelf.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) -diff --git a/src/patchelf.cc b/src/patchelf.cc -index 0b4965adff83..b5db2aef0e8a 100644 ---- a/src/patchelf.cc -+++ b/src/patchelf.cc -@@ -497,7 +497,17 @@ void ElfFile<ElfFileParamNames>::sortShdrs() +Index: git/src/patchelf.cc +=================================================================== +--- git.orig/src/patchelf.cc ++++ git/src/patchelf.cc +@@ -499,9 +499,19 @@ void ElfFile<ElfFileParamNames>::sortShd static void writeFile(std::string fileName, FileContents contents) { -- int fd = open(fileName.c_str(), O_TRUNC | O_WRONLY); + struct stat st; + int fd; + + debug("writing %s\n", fileName.c_str()); + +- int fd = open(fileName.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0777); + if (stat(fileName.c_str(), &st) != 0) + error("stat"); + + if (chmod(fileName.c_str(), 0600) != 0) + error("chmod"); + -+ fd = open(fileName.c_str(), O_TRUNC | O_WRONLY); ++ fd = open(fileName.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0777); + if (fd == -1) error("open"); -@@ -511,6 +521,10 @@ static void writeFile(std::string fileName, FileContents contents) +@@ -515,6 +525,10 @@ static void writeFile(std::string fileNa if (close(fd) != 0) error("close"); diff --git a/meta/recipes-devtools/patchelf/patchelf_0.10.bb b/meta/recipes-devtools/patchelf/patchelf_0.11.bb similarity index 73% rename from meta/recipes-devtools/patchelf/patchelf_0.10.bb rename to meta/recipes-devtools/patchelf/patchelf_0.11.bb index 84e640773b2..ba7ad404e93 100644 --- a/meta/recipes-devtools/patchelf/patchelf_0.10.bb +++ b/meta/recipes-devtools/patchelf/patchelf_0.11.bb @@ -1,13 +1,11 @@ SRC_URI = "git://github.com/NixOS/patchelf;protocol=https \ file://handle-read-only-files.patch \ - file://fix-adjusting-startPage.patch \ - file://fix-phdrs.patch \ " LICENSE = "GPLv3" SUMMARY = "Tool to allow editing of RPATH and interpreter fields in ELF binaries" -SRCREV = "e1e39f3639e39360ceebb2f7ed533cede4623070" +SRCREV = "d6b2a72d9ec3bdfde4b1aacdada823ce388968bb" S = "${WORKDIR}/git" -- 2.25.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#139592): https://lists.openembedded.org/g/openembedded-core/message/139592 Mute This Topic: https://lists.openembedded.org/mt/74934566/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-