From afdd21a299ad0ebf4ee33fa96d390f881a3cc713 Mon Sep 17 00:00:00 2001 From: mk Date: Sun, 10 Sep 2023 15:28:46 -0700 Subject: [PATCH] check all sections if they need a rewrite --- src/patchelf.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/patchelf.cc b/src/patchelf.cc index 82b4b46c..716c4e0c 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -824,13 +824,11 @@ void ElfFile::rewriteSectionsLibrary() to overlap the program header table in memory; we need to shift the first few segments to someplace else. */ /* Some sections may already be replaced so account for that */ - unsigned int i = 1; Elf_Addr pht_size = sizeof(Elf_Ehdr) + (phdrs.size() + num_notes + 1)*sizeof(Elf_Phdr); - while( i < rdi(hdr()->e_shnum) && rdi(shdrs.at(i).sh_offset) <= pht_size ) { - if (not haveReplacedSection(getSectionName(shdrs.at(i)))) - replaceSection(getSectionName(shdrs.at(i)), rdi(shdrs.at(i).sh_size)); - i++; - } + for (unsigned int i = 1; i < rdi(hdr()->e_shnum); ++i) + if (rdi(shdrs.at(i).sh_offset) <= pht_size) + if (not haveReplacedSection(getSectionName(shdrs.at(i)))) + replaceSection(getSectionName(shdrs.at(i)), rdi(shdrs.at(i).sh_size)); bool moveHeaderTableToTheEnd = rdi(hdr()->e_shoff) < pht_size; /* Compute the total space needed for the replaced sections */