summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-06-17 10:47:58 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-06-17 16:31:52 +0100
commit2fd754bed7516c4a698b04f0fdd429354d703eda (patch)
tree5fe0c37da96bd1615a1f3831946ee0afa2719e9a
parent59459ac93663a2bdabc42cb948f2cb5bc3eb2e4a (diff)
downloadpoky-2fd754bed7516c4a698b04f0fdd429354d703eda.tar.gz
patchelf: Upgrade 0.10 -> 0.11
Two patches were merged upstream, the other needed refreshing. (From OE-Core rev: 9a4547804f0a889dc583e84a00374085ecf7f361) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/patchelf/patchelf/fix-adjusting-startPage.patch45
-rw-r--r--meta/recipes-devtools/patchelf/patchelf/fix-phdrs.patch37
-rw-r--r--meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch18
-rw-r--r--meta/recipes-devtools/patchelf/patchelf_0.11.bb (renamed from meta/recipes-devtools/patchelf/patchelf_0.10.bb)4
4 files changed, 11 insertions, 93 deletions
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 @@
1From 1630d3f846c7721b1e7cd3b005bb2b34816e1d0f Mon Sep 17 00:00:00 2001
2From: Ed Bartosh <ed.bartosh@linux.intel.com>
3Date: Fri, 21 Jul 2017 12:33:53 +0300
4Subject: [PATCH] patchelf: fix segfault for binaries linked by gold
5
6commit 1cc234fea5600190d872329aca60e2365cefc39e
7
8fix adjusting startPage
9
10startPage is adjusted unconditionally for all executables.
11This results in incorrect addresses assigned to INTERP and LOAD
12program headers, which breaks patched executable.
13
14Adjusting startPage variable only when startOffset > startPage
15should fix this.
16
17This change is related to the issue NixOS#10
18
19Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
20
21Github PR: https://github.com/NixOS/patchelf/pull/127
22
23Upstream-Status: Submitted
24
25---
26 src/patchelf.cc | 6 ++----
27 1 file changed, 2 insertions(+), 4 deletions(-)
28
29diff --git a/src/patchelf.cc b/src/patchelf.cc
30index a63e3a11c61f..2483d25d78f1 100644
31--- a/src/patchelf.cc
32+++ b/src/patchelf.cc
33@@ -756,10 +756,8 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
34 since DYN executables tend to start at virtual address 0, so
35 rewriteSectionsExecutable() won't work because it doesn't have
36 any virtual address space to grow downwards into. */
37- if (isExecutable) {
38- if (startOffset >= startPage) {
39- debug("shifting new PT_LOAD segment by %d bytes to work around a Linux kernel bug\n", startOffset - startPage);
40- }
41+ if (isExecutable && startOffset > startPage) {
42+ debug("shifting new PT_LOAD segment by %d bytes to work around a Linux kernel bug\n", startOffset - startPage);
43 startPage = startOffset;
44 }
45
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 @@
1When running patchelf on some existing patchelf'd binaries to change to longer
2RPATHS, ldd would report the binaries as invalid. The output of objdump -x on
3those libraryies should show the top of the .dynamic section is getting trashed,
4something like:
5
60x600000001 0x0000000000429000
70x335000 0x0000000000335000
80xc740 0x000000000000c740
90x1000 0x0000000000009098
10SONAME libglib-2.0.so.0
11
12(which should be RPATH and DT_NEEDED entries)
13
14This was tracked down to the code which injects the PT_LOAD section.
15
16The issue is that if the program headers were previously relocated to the end
17of the file which was how patchelf operated previously, the relocation code
18wouldn't work properly on a second run as it now assumes they're located after
19the elf header. This change forces them back to immediately follow the elf
20header which is where the code has made space for them.
21
22Upstream-Status: Submitted [https://github.com/NixOS/patchelf/pull/202]
23Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
24RP 2020/6/2
25
26Index: 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/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 <fabio.berton@ossystems.com.br>
14 src/patchelf.cc | 16 +++++++++++++++- 14 src/patchelf.cc | 16 +++++++++++++++-
15 1 file changed, 15 insertions(+), 1 deletion(-) 15 1 file changed, 15 insertions(+), 1 deletion(-)
16 16
17diff --git a/src/patchelf.cc b/src/patchelf.cc 17Index: git/src/patchelf.cc
18index 0b4965adff83..b5db2aef0e8a 100644 18===================================================================
19--- a/src/patchelf.cc 19--- git.orig/src/patchelf.cc
20+++ b/src/patchelf.cc 20+++ git/src/patchelf.cc
21@@ -497,7 +497,17 @@ void ElfFile<ElfFileParamNames>::sortShdrs() 21@@ -499,9 +499,19 @@ void ElfFile<ElfFileParamNames>::sortShd
22 22
23 static void writeFile(std::string fileName, FileContents contents) 23 static void writeFile(std::string fileName, FileContents contents)
24 { 24 {
25- int fd = open(fileName.c_str(), O_TRUNC | O_WRONLY);
26+ struct stat st; 25+ struct stat st;
27+ int fd; 26+ int fd;
28+ 27+
28 debug("writing %s\n", fileName.c_str());
29
30- int fd = open(fileName.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0777);
29+ if (stat(fileName.c_str(), &st) != 0) 31+ if (stat(fileName.c_str(), &st) != 0)
30+ error("stat"); 32+ error("stat");
31+ 33+
32+ if (chmod(fileName.c_str(), 0600) != 0) 34+ if (chmod(fileName.c_str(), 0600) != 0)
33+ error("chmod"); 35+ error("chmod");
34+ 36+
35+ fd = open(fileName.c_str(), O_TRUNC | O_WRONLY); 37+ fd = open(fileName.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0777);
36+ 38+
37 if (fd == -1) 39 if (fd == -1)
38 error("open"); 40 error("open");
39 41
40@@ -511,6 +521,10 @@ static void writeFile(std::string fileName, FileContents contents) 42@@ -515,6 +525,10 @@ static void writeFile(std::string fileNa
41 43
42 if (close(fd) != 0) 44 if (close(fd) != 0)
43 error("close"); 45 error("close");
diff --git a/meta/recipes-devtools/patchelf/patchelf_0.10.bb b/meta/recipes-devtools/patchelf/patchelf_0.11.bb
index 84e640773b..ba7ad404e9 100644
--- a/meta/recipes-devtools/patchelf/patchelf_0.10.bb
+++ b/meta/recipes-devtools/patchelf/patchelf_0.11.bb
@@ -1,13 +1,11 @@
1SRC_URI = "git://github.com/NixOS/patchelf;protocol=https \ 1SRC_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 \
4 file://fix-phdrs.patch \
5 " 3 "
6 4
7LICENSE = "GPLv3" 5LICENSE = "GPLv3"
8SUMMARY = "Tool to allow editing of RPATH and interpreter fields in ELF binaries" 6SUMMARY = "Tool to allow editing of RPATH and interpreter fields in ELF binaries"
9 7
10SRCREV = "e1e39f3639e39360ceebb2f7ed533cede4623070" 8SRCREV = "d6b2a72d9ec3bdfde4b1aacdada823ce388968bb"
11 9
12S = "${WORKDIR}/git" 10S = "${WORKDIR}/git"
13 11