mirror of
https://git.yoctoproject.org/poky
synced 2026-04-10 23:02:25 +02:00
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>
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
From 1630d3f846c7721b1e7cd3b005bb2b34816e1d0f Mon Sep 17 00:00:00 2001
|
||||
From: Ed Bartosh <ed.bartosh@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.bartosh@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;
|
||||
}
|
||||
|
||||
@@ -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.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];
|
||||
@@ -14,30 +14,32 @@ Signed-off-by: Fabio Berton <fabio.berton@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");
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user