562 |
} |
} |
563 |
} |
} |
564 |
|
|
565 |
printf ("Highest address of load commands in input file: %#8x\n", |
printf ("Highest address of load commands in input file: %#10x\n", |
566 |
infile_lc_highest_addr); |
infile_lc_highest_addr); |
567 |
|
|
568 |
printf ("Lowest offset of all sections in __TEXT segment: %#8lx\n", |
printf ("Lowest offset of all sections in __TEXT segment: %#10lx\n", |
569 |
text_seg_lowest_offset); |
text_seg_lowest_offset); |
570 |
|
|
571 |
printf ("--- List of Load Commands in Input File ---\n"); |
printf ("--- List of Load Commands in Input File ---\n"); |
573 |
|
|
574 |
for (i = 0; i < nlc; i++) |
for (i = 0; i < nlc; i++) |
575 |
{ |
{ |
576 |
printf ("%#2d ", i); |
printf ("%2d ", i); |
577 |
print_load_command (lca[i]); |
print_load_command (lca[i]); |
578 |
} |
} |
579 |
} |
} |
598 |
sectp++; |
sectp++; |
599 |
} |
} |
600 |
|
|
601 |
printf ("Writing segment %-16.16s at %#8lx - %#8lx (sz: %#8lx)\n", |
printf ("Writing segment %-16.16s at %#10lx - %#10lx (sz: %#10lx)\n", |
602 |
scp->segname, scp->fileoff, scp->fileoff + scp->filesize, |
scp->segname, scp->fileoff, scp->fileoff + scp->filesize, |
603 |
scp->filesize); |
scp->filesize); |
604 |
|
|
636 |
return; |
return; |
637 |
} |
} |
638 |
|
|
639 |
printf ("Writing segment %-16.16s at %#8lx - %#8lx (sz: %#8lx)\n", |
printf ("Writing segment %-16.16s at %#10lx - %#10lx (sz: %#10lx)\n", |
640 |
scp->segname, scp->fileoff, scp->fileoff + scp->filesize, |
scp->segname, scp->fileoff, scp->fileoff + scp->filesize, |
641 |
scp->filesize); |
scp->filesize); |
642 |
|
|
684 |
else |
else |
685 |
unexec_error ("unrecognized section name in __DATA segment"); |
unexec_error ("unrecognized section name in __DATA segment"); |
686 |
|
|
687 |
printf (" section %-16.16s at %#8lx - %#8lx (sz: %#8lx)\n", |
printf (" section %-16.16s at %#10lx - %#10lx (sz: %#10lx)\n", |
688 |
sectp->sectname, sectp->offset, sectp->offset + sectp->size, |
sectp->sectname, sectp->offset, sectp->offset + sectp->size, |
689 |
sectp->size); |
sectp->size); |
690 |
|
|
751 |
section.reserved1 = 0; |
section.reserved1 = 0; |
752 |
section.reserved2 = 0; |
section.reserved2 = 0; |
753 |
|
|
754 |
printf ("Writing segment %-16.16s at %#8lx - %#8lx (sz: %#8lx)\n", |
printf ("Writing segment %-16.16s at %#10lx - %#10lx (sz: %#10lx)\n", |
755 |
sc.segname, sc.fileoff, sc.fileoff + sc.filesize, sc.filesize); |
sc.segname, sc.fileoff, sc.fileoff + sc.filesize, sc.filesize); |
756 |
|
|
757 |
if (!unexec_write (sc.fileoff, (void *) sc.vmaddr, sc.filesize)) |
if (!unexec_write (sc.fileoff, (void *) sc.vmaddr, sc.filesize)) |
1072 |
|
|
1073 |
} |
} |
1074 |
|
|
1075 |
|
static void dump_regionXXX (vm_address_t start, vm_size_t size) |
1076 |
|
{ |
1077 |
|
task_t target_task = mach_task_self (); |
1078 |
|
kern_return_t rtn; |
1079 |
|
struct vm_region_basic_info info; |
1080 |
|
mach_msg_type_number_t info_count = VM_REGION_BASIC_INFO_COUNT; |
1081 |
|
mach_port_t object_name; |
1082 |
|
vm_prot_t prot, maxprot; |
1083 |
|
|
1084 |
|
fprintf (stderr, "introspecting between %x and %x\n", start, start+size); |
1085 |
|
|
1086 |
|
fflush (stderr); |
1087 |
|
|
1088 |
|
rtn = vm_region (target_task, &start, &size, VM_REGION_BASIC_INFO, |
1089 |
|
(vm_region_info_t) &info, &info_count, &object_name); |
1090 |
|
|
1091 |
|
if (rtn != KERN_SUCCESS || info_count != VM_REGION_BASIC_INFO_COUNT) { |
1092 |
|
mach_error ("[dump_regionXXX] vm_region() failed: ", rtn); |
1093 |
|
return; |
1094 |
|
} |
1095 |
|
|
1096 |
|
if (object_name != MACH_PORT_NULL) |
1097 |
|
mach_port_deallocate (target_task, object_name); |
1098 |
|
|
1099 |
|
prot = info.protection; |
1100 |
|
maxprot = info.max_protection; |
1101 |
|
|
1102 |
|
fprintf (stderr, "region_start=%x region_size=%x region_end=%x prot=%c%c%c maxprot=%c%c%c\n", |
1103 |
|
start, size, start+size, prot & VM_PROT_READ ? 'r' : '-', prot & VM_PROT_WRITE ? 'w' : '-', |
1104 |
|
prot & VM_PROT_EXECUTE ? 'x' : '-', maxprot & VM_PROT_READ ? 'r' : '-', |
1105 |
|
maxprot & VM_PROT_WRITE ? 'w' : '-', maxprot & VM_PROT_EXECUTE ? 'x' : '-'); |
1106 |
|
|
1107 |
|
fflush (stderr); |
1108 |
|
} |
1109 |
|
|
1110 |
char *my_sbrk (int incr) |
char *my_sbrk (int incr) |
1111 |
{ |
{ |
1112 |
char *temp, *ptr; |
char *temp, *ptr; |
1143 |
} |
} |
1144 |
} |
} |
1145 |
|
|
1146 |
|
void prot_debug () { |
1147 |
|
if (mach_brkpt >= mach_mapstart+0x2000) { |
1148 |
|
dump_regionXXX ((vm_address_t) (mach_mapstart+0x1000),(vm_size_t) 0x1000); |
1149 |
|
} |
1150 |
|
else { |
1151 |
|
printf ("mach_brkpt < mach_mapstart+0x2000\n"); fflush (stdout); |
1152 |
|
} |
1153 |
|
} |
1154 |
|
|
1155 |
#ifdef UNIXSAVE |
#ifdef UNIXSAVE |
1156 |
#include "save.c" |
#include "save.c" |
1157 |
#endif |
#endif |