mirror of
git://git.code.sf.net/p/sbcl/sbcl
synced 2026-09-10 15:36:41 -04:00
0.9.18.28: allow read-only space to be placed in higher addresses on PPC
* Rewrite jumps encoding addresses to read-only space with a spare register so that the address range is not limited. * This means that fix-rospace magic can go away. (But the real reason for this is the forthcoming adjustable dynamic-space-size and relocation, which in conjunction with the rospace magic make me uncomfortable).
This commit is contained in:
parent
a30a3d8229
commit
a41c057bfe
|
|
@ -204,7 +204,7 @@
|
|||
exit
|
||||
|
||||
(move target catch)
|
||||
(inst ba (make-fixup 'unwind :assembly-routine)))
|
||||
|
||||
|
||||
|
||||
;; reuse catch
|
||||
(inst lr catch (make-fixup 'unwind :assembly-routine))
|
||||
(inst mtlr catch)
|
||||
(inst blr))
|
||||
|
|
|
|||
|
|
@ -14,11 +14,15 @@
|
|||
(!def-vm-support-routine generate-call-sequence (name style vop)
|
||||
(ecase style
|
||||
((:raw :none)
|
||||
(values
|
||||
`((inst bla (make-fixup ',name :assembly-routine)))
|
||||
`()))
|
||||
(let ((jump (make-symbol "JUMP")))
|
||||
(values
|
||||
`((inst lr ,jump (make-fixup ',name :assembly-routine))
|
||||
(inst mtlr ,jump)
|
||||
(inst blrl))
|
||||
`((:temporary (:sc any-reg) ,jump)))))
|
||||
(:full-call
|
||||
(let ((temp (make-symbol "TEMP"))
|
||||
(jump (make-symbol "JUMP"))
|
||||
(nfp-save (make-symbol "NFP-SAVE"))
|
||||
(lra (make-symbol "LRA")))
|
||||
(values
|
||||
|
|
@ -28,23 +32,26 @@
|
|||
(store-stack-tn ,nfp-save cur-nfp))
|
||||
(inst compute-lra-from-code ,lra code-tn lra-label ,temp)
|
||||
(note-next-instruction ,vop :call-site)
|
||||
(inst ba (make-fixup ',name :assembly-routine))
|
||||
(inst lr ,jump (make-fixup ',name :assembly-routine))
|
||||
(inst mtlr ,jump)
|
||||
(inst blr)
|
||||
(emit-return-pc lra-label)
|
||||
(note-this-location ,vop :single-value-return)
|
||||
(without-scheduling ()
|
||||
(move csp-tn ocfp-tn)
|
||||
(inst nop))
|
||||
(move csp-tn ocfp-tn)
|
||||
(inst nop))
|
||||
(inst compute-code-from-lra code-tn code-tn
|
||||
lra-label ,temp)
|
||||
(when cur-nfp
|
||||
(load-stack-tn cur-nfp ,nfp-save))))
|
||||
`((:temporary (:scs (non-descriptor-reg) :from (:eval 0) :to (:eval 1))
|
||||
,temp)
|
||||
,temp)
|
||||
(:temporary (:sc descriptor-reg :offset lra-offset
|
||||
:from (:eval 0) :to (:eval 1))
|
||||
,lra)
|
||||
:from (:eval 0) :to (:eval 1))
|
||||
,lra)
|
||||
(:temporary (:scs (control-stack) :offset nfp-save-offset)
|
||||
,nfp-save)
|
||||
,nfp-save)
|
||||
(:temporary (:sc any-reg) ,jump)
|
||||
(:save-p :compute-only)))))))
|
||||
|
||||
(!def-vm-support-routine generate-return-sequence (style)
|
||||
|
|
|
|||
|
|
@ -855,33 +855,27 @@ default-value-8
|
|||
(function-arg :scs (descriptor-reg) :target lexenv)
|
||||
(old-fp-arg :scs (any-reg) :target old-fp)
|
||||
(lra-arg :scs (descriptor-reg) :target lra))
|
||||
|
||||
(:temporary (:sc any-reg :offset nl0-offset :from (:argument 0)) args)
|
||||
(:temporary (:sc any-reg :offset lexenv-offset :from (:argument 1)) lexenv)
|
||||
(:temporary (:sc any-reg :offset ocfp-offset :from (:argument 2)) old-fp)
|
||||
(:temporary (:sc any-reg :offset lra-offset :from (:argument 3)) lra)
|
||||
|
||||
|
||||
(:temporary (:sc any-reg) temp)
|
||||
(:vop-var vop)
|
||||
|
||||
(:generator 75
|
||||
|
||||
;; Move these into the passing locations if they are not already there.
|
||||
(move args args-arg)
|
||||
(move lexenv function-arg)
|
||||
(move old-fp old-fp-arg)
|
||||
(move lra lra-arg)
|
||||
|
||||
|
||||
;; Clear the number stack if anything is there.
|
||||
(let ((cur-nfp (current-nfp-tn vop)))
|
||||
(when cur-nfp
|
||||
(inst addi nsp-tn cur-nfp
|
||||
(- (bytes-needed-for-non-descriptor-stack-frame)
|
||||
number-stack-displacement))))
|
||||
|
||||
|
||||
(inst ba (make-fixup 'tail-call-variable :assembly-routine))))
|
||||
(inst lr temp (make-fixup 'tail-call-variable :assembly-routine))
|
||||
(inst mtlr temp)
|
||||
(inst blr)))
|
||||
|
||||
|
||||
;;;; Unknown values return:
|
||||
|
|
@ -977,17 +971,14 @@ default-value-8
|
|||
(lra-arg :scs (descriptor-reg) :to (:eval 1))
|
||||
(vals-arg :scs (any-reg) :target vals)
|
||||
(nvals-arg :scs (any-reg) :target nvals))
|
||||
|
||||
(:temporary (:sc any-reg :offset nl1-offset :from (:argument 0)) old-fp)
|
||||
(:temporary (:sc descriptor-reg :offset lra-offset :from (:argument 1)) lra)
|
||||
(:temporary (:sc any-reg :offset nl0-offset :from (:argument 2)) vals)
|
||||
(:temporary (:sc any-reg :offset nargs-offset :from (:argument 3)) nvals)
|
||||
(:temporary (:sc descriptor-reg :offset a0-offset) a0)
|
||||
(:temporary (:scs (interior-reg)) lip)
|
||||
|
||||
|
||||
(:temporary (:sc any-reg) temp)
|
||||
(:vop-var vop)
|
||||
|
||||
(:generator 13
|
||||
(trace-table-entry trace-table-fun-epilogue)
|
||||
(let ((not-single (gen-label)))
|
||||
|
|
@ -997,24 +988,23 @@ default-value-8
|
|||
(inst addi nsp-tn cur-nfp
|
||||
(- (bytes-needed-for-non-descriptor-stack-frame)
|
||||
number-stack-displacement))))
|
||||
|
||||
;; Check for the single case.
|
||||
(inst cmpwi nvals-arg (fixnumize 1))
|
||||
(inst lwz a0 vals-arg 0)
|
||||
(inst bne not-single)
|
||||
|
||||
;; Return with one value.
|
||||
(move csp-tn cfp-tn)
|
||||
(move cfp-tn old-fp-arg)
|
||||
(lisp-return lra-arg lip :offset 2)
|
||||
|
||||
;; Nope, not the single case.
|
||||
(emit-label not-single)
|
||||
(move old-fp old-fp-arg)
|
||||
(move lra lra-arg)
|
||||
(move vals vals-arg)
|
||||
(move nvals nvals-arg)
|
||||
(inst ba (make-fixup 'return-multiple :assembly-routine)))
|
||||
(inst lr temp (make-fixup 'return-multiple :assembly-routine))
|
||||
(inst mtlr temp)
|
||||
(inst blr))
|
||||
(trace-table-entry trace-table-normal)))
|
||||
|
||||
;;;; XEP hackery:
|
||||
|
|
|
|||
|
|
@ -340,13 +340,11 @@
|
|||
(inst andi. ,flag-tn alloc-tn 7)
|
||||
(inst twi :ne ,flag-tn 0))))
|
||||
|
||||
|
||||
|
||||
(defmacro sb!sys::with-pinned-objects ((&rest objects) &body body)
|
||||
"Arrange with the garbage collector that the pages occupied by
|
||||
OBJECTS will not be moved in memory for the duration of BODY.
|
||||
Useful for e.g. foreign calls where another thread may trigger
|
||||
garbage collection. This is currently implemented by disabling GC"
|
||||
(declare (ignore objects)) ;should we eval these for side-effect?
|
||||
(declare (ignore objects)) ; should we eval these for side-effect?
|
||||
`(without-gcing
|
||||
,@body))
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@
|
|||
|
||||
;;; Where to put the different spaces.
|
||||
|
||||
(def!constant read-only-space-start #x01000000)
|
||||
(def!constant read-only-space-end #x04ff8000)
|
||||
(def!constant read-only-space-start #x04000000)
|
||||
(def!constant read-only-space-end #x07ff8000)
|
||||
|
||||
(def!constant static-space-start #x08000000)
|
||||
(def!constant static-space-end #x097fff00)
|
||||
|
|
|
|||
|
|
@ -242,8 +242,8 @@
|
|||
|
||||
#!+darwin
|
||||
(progn
|
||||
(def!constant read-only-space-start #x01000000)
|
||||
(def!constant read-only-space-end #x04ff8000)
|
||||
(def!constant read-only-space-start #x04000000)
|
||||
(def!constant read-only-space-end #x07ff8000)
|
||||
|
||||
(def!constant static-space-start #x08000000)
|
||||
(def!constant static-space-end #x097fff00)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
CFLAGS = -g -Wall -O2 -fdollars-in-identifiers
|
||||
OS_SRC = bsd-os.c darwin-os.c ppc-darwin-os.c darwin-dlshim.c darwin-langinfo.c
|
||||
OS_LIBS = -lSystem -lc
|
||||
OS_OBJS = ppc-darwin-rospace.o
|
||||
|
||||
CC = gcc
|
||||
|
||||
|
|
@ -21,38 +20,12 @@ ARCH_SRC = ppc-arch.c
|
|||
|
||||
CPPFLAGS += -no-cpp-precomp
|
||||
|
||||
# KLUDGE: in OS X 10.3, Apple started putting the heap right where we
|
||||
# expect our read-only space mapped. This hack causes the linker to
|
||||
# place a zero-fill-on-demand segment in the same place and size as
|
||||
# read-only-space, which is the only thing capable of keeping malloc
|
||||
# out of this range.
|
||||
LINKFLAGS += -dynamic `cat ppc-darwin-link-flags` -twolevel_namespace -bind_at_load
|
||||
|
||||
GC_SRC = $(shell if grep LISP_FEATURE_GENCGC genesis/config.h \
|
||||
> /dev/null 2>&1; \
|
||||
then echo "gencgc.c"; \
|
||||
else echo "cheneygc.c" ; fi)
|
||||
|
||||
OS_CLEAN_FILES += ppc-darwin-mkrospace ppc-darwin-fix-rospace ppc-darwin-link-flags
|
||||
|
||||
ppc-darwin-mkrospace: ppc-darwin-mkrospace.c
|
||||
$(CC) -g -Wall -pedantic -o $@ $<
|
||||
|
||||
ppc-darwin-fix-rospace: ppc-darwin-fix-rospace.c
|
||||
$(CC) -g -Wall -pedantic -o $@ $<
|
||||
|
||||
ppc-darwin-rospace.o ppc-darwin-link-flags: ppc-darwin-mkrospace
|
||||
./ppc-darwin-mkrospace > ppc-darwin-link-flags
|
||||
|
||||
.PHONY: after-grovel-headers
|
||||
|
||||
# Fix the sbcl runtime to avoid Panther placing the heap where
|
||||
# it wants read only space (in the first 32 megabytes, where it
|
||||
# can be absolute-branched to with BA.) Must be done after
|
||||
# grovel-headers, because Apple's nm is broken.
|
||||
after-grovel-headers: ppc-darwin-fix-rospace
|
||||
./ppc-darwin-fix-rospace
|
||||
|
||||
# Fortunatly make-target-1.sh does a make clean all the time.
|
||||
# Otherwise we would have to make sure that sbcl gets rebuilt without
|
||||
# the readonlyspace hack before groveling headers again.
|
||||
# Nothing to do.
|
||||
after-grovel-headers:
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
CFLAGS = -g -Wall -O2 -fdollars-in-identifiers
|
||||
OS_SRC = bsd-os.c x86-bsd-os.c darwin-os.c x86-darwin-os.c darwin-dlshim.c darwin-langinfo.c
|
||||
OS_LIBS = -lSystem -lc -ldl
|
||||
OS_OBJS = x86-darwin-rospace.o
|
||||
|
||||
CC = gcc
|
||||
|
||||
|
|
@ -21,35 +20,9 @@ ARCH_SRC = x86-arch.c
|
|||
|
||||
CPPFLAGS += -no-cpp-precomp
|
||||
|
||||
# KLUDGE: in OS X 10.3, Apple started putting the heap right where we
|
||||
# expect our read-only space mapped. This hack causes the linker to
|
||||
# place a zero-fill-on-demand segment in the same place and size as
|
||||
# read-only-space, which is the only thing capable of keeping malloc
|
||||
# out of this range.
|
||||
LINKFLAGS += -dynamic `cat x86-darwin-link-flags` -twolevel_namespace -bind_at_load
|
||||
|
||||
GC_SRC = gencgc.c
|
||||
|
||||
OS_CLEAN_FILES += x86-darwin-mkrospace x86-darwin-fix-rospace x86-darwin-link-flags
|
||||
|
||||
x86-darwin-mkrospace: x86-darwin-mkrospace.c
|
||||
$(CC) -g -Wall -pedantic -o $@ $<
|
||||
|
||||
x86-darwin-fix-rospace: x86-darwin-fix-rospace.c
|
||||
$(CC) -g -Wall -pedantic -o $@ $<
|
||||
|
||||
x86-darwin-rospace.o x86-darwin-link-flags: x86-darwin-mkrospace
|
||||
./x86-darwin-mkrospace > x86-darwin-link-flags
|
||||
|
||||
.PHONY: after-grovel-headers
|
||||
|
||||
# Fix the sbcl runtime to avoid Panther placing the heap where
|
||||
# it wants read only space (in the first 32 megabytes, where it
|
||||
# can be absolute-branched to with BA.) Must be done after
|
||||
# grovel-headers, because Apple's nm is broken.
|
||||
after-grovel-headers: x86-darwin-fix-rospace
|
||||
./x86-darwin-fix-rospace
|
||||
|
||||
# Fortunatly make-target-1.sh does a make clean all the time.
|
||||
# Otherwise we would have to make sure that sbcl gets rebuilt without
|
||||
# the readonlyspace hack before groveling headers again.
|
||||
# Nothing to do.
|
||||
after-grovel-headers:
|
||||
|
|
|
|||
|
|
@ -1,85 +0,0 @@
|
|||
/* 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;
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/* ppc-darwin-mkrospace.c - write a .o which makes sure we get our desired address range */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <mach-o/loader.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "sbcl.h"
|
||||
#include "runtime.h"
|
||||
|
||||
#include "ppc-darwin-spacelist.h"
|
||||
|
||||
struct simple_object_file
|
||||
{
|
||||
struct segment_command thesegment;
|
||||
struct section thesection;
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
struct mach_header *theheader;
|
||||
struct simple_object_file *theobj;
|
||||
int fd, i;
|
||||
|
||||
/* Produce the mach header */
|
||||
theheader = (struct mach_header*) malloc(sizeof(struct mach_header));
|
||||
theheader->magic = MH_MAGIC;
|
||||
theheader->cputype = CPU_TYPE_POWERPC;
|
||||
theheader->cpusubtype = CPU_SUBTYPE_POWERPC_ALL;
|
||||
theheader->filetype = MH_OBJECT;
|
||||
theheader->ncmds = N_SEGMENTS_TO_PRODUCE;
|
||||
theheader->sizeofcmds = N_SEGMENTS_TO_PRODUCE * (sizeof(struct segment_command) + sizeof(struct section));
|
||||
theheader->flags = MH_NOUNDEFS;
|
||||
printf("-Wl");
|
||||
fd = open("ppc-darwin-rospace.o", O_WRONLY | O_CREAT, 0644);
|
||||
write(fd, theheader, sizeof(struct mach_header));
|
||||
|
||||
for (i = 0; i < N_SEGMENTS_TO_PRODUCE; i++) {
|
||||
theobj = (struct simple_object_file*) malloc(sizeof(struct simple_object_file));
|
||||
theobj->thesegment.cmd = LC_SEGMENT;
|
||||
theobj->thesegment.cmdsize = sizeof(struct segment_command) + sizeof(struct section);
|
||||
snprintf(theobj->thesegment.segname, 7, "SBCL%d", i);
|
||||
theobj->thesegment.fileoff = sizeof(struct mach_header) + i * (sizeof(struct segment_command) + sizeof(struct section));
|
||||
theobj->thesegment.vmaddr = space_start_locations[i];
|
||||
theobj->thesegment.vmsize = 0;
|
||||
theobj->thesegment.maxprot = VM_PROT_ALL;
|
||||
theobj->thesegment.initprot = VM_PROT_ALL;
|
||||
theobj->thesegment.nsects = 1;
|
||||
theobj->thesegment.flags = 0;
|
||||
snprintf(theobj->thesection.sectname, 7, "sect%d", i);
|
||||
snprintf(theobj->thesection.segname, 7, "SBCL%d", i);
|
||||
theobj->thesection.addr = space_start_locations[i];
|
||||
theobj->thesection.size = 0;
|
||||
theobj->thesection.offset = 0;
|
||||
theobj->thesection.align = 0;
|
||||
theobj->thesection.reloff = 0;
|
||||
theobj->thesection.nreloc = 0;
|
||||
theobj->thesection.flags = S_ZEROFILL | S_REGULAR | S_ATTR_SOME_INSTRUCTIONS;
|
||||
theobj->thesection.reserved1 = 0;
|
||||
theobj->thesection.reserved2 = 0;
|
||||
write(fd, theobj, sizeof(struct simple_object_file));
|
||||
printf(",-segaddr,SBCL%d,0x%x", i, space_start_locations[i]);
|
||||
free(theobj);
|
||||
}
|
||||
printf("\n");
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#ifndef PPC_DARWIN_SPACELIST_H
|
||||
#define PPC_DARWIN_SPACELIST_H
|
||||
|
||||
#if defined(LISP_FEATURE_GENCGC)
|
||||
#define N_SEGMENTS_TO_PRODUCE 4
|
||||
#else
|
||||
#define N_SEGMENTS_TO_PRODUCE 5
|
||||
#endif
|
||||
|
||||
unsigned int space_start_locations[N_SEGMENTS_TO_PRODUCE] =
|
||||
{ READ_ONLY_SPACE_START, STATIC_SPACE_START,
|
||||
#if defined(LISP_FEATURE_GENCGC)
|
||||
DYNAMIC_SPACE_START,
|
||||
#else
|
||||
DYNAMIC_0_SPACE_START, DYNAMIC_1_SPACE_START,
|
||||
#endif
|
||||
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,
|
||||
#if defined(LISP_FEATURE_GENCGC)
|
||||
DYNAMIC_SPACE_END - DYNAMIC_SPACE_START,
|
||||
#else
|
||||
DYNAMIC_0_SPACE_END - DYNAMIC_0_SPACE_START,
|
||||
DYNAMIC_1_SPACE_END - DYNAMIC_1_SPACE_START,
|
||||
#endif
|
||||
LINKAGE_TABLE_SPACE_END - LINKAGE_TABLE_SPACE_START};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
/* 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;
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/* x86-darwin-mkrospace.c - write a .o which makes sure we get our desired address range */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <mach-o/loader.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "sbcl.h"
|
||||
#include "runtime.h"
|
||||
|
||||
#include "x86-darwin-spacelist.h"
|
||||
|
||||
struct simple_object_file
|
||||
{
|
||||
struct segment_command thesegment;
|
||||
struct section thesection;
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
struct mach_header *theheader;
|
||||
struct simple_object_file *theobj;
|
||||
int fd, i;
|
||||
|
||||
/* Produce the mach header */
|
||||
theheader = (struct mach_header*) malloc(sizeof(struct mach_header));
|
||||
theheader->magic = MH_MAGIC;
|
||||
theheader->cputype = CPU_TYPE_X86;
|
||||
theheader->cpusubtype = CPU_SUBTYPE_I386_ALL;
|
||||
theheader->filetype = MH_OBJECT;
|
||||
theheader->ncmds = N_SEGMENTS_TO_PRODUCE;
|
||||
theheader->sizeofcmds = N_SEGMENTS_TO_PRODUCE * (sizeof(struct segment_command) + sizeof(struct section));
|
||||
theheader->flags = MH_NOUNDEFS;
|
||||
printf("-Wl");
|
||||
fd = open("x86-darwin-rospace.o", O_WRONLY | O_CREAT, 0644);
|
||||
write(fd, theheader, sizeof(struct mach_header));
|
||||
|
||||
for (i = 0; i < N_SEGMENTS_TO_PRODUCE; i++) {
|
||||
theobj = (struct simple_object_file*) malloc(sizeof(struct simple_object_file));
|
||||
theobj->thesegment.cmd = LC_SEGMENT;
|
||||
theobj->thesegment.cmdsize = sizeof(struct segment_command) + sizeof(struct section);
|
||||
snprintf(theobj->thesegment.segname, 7, "SBCL%d", i);
|
||||
theobj->thesegment.fileoff = sizeof(struct mach_header) + i * (sizeof(struct segment_command) + sizeof(struct section));
|
||||
theobj->thesegment.vmaddr = space_start_locations[i];
|
||||
theobj->thesegment.vmsize = 0;
|
||||
theobj->thesegment.maxprot = VM_PROT_ALL;
|
||||
theobj->thesegment.initprot = VM_PROT_ALL;
|
||||
theobj->thesegment.nsects = 1;
|
||||
theobj->thesegment.flags = 0;
|
||||
snprintf(theobj->thesection.sectname, 7, "sect%d", i);
|
||||
snprintf(theobj->thesection.segname, 7, "SBCL%d", i);
|
||||
theobj->thesection.addr = space_start_locations[i];
|
||||
theobj->thesection.size = 0;
|
||||
theobj->thesection.offset = 0;
|
||||
theobj->thesection.align = 0;
|
||||
theobj->thesection.reloff = 0;
|
||||
theobj->thesection.nreloc = 0;
|
||||
theobj->thesection.flags = S_ZEROFILL | S_REGULAR | S_ATTR_SOME_INSTRUCTIONS;
|
||||
theobj->thesection.reserved1 = 0;
|
||||
theobj->thesection.reserved2 = 0;
|
||||
write(fd, theobj, sizeof(struct simple_object_file));
|
||||
printf(",-segaddr,SBCL%d,0x%x", i, space_start_locations[i]);
|
||||
free(theobj);
|
||||
}
|
||||
printf("\n");
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#ifndef PPC_DARWIN_SPACELIST_H
|
||||
#define PPC_DARWIN_SPACELIST_H
|
||||
|
||||
#if defined(LISP_FEATURE_GENCGC)
|
||||
#define N_SEGMENTS_TO_PRODUCE 4
|
||||
#else
|
||||
#define N_SEGMENTS_TO_PRODUCE 5
|
||||
#endif
|
||||
|
||||
unsigned int space_start_locations[N_SEGMENTS_TO_PRODUCE] =
|
||||
{ READ_ONLY_SPACE_START, STATIC_SPACE_START,
|
||||
#if defined(LISP_FEATURE_GENCGC)
|
||||
DYNAMIC_SPACE_START,
|
||||
#else
|
||||
DYNAMIC_0_SPACE_START, DYNAMIC_1_SPACE_START,
|
||||
#endif
|
||||
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,
|
||||
#if defined(LISP_FEATURE_GENCGC)
|
||||
DYNAMIC_SPACE_END - DYNAMIC_SPACE_START,
|
||||
#else
|
||||
DYNAMIC_0_SPACE_END - DYNAMIC_0_SPACE_START,
|
||||
DYNAMIC_1_SPACE_END - DYNAMIC_1_SPACE_START,
|
||||
#endif
|
||||
LINKAGE_TABLE_SPACE_END - LINKAGE_TABLE_SPACE_START};
|
||||
|
||||
#endif
|
||||
|
|
@ -17,4 +17,4 @@
|
|||
;;; checkins which aren't released. (And occasionally for internal
|
||||
;;; versions, especially for internal versions off the main CVS
|
||||
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
|
||||
"0.9.18.27"
|
||||
"0.9.18.28"
|
||||
|
|
|
|||
Loading…
Reference in a new issue