mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Zero ElfXX_Ehdr.e_sh* info when removing ElfXX_Shdr
The aim is less confusion by static linkers: the _Shdr are gone! https://github.com/upx/upx/issues/659 modified: p_lx_elf.cpp
This commit is contained in:
parent
f8934c09ff
commit
35333403ef
|
@ -5507,6 +5507,14 @@ void PackLinuxElf32::pack4(OutputFile *fo, Filter &ft)
|
||||||
set_te32(&phdro->p_flags, Elf32_Phdr::PF_X | get_te32(&phdro->p_flags));
|
set_te32(&phdro->p_flags, Elf32_Phdr::PF_X | get_te32(&phdro->p_flags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!sec_arm_attr && !saved_opt_android_shlib) {
|
||||||
|
// Make it abunantly clear that there are no Elf32_Shdr in this shlib
|
||||||
|
Elf32_Ehdr *ehdro = (Elf32_Ehdr *)lowmem.getVoidPtr();
|
||||||
|
ehdro->e_shoff = 0;
|
||||||
|
ehdro->e_shentsize = 0;
|
||||||
|
ehdro->e_shnum = 0;
|
||||||
|
ehdro->e_shstrndx = 0;
|
||||||
|
}
|
||||||
fo->rewrite(&lowmem[0], sizeof(ehdri) + e_phnum * sizeof(*phdri));
|
fo->rewrite(&lowmem[0], sizeof(ehdri) + e_phnum * sizeof(*phdri));
|
||||||
fo->seek(linfo_off, SEEK_SET);
|
fo->seek(linfo_off, SEEK_SET);
|
||||||
fo->rewrite(&linfo, sizeof(linfo)); // new info: l_checksum, l_size
|
fo->rewrite(&linfo, sizeof(linfo)); // new info: l_checksum, l_size
|
||||||
|
@ -5581,6 +5589,13 @@ void PackLinuxElf64::pack4(OutputFile *fo, Filter &ft)
|
||||||
set_te64(&phdro->p_flags, Elf64_Phdr::PF_X | get_te64(&phdro->p_flags));
|
set_te64(&phdro->p_flags, Elf64_Phdr::PF_X | get_te64(&phdro->p_flags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Make it abundantly clear that there are no Elf64_Shdr in a compressed shlib
|
||||||
|
Elf64_Ehdr *ehdro = (Elf64_Ehdr *)lowmem.getVoidPtr();
|
||||||
|
ehdro->e_shoff = 0;
|
||||||
|
ehdro->e_shentsize = 0;
|
||||||
|
ehdro->e_shnum = 0;
|
||||||
|
ehdro->e_shstrndx = 0;
|
||||||
|
|
||||||
fo->rewrite(&lowmem[0], sizeof(ehdri) + e_phnum * sizeof(*phdri));
|
fo->rewrite(&lowmem[0], sizeof(ehdri) + e_phnum * sizeof(*phdri));
|
||||||
fo->seek(linfo_off, SEEK_SET);
|
fo->seek(linfo_off, SEEK_SET);
|
||||||
fo->rewrite(&linfo, sizeof(linfo)); // new info: l_checksum, l_size
|
fo->rewrite(&linfo, sizeof(linfo)); // new info: l_checksum, l_size
|
||||||
|
|
Loading…
Reference in New Issue
Block a user