Mach-o LC_SEGMENTs not monotonic in file (__DWARF for 'go')

https://github.com/upx/upx/issues/222  go-1.14 (but not go-1.14.3 ?)
	modified:   ../p_mach.cpp
	modified:   ../p_mach.h
	modified:   ../p_unix.cpp
	modified:   ../p_unix.h
	modified:   ../stub/src/amd64-darwin.macho-main.c

	modified:   ../stub/amd64-darwin.macho-fold.h
	modified:   ../stub/arm.v5a-darwin.macho-fold.h
	modified:   ../stub/arm64-darwin.macho-fold.h
	modified:   ../stub/tmp/amd64-darwin.macho-fold.map
	modified:   ../stub/tmp/arm.v5a-darwin.macho-fold.map
	modified:   ../stub/tmp/arm64-darwin.macho-fold.map
This commit is contained in:
John Reiser
2020-05-30 02:54:09 -07:00
committed by Markus F.X.J. Oberhumer
parent 17bd0b3248
commit 4ae1576726
11 changed files with 618 additions and 543 deletions
+12 -1
View File
@@ -1089,8 +1089,19 @@ int PackMachBase<T>::pack2(OutputFile *fo, Filter &ft) // append compressed bo
}
bool const do_filter = (msegcmd[k].filesize==exe_filesize_max)
&& 0!=(Mach_command::VM_PROT_EXECUTE & msegcmd[k].initprot);
Mach_segment_command const *ptr = rawmseg;
unsigned b_extra = 0;
for (unsigned j= 0; j < mhdri.ncmds; ++j) {
if (msegcmd[k].cmd == ptr->cmd
&& msegcmd[k].vmaddr == ptr->vmaddr
&& msegcmd[k].vmsize == ptr->vmsize) {
b_extra = j;
break;
}
ptr = (Mach_segment_command const *)(ptr->cmdsize + (char const *)ptr);
}
packExtent(x, total_in, total_out,
(do_filter ? &ft : 0 ), fo, hdr_u_len );
(do_filter ? &ft : 0 ), fo, hdr_u_len, b_extra );
if (do_filter) {
exe_filesize_max = 0;
}