static void print_load_command (struct load_command *lc) { print_load_command_name (lc->cmd); printf ("%8d", lc->cmdsize); if (lc->cmd == LC_SEGMENT) { struct segment_command *scp; struct section *sectp; int j; scp = (struct segment_command *) lc; printf (" %-16.16s %#10lx %#8lx\n", scp->segname, (long) (scp->vmaddr), (long) (scp->vmsize)); sectp = (struct section *) (scp + 1); for (j = 0; j < scp->nsects; j++) { printf (" %-16.16s %#10lx %#8lx\n", sectp->sectname, (long) (sectp->addr), (long) (sectp->size)); sectp++; } } else printf ("\n"); }
/* Copy a LC_DYLD_INFO(_ONLY) load command from the input file to the output file, adjusting the file offset fields. */ static void copy_dyld_info (struct load_command *lc, long delta) { struct dyld_info_command *dip = (struct dyld_info_command *) lc; if (dip->rebase_off > 0) dip->rebase_off += delta; if (dip->bind_off > 0) dip->bind_off += delta; if (dip->weak_bind_off > 0) dip->weak_bind_off += delta; if (dip->lazy_bind_off > 0) dip->lazy_bind_off += delta; if (dip->export_off > 0) dip->export_off += delta; printf ("Writing "); print_load_command_name (lc->cmd); printf (" command\n"); if (!unexec_write (curr_header_offset, lc, lc->cmdsize)) unexec_error ("cannot write dyld info command to header"); curr_header_offset += lc->cmdsize; }
/* Copy other kinds of load commands from the input file to the output file, ones that do not require adjustments of file offsets. */ static void copy_other (struct load_command *lc) { printf ("Writing "); print_load_command_name (lc->cmd); printf (" command\n"); if (!unexec_write (curr_header_offset, lc, lc->cmdsize)) unexec_error ("cannot write symtab command to header"); curr_header_offset += lc->cmdsize; }
/* Copy a LC_FUNCTION_STARTS/LC_DATA_IN_CODE/LC_DYLIB_CODE_SIGN_DRS load command from the input file to the output file, adjusting the data offset field. */ static void copy_linkedit_data (struct load_command *lc, long delta) { struct linkedit_data_command *ldp = (struct linkedit_data_command *) lc; if (ldp->dataoff > 0) ldp->dataoff += delta; printf ("Writing "); print_load_command_name (lc->cmd); printf (" command\n"); if (!unexec_write (curr_header_offset, lc, lc->cmdsize)) unexec_error ("cannot write linkedit data command to header"); curr_header_offset += lc->cmdsize; }