mirror of
https://git.yoctoproject.org/poky
synced 2026-09-19 00:49:33 +02:00
patchelf: fix PT_PHDR program header corruption
Backport patch and tweak it to fix PT_PHDR program header corruption. (From OE-Core rev: a980aa5696a98c5b97f9a117df4c82ea525f6e4f) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -0,0 +1,47 @@
|
|||||||
|
From 6ac5c1350834b9da81ab90ab5ba4e5bf507c6c0d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Satadru Pramanik <satadru@gmail.com>
|
||||||
|
Date: Thu, 20 May 2021 16:52:21 -0400
|
||||||
|
Subject: [PATCH] merge from PR243
|
||||||
|
|
||||||
|
Upstream-Status: Backport
|
||||||
|
|
||||||
|
Reference to upstream patch:
|
||||||
|
https://github.com/NixOS/patchelf/commit/4efbce410d00c8cb43f134181d07b364bcf78022
|
||||||
|
|
||||||
|
[OP: tweak patch to apply to patchelf v0.10]
|
||||||
|
Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
|
||||||
|
[OP: tweak patch to apply to patchelf v0.12]
|
||||||
|
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
|
||||||
|
---
|
||||||
|
src/patchelf.cc | 5 ++++-
|
||||||
|
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/patchelf.cc b/src/patchelf.cc
|
||||||
|
index 1854cfa..73a3a86 100644
|
||||||
|
--- a/src/patchelf.cc
|
||||||
|
+++ b/src/patchelf.cc
|
||||||
|
@@ -774,12 +774,15 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
|
||||||
|
PT_LOAD segment located directly after the last virtual address
|
||||||
|
page of other segments. */
|
||||||
|
Elf_Addr startPage = 0;
|
||||||
|
+ Elf_Addr firstPage = 0;
|
||||||
|
for (unsigned int i = 0; i < phdrs.size(); ++i) {
|
||||||
|
Elf_Addr thisPage = roundUp(rdi(phdrs[i].p_vaddr) + rdi(phdrs[i].p_memsz), getPageSize());
|
||||||
|
if (thisPage > startPage) startPage = thisPage;
|
||||||
|
+ if (rdi(phdrs[i].p_type) == PT_PHDR) firstPage = rdi(phdrs[i].p_vaddr) - rdi(phdrs[i].p_offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
debug("last page is 0x%llx\n", (unsigned long long) startPage);
|
||||||
|
+ debug("first page is 0x%llx\n", (unsigned long long) firstPage);
|
||||||
|
|
||||||
|
/* When normalizing note segments we will in the worst case be adding
|
||||||
|
1 program header for each SHT_NOTE section. */
|
||||||
|
@@ -852,7 +855,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
|
||||||
|
assert(curOff == startOffset + neededSpace);
|
||||||
|
|
||||||
|
/* Write out the updated program and section headers */
|
||||||
|
- rewriteHeaders(hdr->e_phoff);
|
||||||
|
+ rewriteHeaders(firstPage + hdr->e_phoff);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -8,6 +8,7 @@ SRC_URI = "git://github.com/NixOS/patchelf;protocol=https;branch=master \
|
|||||||
file://handle-read-only-files.patch \
|
file://handle-read-only-files.patch \
|
||||||
file://6edec83653ce1b5fc201ff6db93b966394766814.patch \
|
file://6edec83653ce1b5fc201ff6db93b966394766814.patch \
|
||||||
file://alignmentfix.patch \
|
file://alignmentfix.patch \
|
||||||
|
file://0001-merge-from-PR243.patch \
|
||||||
"
|
"
|
||||||
SRCREV = "8d3a16e97294e3c5521c61b4c8835499c9918264"
|
SRCREV = "8d3a16e97294e3c5521c61b4c8835499c9918264"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user