summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBreno Rodrigues Guimarães <brenorg@gmail.com>2023-02-19 09:27:44 -0300
committerGitHub <noreply@github.com>2023-02-19 09:27:44 -0300
commit313c6115b7988f65d2823d37b330a91b39c8f415 (patch)
tree3a2198829738086b7274c4304b7798497f2bcc5b
parentd925e8c91d06a7099cf03b39ec481f5f43107506 (diff)
downloadpatchelf-313c6115b7988f65d2823d37b330a91b39c8f415.tar.gz
Update src/patchelf.cc
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
-rw-r--r--src/patchelf.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/patchelf.cc b/src/patchelf.cc
index af00172..f194cad 100644
--- a/src/patchelf.cc
+++ b/src/patchelf.cc
@@ -799,7 +799,8 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
bool needNewSegment = true;
auto& lastSeg = phdrs.back();
/* Try to extend the last segment to include replaced sections */
- if (rdi(lastSeg.p_type) == PT_LOAD &&
+ if (phdrs.size() &&
+ rdi(lastSeg.p_type) == PT_LOAD &&
rdi(lastSeg.p_flags) == (PF_R | PF_W) &&
rdi(lastSeg.p_align) == getPageSize()) {
auto segEnd = roundUp(rdi(lastSeg.p_offset) + rdi(lastSeg.p_memsz), getPageSize());