mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Fix PT_LOAD for ELF shared library.
modified: p_lx_elf.cpp
This commit is contained in:
parent
1a5ba22fe7
commit
6489ec9bba
|
@ -430,7 +430,11 @@ off_t PackLinuxElf32::pack3(OutputFile *fo, Filter &ft)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (PT_LOAD32 == type) {
|
if (PT_LOAD32 == type) {
|
||||||
if (xct_off < ioff) { // Slide up non-first PT_LOAD.
|
if ((xct_off - ioff) < len) { // Change length of compressed PT_LOAD.
|
||||||
|
set_te32(&phdr->p_filesz, sz_pack2 + lsize - ioff);
|
||||||
|
set_te32(&phdr->p_memsz, sz_pack2 + lsize - ioff);
|
||||||
|
}
|
||||||
|
else if (xct_off < ioff) { // Slide subsequent PT_LOAD.
|
||||||
if ((1u<<12) < align) {
|
if ((1u<<12) < align) {
|
||||||
align = 1u<<12;
|
align = 1u<<12;
|
||||||
set_te32(&phdr->p_align, align);
|
set_te32(&phdr->p_align, align);
|
||||||
|
@ -441,10 +445,6 @@ off_t PackLinuxElf32::pack3(OutputFile *fo, Filter &ft)
|
||||||
so_slide = off - ioff;
|
so_slide = off - ioff;
|
||||||
set_te32(&phdr->p_offset, so_slide + ioff);
|
set_te32(&phdr->p_offset, so_slide + ioff);
|
||||||
}
|
}
|
||||||
else if ((ioff - xct_off) < len) { // Change length of compressed PT_LOAD.
|
|
||||||
set_te32(&phdr->p_filesz, sz_pack2 + lsize - ioff);
|
|
||||||
set_te32(&phdr->p_memsz, sz_pack2 + lsize - ioff);
|
|
||||||
}
|
|
||||||
continue; // all done with this PT_LOAD
|
continue; // all done with this PT_LOAD
|
||||||
}
|
}
|
||||||
if (xct_off < ioff)
|
if (xct_off < ioff)
|
||||||
|
@ -554,7 +554,11 @@ off_t PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (PT_LOAD64 == type) {
|
if (PT_LOAD64 == type) {
|
||||||
if (xct_off < ioff) { // Slide up non-first PT_LOAD.
|
if ((xct_off - ioff) < len) { // Change length of compressed PT_LOAD.
|
||||||
|
set_te64(&phdr->p_filesz, sz_pack2 + lsize - ioff);
|
||||||
|
set_te64(&phdr->p_memsz, sz_pack2 + lsize - ioff);
|
||||||
|
}
|
||||||
|
else if (xct_off < ioff) { // Slide subsequent PT_LOAD.
|
||||||
// AMD64 chip supports page sizes of 4KiB, 2MiB, and 1GiB;
|
// AMD64 chip supports page sizes of 4KiB, 2MiB, and 1GiB;
|
||||||
// the operating system chooses one. .p_align typically
|
// the operating system chooses one. .p_align typically
|
||||||
// is a forward-looking 2MiB. In 2009 Linux chooses 4KiB.
|
// is a forward-looking 2MiB. In 2009 Linux chooses 4KiB.
|
||||||
|
@ -570,10 +574,6 @@ off_t PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
|
||||||
so_slide = off - ioff;
|
so_slide = off - ioff;
|
||||||
set_te64(&phdr->p_offset, so_slide + ioff);
|
set_te64(&phdr->p_offset, so_slide + ioff);
|
||||||
}
|
}
|
||||||
else if ((ioff - xct_off) < len) { // Change length of compressed PT_LOAD.
|
|
||||||
set_te64(&phdr->p_filesz, sz_pack2 + lsize - ioff);
|
|
||||||
set_te64(&phdr->p_memsz, sz_pack2 + lsize - ioff);
|
|
||||||
}
|
|
||||||
continue; // all done with this PT_LOAD
|
continue; // all done with this PT_LOAD
|
||||||
}
|
}
|
||||||
if (xct_off < ioff)
|
if (xct_off < ioff)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user