From 3400ae9dbe8a5305f2ae6f3c5cb570d130c18064 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Tue, 12 Dec 2017 10:53:19 -0800 Subject: [PATCH] MH_EXECUTE leave space for thread state command modified: p_mach.cpp --- src/p_mach.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_mach.cpp b/src/p_mach.cpp index 363b118e..f7c7422b 100644 --- a/src/p_mach.cpp +++ b/src/p_mach.cpp @@ -726,7 +726,6 @@ next: unsigned const sz_threado = threado_size(); mhp->ncmds += 1; mhp->sizeofcmds += sz_threado; - sz_mach_headers += sz_threado; fo->seek(0, SEEK_SET); fo->rewrite(mhp, tail - (char *)mhp); threado_rewrite(fo); @@ -1359,6 +1358,9 @@ void PackMachBase::pack1(OutputFile *const fo, Filter &/*ft*/) // generate e } } } + unsigned const sz_threado = threado_size(); + MemBuffer space(sz_threado); memset(space, 0, sz_threado); + fo->write(space, sz_threado); sz_mach_headers = fo->getBytesWritten(); } else if (my_filetype == Mach_header::MH_DYLIB) {