summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-05-01 17:10:21 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-05-01 22:43:11 +0100
commitcde414f5710b4f6a428dd99e2876bcc9bede972b (patch)
treec978d6f4a329e5f05d83d0ae15734e5a0b6d23a3 /meta/recipes-devtools
parent19c365d040eb50a52fc7211a2d0aa223c4a6e0f8 (diff)
downloadpoky-cde414f5710b4f6a428dd99e2876bcc9bede972b.tar.gz
patchelf: Fix note section alignment issues
Improve note section normalization was added to patchelf in recent versions however if fails if there are two note sections which aren't sized to match section alignment. Tweak the code to account for section alignment. This fixes patchelf failures on the autobuilder, particularly to ccache-native. (From OE-Core rev: fee8dde0d597b511b37d8dcf215e8355980d5f2b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/patchelf/patchelf/alignmentfix.patch42
-rw-r--r--meta/recipes-devtools/patchelf/patchelf_0.12.bb1
2 files changed, 43 insertions, 0 deletions
diff --git a/meta/recipes-devtools/patchelf/patchelf/alignmentfix.patch b/meta/recipes-devtools/patchelf/patchelf/alignmentfix.patch
new file mode 100644
index 0000000000..62e11a5e7f
--- /dev/null
+++ b/meta/recipes-devtools/patchelf/patchelf/alignmentfix.patch
@@ -0,0 +1,42 @@
1If a binary has multiple SHT_NOTE sections and corresponding PT_NOTE
2headers, we can see the error:
3
4patchelf: cannot normalize PT_NOTE segment: non-contiguous SHT_NOTE sections
5
6if the SHT_NOTE sections aren't sized to end on aligned boundaries. An example
7would be a binary with:
8
9 [ 2] .note.ABI-tag NOTE 00000000000002f4 000002f4
10 0000000000000020 0000000000000000 A 0 0 4
11 [ 3] .note.gnu.propert NOTE 0000000000000318 00000318
12 0000000000000030 0000000000000000 A 0 0 8
13 [ 4] .note.gnu.build-i NOTE 0000000000000348 00000348
14 0000000000000024 0000000000000000 A 0 0 4
15
16 NOTE 0x0000000000000318 0x0000000000000318 0x0000000000000318
17 0x0000000000000030 0x0000000000000030 R 0x8
18 NOTE 0x00000000000002f4 0x00000000000002f4 0x00000000000002f4
19 0x0000000000000078 0x0000000000000074 R 0x4
20
21since the PT_NOTE section at 2f4 covers [2] and [3] but the code
22calclates curr_off should be 314, not the 318 in the binary. This
23is an alignment issue.
24
25To fix this, we need to round curr_off to the next section alignment.
26
27Upstream-Status: Submitted [https://github.com/NixOS/patchelf/pull/274]
28Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
29
30Index: git/src/patchelf.cc
31===================================================================
32--- git.orig/src/patchelf.cc
33+++ git/src/patchelf.cc
34@@ -1035,6 +1035,8 @@ void ElfFile<ElfFileParamNames>::normali
35 phdrs.push_back(new_phdr);
36
37 curr_off += size;
38+ /* The next section offset would be aligned */
39+ curr_off = roundUp(curr_off, sectionAlignment);
40 }
41 }
42 wri(hdr->e_phnum, phdrs.size());
diff --git a/meta/recipes-devtools/patchelf/patchelf_0.12.bb b/meta/recipes-devtools/patchelf/patchelf_0.12.bb
index 2eb09aee32..7c97ea0789 100644
--- a/meta/recipes-devtools/patchelf/patchelf_0.12.bb
+++ b/meta/recipes-devtools/patchelf/patchelf_0.12.bb
@@ -7,6 +7,7 @@ LICENSE = "GPLv3"
7SRC_URI = "git://github.com/NixOS/patchelf;protocol=https \ 7SRC_URI = "git://github.com/NixOS/patchelf;protocol=https \
8 file://handle-read-only-files.patch \ 8 file://handle-read-only-files.patch \
9 file://6edec83653ce1b5fc201ff6db93b966394766814.patch \ 9 file://6edec83653ce1b5fc201ff6db93b966394766814.patch \
10 file://alignmentfix.patch \
10 " 11 "
11SRCREV = "8d3a16e97294e3c5521c61b4c8835499c9918264" 12SRCREV = "8d3a16e97294e3c5521c61b4c8835499c9918264"
12 13