]> code.ossystems Code Review - openembedded-core.git/commitdiff
patchelf: Fix alignment patch
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 2 May 2021 11:11:20 +0000 (12:11 +0100)
committerAnuj Mittal <anuj.mittal@intel.com>
Thu, 6 May 2021 02:09:37 +0000 (10:09 +0800)
The previous fix was in the right direction but needed to account
for the section alignment of the current section. Tweak the patch
to handle this.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit e464efc07a8997c43998a9c6a9544be11ab4f303)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
meta/recipes-devtools/patchelf/patchelf/alignmentfix.patch

index 62e11a5e7f82cfa68e62cd744186cb11c12323b7..a06876e50a1b4dd0cfd01d0cf0348868366aafd5 100644 (file)
@@ -31,12 +31,14 @@ Index: git/src/patchelf.cc
 ===================================================================
 --- git.orig/src/patchelf.cc
 +++ git/src/patchelf.cc
-@@ -1035,6 +1035,8 @@ void ElfFile<ElfFileParamNames>::normali
-                 phdrs.push_back(new_phdr);
-             curr_off += size;
-+            /* The next section offset would be aligned */
-+            curr_off = roundUp(curr_off, sectionAlignment);
-         }
-     }
-     wri(hdr->e_phnum, phdrs.size());
+@@ -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)