diff options
| author | YAMAMOTO Mitsuharu | 2020-02-16 09:50:26 +0900 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2020-02-16 09:50:26 +0900 |
| commit | 888ffd960c06d56a409a7ff15b1d930d25c56089 (patch) | |
| tree | c9feba2ea85638768ddc84eab0cd891566cc7d0a | |
| parent | b392c9f365d081d98d9fbad5d54cadb7b9be15af (diff) | |
| download | emacs-888ffd960c06d56a409a7ff15b1d930d25c56089.tar.gz emacs-888ffd960c06d56a409a7ff15b1d930d25c56089.zip | |
Fix unexec failure on macOS 10.15.4
* src/unexmacosx.c (unexec_regions_merge): Align region start addresses to
page boundaries and then merge regions.
| -rw-r--r-- | src/unexmacosx.c | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/src/unexmacosx.c b/src/unexmacosx.c index 8d132417e89..59cbe3c18b9 100644 --- a/src/unexmacosx.c +++ b/src/unexmacosx.c | |||
| @@ -503,22 +503,34 @@ unexec_regions_sort_compare (const void *a, const void *b) | |||
| 503 | static void | 503 | static void |
| 504 | unexec_regions_merge (void) | 504 | unexec_regions_merge (void) |
| 505 | { | 505 | { |
| 506 | int i, n; | ||
| 507 | unexec_region_info r; | ||
| 508 | vm_size_t padsize; | ||
| 509 | |||
| 510 | qsort (unexec_regions, num_unexec_regions, sizeof (unexec_regions[0]), | 506 | qsort (unexec_regions, num_unexec_regions, sizeof (unexec_regions[0]), |
| 511 | &unexec_regions_sort_compare); | 507 | &unexec_regions_sort_compare); |
| 512 | n = 0; | 508 | |
| 513 | r = unexec_regions[0]; | 509 | /* Align each region start address to a page boundary. */ |
| 514 | padsize = r.range.address & (pagesize - 1); | 510 | for (unexec_region_info *cur = unexec_regions; |
| 515 | if (padsize) | 511 | cur < unexec_regions + num_unexec_regions; cur++) |
| 516 | { | 512 | { |
| 517 | r.range.address -= padsize; | 513 | vm_size_t padsize = cur->range.address & (pagesize - 1); |
| 518 | r.range.size += padsize; | 514 | if (padsize) |
| 519 | r.filesize += padsize; | 515 | { |
| 516 | cur->range.address -= padsize; | ||
| 517 | cur->range.size += padsize; | ||
| 518 | cur->filesize += padsize; | ||
| 519 | |||
| 520 | unexec_region_info *prev = cur == unexec_regions ? NULL : cur - 1; | ||
| 521 | if (prev | ||
| 522 | && prev->range.address + prev->range.size > cur->range.address) | ||
| 523 | { | ||
| 524 | prev->range.size = cur->range.address - prev->range.address; | ||
| 525 | if (prev->filesize > prev->range.size) | ||
| 526 | prev->filesize = prev->range.size; | ||
| 527 | } | ||
| 528 | } | ||
| 520 | } | 529 | } |
| 521 | for (i = 1; i < num_unexec_regions; i++) | 530 | |
| 531 | int n = 0; | ||
| 532 | unexec_region_info r = unexec_regions[0]; | ||
| 533 | for (int i = 1; i < num_unexec_regions; i++) | ||
| 522 | { | 534 | { |
| 523 | if (r.range.address + r.range.size == unexec_regions[i].range.address | 535 | if (r.range.address + r.range.size == unexec_regions[i].range.address |
| 524 | && r.range.size - r.filesize < 2 * pagesize) | 536 | && r.range.size - r.filesize < 2 * pagesize) |
| @@ -530,17 +542,6 @@ unexec_regions_merge (void) | |||
| 530 | { | 542 | { |
| 531 | unexec_regions[n++] = r; | 543 | unexec_regions[n++] = r; |
| 532 | r = unexec_regions[i]; | 544 | r = unexec_regions[i]; |
| 533 | padsize = r.range.address & (pagesize - 1); | ||
| 534 | if (padsize) | ||
| 535 | { | ||
| 536 | if ((unexec_regions[n-1].range.address | ||
| 537 | + unexec_regions[n-1].range.size) == r.range.address) | ||
| 538 | unexec_regions[n-1].range.size -= padsize; | ||
| 539 | |||
| 540 | r.range.address -= padsize; | ||
| 541 | r.range.size += padsize; | ||
| 542 | r.filesize += padsize; | ||
| 543 | } | ||
| 544 | } | 545 | } |
| 545 | } | 546 | } |
| 546 | unexec_regions[n++] = r; | 547 | unexec_regions[n++] = r; |