Ticket #13037: patch-src-unexmacosx.c.diff

File patch-src-unexmacosx.c.diff, 2.2 KB (added by darren.bane@…, 16 years ago)

New patch, to go in editors/emacs-apps/files

  • src/unexmacosx.c

    old new  
    443443
    444444  while (num && num_unexec_regions < MAX_UNEXEC_REGIONS)
    445445    {
    446       /* Subtract the size of trailing null pages from filesize.  It
     446      /* Subtract the size of trailing null bytes from filesize.  It
    447447         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))
    452451          break;
    453       filesize = ROUNDUP_TO_PAGE_BOUNDARY (p - ranges->address);
    454       assert (filesize <= ranges->size);
     452      filesize = p - ranges->address;
    455453
    456454      unexec_regions[num_unexec_regions].filesize = filesize;
    457455      unexec_regions[num_unexec_regions++].range = *ranges;
     
    503501{
    504502  int i, n;
    505503  unexec_region_info r;
     504  vm_size_t padsize;
    506505
    507506  qsort (unexec_regions, num_unexec_regions, sizeof (unexec_regions[0]),
    508507         &unexec_regions_sort_compare);
    509508  n = 0;
    510509  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    }
    511517  for (i = 1; i < num_unexec_regions; i++)
    512518    {
    513519      if (r.range.address + r.range.size == unexec_regions[i].range.address
     
    520526        {
    521527          unexec_regions[n++] = r;
    522528          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            }
    523540        }
    524541    }
    525542  unexec_regions[n++] = r;
     
    562579    case LC_TWOLEVEL_HINTS:
    563580      printf ("LC_TWOLEVEL_HINTS");
    564581      break;
     582#ifdef LC_UUID
     583    case LC_UUID:
     584      printf ("LC_UUID          ");
     585      break;
     586#endif
    565587    default:
    566588      printf ("unknown          ");
    567589    }