forked from dmitryvk/sbcl-win32-threads
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.8.21.32: improvement for the space reservation mechanism on OS X
* The C runtime is no longer relinked after running nm, which should avoid some cases where symbols moved when linking in the read-only space reservation object. This was previously observed as segfaults in target-2 and could be worked around by choosing a different C compiler. * Space is now reserved for each of our fixed-address spaces on OS X, currently: * read-only space * static space * dynamic-1 and dynamic-2 spaces * linkage table space Should Apple ever decide to move the malloc heap again, none of these spaces will be picked because their virtual memory ranges will have been reserved by the linker.
- Loading branch information
Brian Mastenbrook
committed
Apr 10, 2005
1 parent
7861e49
commit 1ebf7c8
Showing
7 changed files
with
166 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* ppc-darwin-fix-rospace.c - fix the segment and section output by ppc-darwin-mkrospace.c to have the correct size */ | ||
|
||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <stdio.h> | ||
#include <mach-o/loader.h> | ||
#include <sys/types.h> | ||
#include <sys/mman.h> | ||
#include <sys/stat.h> | ||
#include <sys/uio.h> | ||
#include <unistd.h> | ||
#include <fcntl.h> | ||
|
||
#include "sbcl.h" | ||
#include "runtime.h" | ||
|
||
#include "ppc-darwin-spacelist.h" | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
int fd; | ||
int i, spacei; | ||
struct stat filestat; | ||
struct mach_header *header; | ||
void* file_pointer; | ||
size_t filesize; | ||
size_t old_commands_size; | ||
char* window; | ||
size_t segments_size; | ||
|
||
/* Open the SBCL binary */ | ||
fd = open("sbcl", O_RDWR, 0); /* wr unx prgrmmrs, we cn't spll */ | ||
if (fd == -1) { | ||
perror(argv[0]); | ||
return -1; | ||
} | ||
if (fstat(fd, &filestat) == -1) { | ||
close(fd); | ||
perror(argv[0]); | ||
return -1; | ||
} | ||
filesize = filestat.st_size; | ||
if ((int) (file_pointer = mmap(NULL, filesize, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0)) == -1) { | ||
perror(argv[0]); | ||
close(fd); | ||
return -1; | ||
} | ||
|
||
segments_size = 0; | ||
spacei = 0; | ||
header = (struct mach_header*) file_pointer; | ||
window = (char*) (header + 1); | ||
for (i = 0; i < header->ncmds; i++) { | ||
struct load_command* current_segment; | ||
current_segment = (struct load_command*) window; | ||
segments_size += current_segment->cmdsize; | ||
window += current_segment->cmdsize; | ||
if (current_segment->cmd == LC_SEGMENT) { | ||
int is_sbcl; | ||
struct segment_command* seg = (struct segment_command*) current_segment; | ||
struct section* sectptr; | ||
int j, max; | ||
max = seg->nsects; | ||
if (strncmp("SBCL", seg->segname, 4) == 0) { | ||
is_sbcl = 1; | ||
seg->vmsize = space_sizes[spacei]; | ||
} else { | ||
is_sbcl = 0; | ||
} | ||
seg++; | ||
sectptr = (struct section*) seg; | ||
for (j = 0; j < max; j++) { | ||
if (is_sbcl) { | ||
sectptr->size = space_sizes[spacei]; | ||
spacei++; | ||
} | ||
sectptr++; | ||
} | ||
} | ||
} | ||
|
||
munmap(file_pointer, filesize); | ||
close(fd); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef PPC_DARWIN_SPACELIST_H | ||
#define PPC_DARWIN_SPACELIST_H | ||
|
||
#define N_SEGMENTS_TO_PRODUCE 5 | ||
|
||
unsigned int space_start_locations[N_SEGMENTS_TO_PRODUCE] = | ||
{ READ_ONLY_SPACE_START, STATIC_SPACE_START, DYNAMIC_0_SPACE_START, DYNAMIC_1_SPACE_START, LINKAGE_TABLE_SPACE_START}; | ||
|
||
unsigned int space_sizes[N_SEGMENTS_TO_PRODUCE] = | ||
{ READ_ONLY_SPACE_END - READ_ONLY_SPACE_START, | ||
STATIC_SPACE_END - STATIC_SPACE_START, | ||
DYNAMIC_0_SPACE_END - DYNAMIC_0_SPACE_START, | ||
DYNAMIC_1_SPACE_END - DYNAMIC_1_SPACE_START, | ||
LINKAGE_TABLE_SPACE_END - LINKAGE_TABLE_SPACE_START}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters