+ if (flag_r) {
+ size_t clip(_not(size_t)); {
+ FatHeader fat_header(Map(path));
+ _foreach (mach_header, fat_header.GetMachHeaders()) {
+ mach_header->flags = mach_header.Swap(mach_header.Swap(mach_header->flags) | MH_DYLDLINK);
+
+ size_t size(_not(size_t)); {
+ _foreach (load_command, mach_header.GetLoadCommands()) {
+ switch (mach_header.Swap(load_command->cmd)) {
+ case LC_CODE_SIGNATURE: {
+ struct linkedit_data_command *signature = reinterpret_cast<struct linkedit_data_command *>(load_command);
+ memset(signature, 0, sizeof(struct linkedit_data_command));
+
+ mach_header->ncmds -= 1;
+ mach_header->sizeofcmds -= sizeof(struct linkedit_data_command);
+ } break;
+
+ case LC_SYMTAB: {
+ struct symtab_command *symtab = reinterpret_cast<struct symtab_command *>(load_command);
+ size = symtab->stroff + symtab->strsize;
+ } break;
+ }
+ }
+
+ _foreach (segment, const_cast<MachHeader &>(mach_header).GetSegments("__LINKEDIT")) {
+ segment->filesize -= mach_header.GetSize() - size;
+
+ if (!fat_header.IsFat())
+ clip = size;
+ else
+ _assert(false);
+ }
+ }
+ }
+ }
+
+ if (clip != _not(size_t))
+ _syscall(truncate(path, clip));
+ }
+