Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG FIX] false alarm for non overlapping sections #230

Merged
merged 1 commit into from
Nov 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/patchelf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
memset(contents + rdi(shdr.sh_offset), 'X', rdi(shdr.sh_size));
}

std::set<unsigned int> noted_phdrs = {};
rmNULL marked this conversation as resolved.
Show resolved Hide resolved
for (auto & i : replacedSections) {
std::string sectionName = i.first;
auto & shdr = findSection(sectionName);
Expand Down Expand Up @@ -721,7 +722,7 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
shdr.sh_addralign = orig_shdr.sh_addralign;

for (unsigned int j = 0; j < phdrs.size(); ++j)
if (rdi(phdrs[j].p_type) == PT_NOTE) {
if (rdi(phdrs[j].p_type) == PT_NOTE && noted_phdrs.find(j) == noted_phdrs.end()) {
rmNULL marked this conversation as resolved.
Show resolved Hide resolved
Elf_Off p_start = rdi(phdrs[j].p_offset);
Elf_Off p_end = p_start + rdi(phdrs[j].p_filesz);
Elf_Off s_start = rdi(orig_shdr.sh_offset);
Expand All @@ -739,6 +740,8 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
phdrs[j].p_offset = shdr.sh_offset;
phdrs[j].p_vaddr = phdrs[j].p_paddr = shdr.sh_addr;
phdrs[j].p_filesz = phdrs[j].p_memsz = shdr.sh_size;

noted_phdrs.insert(j);
rmNULL marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down