Another checkAlreadyPacked()

https://github.com/upx/upx/issues/463
	modified:   Makefile
	modified:   p_mach.cpp
This commit is contained in:
John Reiser 2021-02-26 15:15:28 -08:00 committed by Markus F.X.J. Oberhumer
parent 1c29f921e0
commit fd6837b267
2 changed files with 13 additions and 2 deletions

View File

@ -10,7 +10,7 @@ export SHELL = /bin/sh
# build configuration options for this Makefile
BUILD_TYPE_DEBUG ?= 1
BUILD_TYPE_SANITIZE ?= 1
BUILD_TYPE_SANITIZE ?= 0
BUILD_USE_DEPEND ?= 1
ifndef srcdir

View File

@ -1844,6 +1844,17 @@ bool PackMachBase<T>::canPack()
headway -= ((Mach_command const *)ptr)->cmdsize;
if (lc_seg == segptr->cmd) {
msegcmd[j] = *segptr;
if (!strcmp("__TEXT", segptr->segname)) {
Mach_section_command const *secp =
(Mach_section_command const *)(const void*)(const char*)(1+ segptr);
unsigned const offset = secp->offset;
if (offset < file_size) {
struct l_info h;
fi->seek(offset, SEEK_SET);
fi->readx(&h, sizeof(h));
checkAlreadyPacked(&h, sizeof(h));
}
}
if (!strcmp("__DATA", segptr->segname)) {
prev_mod_init_func = get_mod_init_func(segptr);
}
@ -1896,7 +1907,7 @@ bool PackMachBase<T>::canPack()
if (vma_max < t) {
vma_max = t;
}
// Segments need not be contigous {esp. "rust")
// Segments need not be contigous (esp. "rust"/"go")
sz_segment = msegcmd[j].filesize + msegcmd[j].fileoff - msegcmd[0].fileoff;
}
}