124 |
#endif |
#endif |
125 |
#include <mach-o/nlist.h> |
#include <mach-o/nlist.h> |
126 |
#include <mach-o/getsect.h> |
#include <mach-o/getsect.h> |
127 |
#include <objc/malloc.h> |
#include <malloc/malloc.h> |
128 |
|
|
129 |
#include <sys/mman.h> |
#include <sys/mman.h> |
130 |
|
|
528 |
print_load_command (struct load_command *lc) |
print_load_command (struct load_command *lc) |
529 |
{ |
{ |
530 |
print_load_command_name (lc->cmd); |
print_load_command_name (lc->cmd); |
531 |
printf ("%#10lx", lc->cmdsize); |
printf ("%#10x", lc->cmdsize); |
532 |
|
|
533 |
if (lc->cmd == LC_SEGMENT) |
if (lc->cmd == LC_SEGMENT) |
534 |
{ |
{ |
537 |
int j; |
int j; |
538 |
|
|
539 |
scp = (struct segment_command *) lc; |
scp = (struct segment_command *) lc; |
540 |
printf (" %-16.16s %#10lx %#10lx\n", |
printf (" %-16.16s %#10x %#10x\n", |
541 |
scp->segname, scp->vmaddr, scp->vmsize); |
scp->segname, scp->vmaddr, scp->vmsize); |
542 |
|
|
543 |
sectp = (struct section *) (scp + 1); |
sectp = (struct section *) (scp + 1); |
544 |
for (j = 0; j < scp->nsects; j++) |
for (j = 0; j < scp->nsects; j++) |
545 |
{ |
{ |
546 |
printf (" %-16.16s %#10lx %#10lx\n", |
printf (" %-16.16s %#10x %#10x\n", |
547 |
sectp->sectname, sectp->addr, sectp->size); |
sectp->sectname, sectp->addr, sectp->size); |
548 |
sectp++; |
sectp++; |
549 |
} |
} |
571 |
|
|
572 |
#if VERBOSE |
#if VERBOSE |
573 |
printf ("--- Header Information ---\n"); |
printf ("--- Header Information ---\n"); |
574 |
printf ("Magic = 0x%08lx\n", mh.magic); |
printf ("Magic = 0x%08x\n", mh.magic); |
575 |
printf ("CPUType = %d\n", mh.cputype); |
printf ("CPUType = %d\n", mh.cputype); |
576 |
printf ("CPUSubType = %d\n", mh.cpusubtype); |
printf ("CPUSubType = %d\n", mh.cpusubtype); |
577 |
printf ("FileType = 0x%lx\n", mh.filetype); |
printf ("FileType = 0x%x\n", mh.filetype); |
578 |
printf ("NCmds = %ld\n", mh.ncmds); |
printf ("NCmds = %d\n", mh.ncmds); |
579 |
printf ("SizeOfCmds = %ld\n", mh.sizeofcmds); |
printf ("SizeOfCmds = %d\n", mh.sizeofcmds); |
580 |
printf ("Flags = 0x%08lx\n", mh.flags); |
printf ("Flags = 0x%08x\n", mh.flags); |
581 |
#endif |
#endif |
582 |
|
|
583 |
nlc = mh.ncmds; |
nlc = mh.ncmds; |
655 |
if (strncmp (scp->segname, SEG_LINKEDIT, 16) == 0) |
if (strncmp (scp->segname, SEG_LINKEDIT, 16) == 0) |
656 |
scp->vmaddr += linkedit_delta; |
scp->vmaddr += linkedit_delta; |
657 |
|
|
658 |
printf ("Writing segment %-16.16s at %#10lx - %#10lx (sz: %#10lx)\n", |
printf ("Writing segment %-16.16s at %#10x - %#10x (sz: %#10x)\n", |
659 |
scp->segname, scp->fileoff, scp->fileoff + scp->filesize, |
scp->segname, scp->fileoff, scp->fileoff + scp->filesize, |
660 |
scp->filesize); |
scp->filesize); |
661 |
|
|
693 |
return; |
return; |
694 |
} |
} |
695 |
|
|
696 |
printf ("Writing segment %-16.16s at %#10lx - %#10lx (sz: %#10lx)\n", |
printf ("Writing segment %-16.16s at %#10x - %#10x (sz: %#10x)\n", |
697 |
scp->segname, scp->fileoff, scp->fileoff + scp->filesize, |
scp->segname, scp->fileoff, scp->fileoff + scp->filesize, |
698 |
scp->filesize); |
scp->filesize); |
699 |
|
|
741 |
else |
else |
742 |
unexec_error ("unrecognized section name in __DATA segment"); |
unexec_error ("unrecognized section name in __DATA segment"); |
743 |
|
|
744 |
printf (" section %-16.16s at %#10lx - %#10lx (sz: %#10lx)\n", |
printf (" section %-16.16s at %#10x - %#10x (sz: %#10x)\n", |
745 |
sectp->sectname, sectp->offset, sectp->offset + sectp->size, |
sectp->sectname, sectp->offset, sectp->offset + sectp->size, |
746 |
sectp->size); |
sectp->size); |
747 |
|
|
830 |
section.reserved1 = 0; |
section.reserved1 = 0; |
831 |
section.reserved2 = 0; |
section.reserved2 = 0; |
832 |
|
|
833 |
printf ("Writing segment %-16.16s at %#10lx - %#10lx (sz: %#10lx)\n", |
printf ("Writing segment %-16.16s at %#10x - %#10x (sz: %#10x)\n", |
834 |
sc.segname, sc.fileoff, sc.fileoff + sc.filesize, sc.filesize); |
sc.segname, sc.fileoff, sc.fileoff + sc.filesize, sc.filesize); |
835 |
|
|
836 |
if (!unexec_write (sc.fileoff, (void *) sc.vmaddr, sc.filesize)) |
if (!unexec_write (sc.fileoff, (void *) sc.vmaddr, sc.filesize)) |
1274 |
|
|
1275 |
/* Replacement for broken sbrk(2). */ |
/* Replacement for broken sbrk(2). */ |
1276 |
|
|
1277 |
char *my_sbrk (int incr) |
void *my_sbrk (int incr) |
1278 |
{ |
{ |
1279 |
char *temp, *ptr; |
char *temp, *ptr; |
1280 |
kern_return_t rtn; |
kern_return_t rtn; |