xref: /OK3568_Linux_fs/buildroot/package/patchelf/0007-fix-adjusting-startPage.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From 4a82c97e8a0677706d1d532812daaa73249768a8 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] fix adjusting startPage
5
6startPage is adjusted unconditionally for all executables.
7This results in incorrect addresses assigned to INTERP and LOAD
8program headers, which breaks patched executable.
9
10Adjusting startPage variable only when startOffset > startPage
11should fix this.
12
13This change is related to the issue NixOS#10
14
15Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
16
17Fetch from: https://github.com/NixOS/patchelf/commit/1cc234fea5600190d872329aca60e2365cefc39e
18
19Backported to v0.9
20
21Signed-off-by: Conrad Ratschan <conrad.ratschan@rockwellcollins.com>
22---
23 src/patchelf.cc | 6 ++----
24 1 file changed, 2 insertions(+), 4 deletions(-)
25
26diff --git a/src/patchelf.cc b/src/patchelf.cc
27index 1224a89..4676157 100644
28--- a/src/patchelf.cc
29+++ b/src/patchelf.cc
30@@ -697,10 +697,8 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
31        since DYN executables tend to start at virtual address 0, so
32        rewriteSectionsExecutable() won't work because it doesn't have
33        any virtual address space to grow downwards into. */
34-    if (isExecutable) {
35-        if (startOffset >= startPage) {
36-            debug("shifting new PT_LOAD segment by %d bytes to work around a Linux kernel bug\n", startOffset - startPage);
37-        }
38+    if (isExecutable && startOffset > startPage) {
39+        debug("shifting new PT_LOAD segment by %d bytes to work around a Linux kernel bug\n", startOffset - startPage);
40         startPage = startOffset;
41     }
42
43--
442.17.1
45
46