mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 13:29:49 +00:00
patchelf: upgrade 0.12 -> 0.13
(From OE-Core rev: 9fdfa49ac11eff7215fab8540114535b2c652b83) Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
9a262e9038
commit
253fca8246
-44
@@ -1,44 +0,0 @@
|
|||||||
From 6edec83653ce1b5fc201ff6db93b966394766814 Mon Sep 17 00:00:00 2001
|
|
||||||
From: rmnull <rmnull@users.noreply.github.com>
|
|
||||||
Date: Tue, 18 Aug 2020 20:22:52 +0530
|
|
||||||
Subject: [PATCH] mark phdrs synced with sections, avoid rechecking it when
|
|
||||||
syncing note sections to segments.
|
|
||||||
|
|
||||||
This also serves as a bug fix when a previously synced note segment
|
|
||||||
overlaps with another section and creates a false alarm.
|
|
||||||
|
|
||||||
Upstream-Status: Backport
|
|
||||||
---
|
|
||||||
src/patchelf.cc | 5 ++++-
|
|
||||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/src/patchelf.cc b/src/patchelf.cc
|
|
||||||
index 05ec793..622f0b6 100644
|
|
||||||
--- a/src/patchelf.cc
|
|
||||||
+++ b/src/patchelf.cc
|
|
||||||
@@ -669,6 +669,7 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
|
|
||||||
memset(contents + rdi(shdr.sh_offset), 'X', rdi(shdr.sh_size));
|
|
||||||
}
|
|
||||||
|
|
||||||
+ std::set<unsigned int> noted_phdrs = {};
|
|
||||||
for (auto & i : replacedSections) {
|
|
||||||
std::string sectionName = i.first;
|
|
||||||
auto & shdr = findSection(sectionName);
|
|
||||||
@@ -721,7 +722,7 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
|
|
||||||
shdr.sh_addralign = orig_shdr.sh_addralign;
|
|
||||||
|
|
||||||
for (unsigned int j = 0; j < phdrs.size(); ++j)
|
|
||||||
- if (rdi(phdrs[j].p_type) == PT_NOTE) {
|
|
||||||
+ if (rdi(phdrs[j].p_type) == PT_NOTE && noted_phdrs.find(j) == noted_phdrs.end()) {
|
|
||||||
Elf_Off p_start = rdi(phdrs[j].p_offset);
|
|
||||||
Elf_Off p_end = p_start + rdi(phdrs[j].p_filesz);
|
|
||||||
Elf_Off s_start = rdi(orig_shdr.sh_offset);
|
|
||||||
@@ -739,6 +740,8 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
|
|
||||||
phdrs[j].p_offset = shdr.sh_offset;
|
|
||||||
phdrs[j].p_vaddr = phdrs[j].p_paddr = shdr.sh_addr;
|
|
||||||
phdrs[j].p_filesz = phdrs[j].p_memsz = shdr.sh_size;
|
|
||||||
+
|
|
||||||
+ noted_phdrs.insert(j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
If a binary has multiple SHT_NOTE sections and corresponding PT_NOTE
|
|
||||||
headers, we can see the error:
|
|
||||||
|
|
||||||
patchelf: cannot normalize PT_NOTE segment: non-contiguous SHT_NOTE sections
|
|
||||||
|
|
||||||
if the SHT_NOTE sections aren't sized to end on aligned boundaries. An example
|
|
||||||
would be a binary with:
|
|
||||||
|
|
||||||
[ 2] .note.ABI-tag NOTE 00000000000002f4 000002f4
|
|
||||||
0000000000000020 0000000000000000 A 0 0 4
|
|
||||||
[ 3] .note.gnu.propert NOTE 0000000000000318 00000318
|
|
||||||
0000000000000030 0000000000000000 A 0 0 8
|
|
||||||
[ 4] .note.gnu.build-i NOTE 0000000000000348 00000348
|
|
||||||
0000000000000024 0000000000000000 A 0 0 4
|
|
||||||
|
|
||||||
NOTE 0x0000000000000318 0x0000000000000318 0x0000000000000318
|
|
||||||
0x0000000000000030 0x0000000000000030 R 0x8
|
|
||||||
NOTE 0x00000000000002f4 0x00000000000002f4 0x00000000000002f4
|
|
||||||
0x0000000000000078 0x0000000000000074 R 0x4
|
|
||||||
|
|
||||||
since the PT_NOTE section at 2f4 covers [2] and [3] but the code
|
|
||||||
calclates curr_off should be 314, not the 318 in the binary. This
|
|
||||||
is an alignment issue.
|
|
||||||
|
|
||||||
To fix this, we need to round curr_off to the next section alignment.
|
|
||||||
|
|
||||||
Upstream-Status: Submitted [https://github.com/NixOS/patchelf/pull/274]
|
|
||||||
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
|
|
||||||
|
|
||||||
Index: git/src/patchelf.cc
|
|
||||||
===================================================================
|
|
||||||
--- git.orig/src/patchelf.cc
|
|
||||||
+++ git/src/patchelf.cc
|
|
||||||
@@ -1010,8 +1010,9 @@ void ElfFile<ElfFileParamNames>::normali
|
|
||||||
size_t size = 0;
|
|
||||||
for (const auto & shdr : shdrs) {
|
|
||||||
if (rdi(shdr.sh_type) != SHT_NOTE) continue;
|
|
||||||
- if (rdi(shdr.sh_offset) != curr_off) continue;
|
|
||||||
+ if (rdi(shdr.sh_offset) != roundUp(curr_off, rdi(shdr.sh_addralign))) continue;
|
|
||||||
size = rdi(shdr.sh_size);
|
|
||||||
+ curr_off = roundUp(curr_off, rdi(shdr.sh_addralign));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (size == 0)
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
From 7f1fd10cfebd5ea2f3e1938abe1bd1c4828164a7 Mon Sep 17 00:00:00 2001
|
From 682fb48c137b687477008b68863c2a0b73ed47d1 Mon Sep 17 00:00:00 2001
|
||||||
From: Fabio Berton <fabio.berton@ossystems.com.br>
|
From: Fabio Berton <fabio.berton@ossystems.com.br>
|
||||||
Date: Fri, 9 Sep 2016 16:00:42 -0300
|
Date: Fri, 9 Sep 2016 16:00:42 -0300
|
||||||
Subject: [PATCH] handle read-only files
|
Subject: [PATCH] handle read-only files
|
||||||
@@ -14,13 +14,13 @@ Signed-off-by: Fabio Berton <fabio.berton@ossystems.com.br>
|
|||||||
src/patchelf.cc | 16 +++++++++++++++-
|
src/patchelf.cc | 16 +++++++++++++++-
|
||||||
1 file changed, 15 insertions(+), 1 deletion(-)
|
1 file changed, 15 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
Index: git/src/patchelf.cc
|
diff --git a/src/patchelf.cc b/src/patchelf.cc
|
||||||
===================================================================
|
index fd1e7b7..a941da1 100644
|
||||||
--- git.orig/src/patchelf.cc
|
--- a/src/patchelf.cc
|
||||||
+++ git/src/patchelf.cc
|
+++ b/src/patchelf.cc
|
||||||
@@ -499,9 +499,19 @@ void ElfFile<ElfFileParamNames>::sortShd
|
@@ -527,9 +527,19 @@ void ElfFile<ElfFileParamNames>::sortShdrs()
|
||||||
|
|
||||||
static void writeFile(std::string fileName, FileContents contents)
|
static void writeFile(const std::string & fileName, const FileContents & contents)
|
||||||
{
|
{
|
||||||
+ struct stat st;
|
+ struct stat st;
|
||||||
+ int fd;
|
+ int fd;
|
||||||
@@ -39,7 +39,7 @@ Index: git/src/patchelf.cc
|
|||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
error("open");
|
error("open");
|
||||||
|
|
||||||
@@ -515,6 +525,10 @@ static void writeFile(std::string fileNa
|
@@ -543,6 +553,10 @@ static void writeFile(const std::string & fileName, const FileContents & content
|
||||||
|
|
||||||
if (close(fd) != 0)
|
if (close(fd) != 0)
|
||||||
error("close");
|
error("close");
|
||||||
|
|||||||
+1
-3
@@ -6,10 +6,8 @@ LICENSE = "GPLv3"
|
|||||||
|
|
||||||
SRC_URI = "git://github.com/NixOS/patchelf;protocol=https \
|
SRC_URI = "git://github.com/NixOS/patchelf;protocol=https \
|
||||||
file://handle-read-only-files.patch \
|
file://handle-read-only-files.patch \
|
||||||
file://6edec83653ce1b5fc201ff6db93b966394766814.patch \
|
|
||||||
file://alignmentfix.patch \
|
|
||||||
"
|
"
|
||||||
SRCREV = "8d3a16e97294e3c5521c61b4c8835499c9918264"
|
SRCREV = "a949ff23315bbb5863627c4655fe216ecbf341a2"
|
||||||
|
|
||||||
S = "${WORKDIR}/git"
|
S = "${WORKDIR}/git"
|
||||||
|
|
||||||
Reference in New Issue
Block a user