summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2017-07-21 09:33:53 (GMT)
committerEd Bartosh <ed.bartosh@linux.intel.com>2017-07-21 09:49:30 (GMT)
commit1cc234fea5600190d872329aca60e2365cefc39e (patch)
treee25305097bafbbc075b34c49bdbfbec9e3f649fe
parentc4deb5e9e1ce9c98a48e0d5bb37d87739b8cfee4 (diff)
downloadpatchelf-1cc234fea5600190d872329aca60e2365cefc39e.zip
patchelf-1cc234fea5600190d872329aca60e2365cefc39e.tar.gz
patchelf-1cc234fea5600190d872329aca60e2365cefc39e.tar.bz2
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>
-rw-r--r--src/patchelf.cc6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/patchelf.cc b/src/patchelf.cc
index cbd36c0..e9d7ea5 100644
--- a/src/patchelf.cc
+++ b/src/patchelf.cc
@@ -720,10 +720,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;
}