Skip to content

Commit 3a6d771

Browse files
author
Jason
committed
Revert "shiftFile: when splitting a segment into two pieces, preserve the original flags in both"
This reverts commit f4f1848.
1 parent 8d2cb4f commit 3a6d771

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/patchelf.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,6 @@ void ElfFile<ElfFileParamNames>::shiftFile(unsigned int extraPages, size_t start
463463

464464
int splitIndex = -1;
465465
size_t splitShift = 0;
466-
/* Save off the flags from the segment that we are splitting so we can apply the same value
467-
to both of the resulting segments. */
468-
decltype(phdrs.at(0).p_flags) splitFlags = 0;
469466

470467
/* Update the offsets in the program headers. */
471468
for (int i = 0; i < rdi(hdr()->e_phnum); ++i) {
@@ -476,7 +473,6 @@ void ElfFile<ElfFileParamNames>::shiftFile(unsigned int extraPages, size_t start
476473

477474
splitIndex = i;
478475
splitShift = startOffset - p_start;
479-
splitFlags = rdi(phdrs.at(i).p_flags);
480476

481477
/* This is the load segment we're currently extending within, so we split it. */
482478
wri(phdrs.at(i).p_offset, startOffset);
@@ -517,7 +513,7 @@ void ElfFile<ElfFileParamNames>::shiftFile(unsigned int extraPages, size_t start
517513
wri(phdr.p_paddr, phdrs.at(splitIndex).p_paddr - splitShift - shift);
518514
wri(phdr.p_vaddr, phdrs.at(splitIndex).p_vaddr - splitShift - shift);
519515
wri(phdr.p_filesz, wri(phdr.p_memsz, splitShift + extraBytes));
520-
wri(phdr.p_flags, splitFlags);
516+
wri(phdr.p_flags, PF_R | PF_W);
521517
wri(phdr.p_align, getPageSize());
522518
}
523519

0 commit comments

Comments
 (0)