From 9a4547804f0a889dc583e84a00374085ecf7f361 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 17 Jun 2020 10:47:58 +0100 Subject: patchelf: Upgrade 0.10 -> 0.11 Two patches were merged upstream, the other needed refreshing. Signed-off-by: Richard Purdie --- .../patchelf/fix-adjusting-startPage.patch | 45 ---------------------- .../patchelf/patchelf/fix-phdrs.patch | 37 ------------------ .../patchelf/patchelf/handle-read-only-files.patch | 18 +++++---- meta/recipes-devtools/patchelf/patchelf_0.10.bb | 18 --------- meta/recipes-devtools/patchelf/patchelf_0.11.bb | 16 ++++++++ 5 files changed, 26 insertions(+), 108 deletions(-) delete mode 100644 meta/recipes-devtools/patchelf/patchelf/fix-adjusting-startPage.patch delete mode 100644 meta/recipes-devtools/patchelf/patchelf/fix-phdrs.patch delete mode 100644 meta/recipes-devtools/patchelf/patchelf_0.10.bb create mode 100644 meta/recipes-devtools/patchelf/patchelf_0.11.bb (limited to 'meta') 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 a0988423fe..0000000000 --- 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 -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 - -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::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 d087bd7855..0000000000 --- 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 -RP 2020/6/2 - -Index: git/src/patchelf.cc -=================================================================== ---- git.orig/src/patchelf.cc -+++ git/src/patchelf.cc -@@ -762,6 +762,7 @@ void ElfFile::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 03b0d18a89..bf721c1af8 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 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::sortShdrs() +Index: git/src/patchelf.cc +=================================================================== +--- git.orig/src/patchelf.cc ++++ git/src/patchelf.cc +@@ -499,9 +499,19 @@ void ElfFile::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.10.bb deleted file mode 100644 index 84e640773b..0000000000 --- a/meta/recipes-devtools/patchelf/patchelf_0.10.bb +++ /dev/null @@ -1,18 +0,0 @@ -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" - -S = "${WORKDIR}/git" - -LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504" - -inherit autotools - -BBCLASSEXTEND = "native nativesdk" diff --git a/meta/recipes-devtools/patchelf/patchelf_0.11.bb b/meta/recipes-devtools/patchelf/patchelf_0.11.bb new file mode 100644 index 0000000000..ba7ad404e9 --- /dev/null +++ b/meta/recipes-devtools/patchelf/patchelf_0.11.bb @@ -0,0 +1,16 @@ +SRC_URI = "git://github.com/NixOS/patchelf;protocol=https \ + file://handle-read-only-files.patch \ + " + +LICENSE = "GPLv3" +SUMMARY = "Tool to allow editing of RPATH and interpreter fields in ELF binaries" + +SRCREV = "d6b2a72d9ec3bdfde4b1aacdada823ce388968bb" + +S = "${WORKDIR}/git" + +LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504" + +inherit autotools + +BBCLASSEXTEND = "native nativesdk" -- cgit 1.2.3-korg