Ticket #13037: patch-src-unexmacosx.c.diff
File patch-src-unexmacosx.c.diff, 2.2 KB (added by darren.bane@…, 17 years ago) |
---|
-
src/unexmacosx.c
old new 443 443 444 444 while (num && num_unexec_regions < MAX_UNEXEC_REGIONS) 445 445 { 446 /* Subtract the size of trailing null pages from filesize. It446 /* Subtract the size of trailing null bytes from filesize. It 447 447 can be smaller than vmsize in segment commands. In such a 448 case, trailing pages are initialized with zeros. */ 449 for (p = ranges->address + ranges->size; p > ranges->address; 450 p -= sizeof (int)) 451 if (*(((int *) p)-1)) 448 case, trailing bytes are initialized with zeros. */ 449 for (p = ranges->address + ranges->size; p > ranges->address; p--) 450 if (*(((char *) p)-1)) 452 451 break; 453 filesize = ROUNDUP_TO_PAGE_BOUNDARY (p - ranges->address); 454 assert (filesize <= ranges->size); 452 filesize = p - ranges->address; 455 453 456 454 unexec_regions[num_unexec_regions].filesize = filesize; 457 455 unexec_regions[num_unexec_regions++].range = *ranges; … … 503 501 { 504 502 int i, n; 505 503 unexec_region_info r; 504 vm_size_t padsize; 506 505 507 506 qsort (unexec_regions, num_unexec_regions, sizeof (unexec_regions[0]), 508 507 &unexec_regions_sort_compare); 509 508 n = 0; 510 509 r = unexec_regions[0]; 510 padsize = r.range.address & (pagesize - 1); 511 if (padsize) 512 { 513 r.range.address -= padsize; 514 r.range.size += padsize; 515 r.filesize += padsize; 516 } 511 517 for (i = 1; i < num_unexec_regions; i++) 512 518 { 513 519 if (r.range.address + r.range.size == unexec_regions[i].range.address … … 520 526 { 521 527 unexec_regions[n++] = r; 522 528 r = unexec_regions[i]; 529 padsize = r.range.address & (pagesize - 1); 530 if (padsize) 531 { 532 if ((unexec_regions[n-1].range.address 533 + unexec_regions[n-1].range.size) == r.range.address) 534 unexec_regions[n-1].range.size -= padsize; 535 536 r.range.address -= padsize; 537 r.range.size += padsize; 538 r.filesize += padsize; 539 } 523 540 } 524 541 } 525 542 unexec_regions[n++] = r; … … 562 579 case LC_TWOLEVEL_HINTS: 563 580 printf ("LC_TWOLEVEL_HINTS"); 564 581 break; 582 #ifdef LC_UUID 583 case LC_UUID: 584 printf ("LC_UUID "); 585 break; 586 #endif 565 587 default: 566 588 printf ("unknown "); 567 589 }