Ticket #13294: leopard-patch

File leopard-patch, 3.0 KB (added by terry@…, 17 years ago)

Patch pasted into a file from http://article.gmane.org/gmane.emacs.bugs/16867

Line 
1Index: src/unexmacosx.c
2===================================================================
3RCS file: /cvsroot/emacs/emacs/src/unexmacosx.c,v
4retrieving revision 1.22.2.1
5diff -c -p -r1.22.2.1 unexmacosx.c
6*** src/unexmacosx.c    25 Jul 2007 05:15:30 -0000      1.22.2.1
7--- src/unexmacosx.c    29 Oct 2007 23:09:00 -0000
8*************** unexec_regions_recorder (task_t task, vo
9*** 443,457 ****
10
11    while (num && num_unexec_regions < MAX_UNEXEC_REGIONS)
12      {
13!       /* Subtract the size of trailing null pages from filesize.  It
14         can be smaller than vmsize in segment commands.  In such a
15!        case, trailing pages are initialized with zeros.  */
16!       for (p = ranges->address + ranges->size; p > ranges->address;
17!          p -= sizeof (int))
18!       if (*(((int *) p)-1))
19!         break;
20!       filesize = ROUNDUP_TO_PAGE_BOUNDARY (p - ranges->address);
21!       assert (filesize <= ranges->size);
22
23        unexec_regions[num_unexec_regions].filesize = filesize;
24        unexec_regions[num_unexec_regions++].range = *ranges;
25--- 443,455 ----
26
27    while (num && num_unexec_regions < MAX_UNEXEC_REGIONS)
28      {
29!       /* Subtract the size of trailing null bytes from filesize.  It
30         can be smaller than vmsize in segment commands.  In such a
31!        case, trailing bytes are initialized with zeros.  */
32!       for (p = ranges->address + ranges->size; p > ranges->address; p--)
33!               if (*(((char *) p)-1))
34!                 break;
35!       filesize = p - ranges->address;
36
37        unexec_regions[num_unexec_regions].filesize = filesize;
38        unexec_regions[num_unexec_regions++].range = *ranges;
39*************** unexec_regions_merge ()
40*** 503,513 ****
41--- 501,519 ----
42  {
43    int i, n;
44    unexec_region_info r;
45+   vm_size_t padsize;
46
47    qsort (unexec_regions, num_unexec_regions, sizeof (unexec_regions[0]),
48         &unexec_regions_sort_compare);
49    n = 0;
50    r = unexec_regions[0];
51+   padsize = r.range.address & (pagesize - 1);
52+   if (padsize)
53+     {
54+       r.range.address -= padsize;
55+       r.range.size += padsize;
56+       r.filesize += padsize;
57+     }
58    for (i = 1; i < num_unexec_regions; i++)
59      {
60        if (r.range.address + r.range.size == unexec_regions[i].range.address
61*************** unexec_regions_merge ()
62*** 520,525 ****
63--- 526,542 ----
64        {
65          unexec_regions[n++] = r;
66          r = unexec_regions[i];
67+         padsize = r.range.address & (pagesize - 1);
68+         if (padsize)
69+           {
70+             if ((unexec_regions[n-1].range.address
71+                  + unexec_regions[n-1].range.size) == r.range.address)
72+               unexec_regions[n-1].range.size -= padsize;
73+
74+             r.range.address -= padsize;
75+             r.range.size += padsize;
76+             r.filesize += padsize;
77+           }
78        }
79      }
80    unexec_regions[n++] = r;
81*************** print_load_command_name (int lc)
82*** 562,567 ****
83--- 579,589 ----
84      case LC_TWOLEVEL_HINTS:
85        printf ("LC_TWOLEVEL_HINTS");
86        break;
87+ #ifdef LC_UUID
88+     case LC_UUID:
89+       printf ("LC_UUID          ");
90+       break;
91+ #endif
92      default:
93        printf ("unknown          ");
94      }