X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fppc-darwin-mkrospace.c;h=683808f7e61222735c3e36cc650e0c3357fde9d8;hb=7fb597b585fc715537ea644f7d84440eca217ca1;hp=610e9cf7223ee72db9b920eeff161ed106450f5c;hpb=e8d94e7c0f7efc78627e6347d4441f4176e8d160;p=sbcl.git diff --git a/src/runtime/ppc-darwin-mkrospace.c b/src/runtime/ppc-darwin-mkrospace.c index 610e9cf..683808f 100644 --- a/src/runtime/ppc-darwin-mkrospace.c +++ b/src/runtime/ppc-darwin-mkrospace.c @@ -7,53 +7,66 @@ #include #include #include +#include #include "sbcl.h" #include "runtime.h" +#include "ppc-darwin-spacelist.h" + struct simple_object_file { - struct mach_header theheader; struct segment_command thesegment; struct section thesection; }; int main(int argc, char** argv) { + struct mach_header *theheader; struct simple_object_file *theobj; - int fd; - theobj = (struct simple_object_file*) malloc(sizeof(struct simple_object_file)); - theobj->theheader.magic = MH_MAGIC; - theobj->theheader.cputype = CPU_TYPE_POWERPC; - theobj->theheader.cpusubtype = CPU_SUBTYPE_POWERPC_ALL; - theobj->theheader.filetype = MH_OBJECT; - theobj->theheader.ncmds = 1; - theobj->theheader.sizeofcmds = sizeof(struct segment_command) + sizeof(struct section); - theobj->theheader.flags = MH_NOUNDEFS; - theobj->thesegment.cmd = LC_SEGMENT; - theobj->thesegment.cmdsize = sizeof(struct segment_command) + sizeof(struct section); - memcpy(theobj->thesegment.segname, "", sizeof(char)); - theobj->thesegment.fileoff = sizeof(struct mach_header); - theobj->thesegment.vmaddr = READ_ONLY_SPACE_START; - theobj->thesegment.vmsize = READ_ONLY_SPACE_END - READ_ONLY_SPACE_START; - theobj->thesegment.maxprot = VM_PROT_ALL; - theobj->thesegment.initprot = VM_PROT_ALL; - theobj->thesegment.nsects = 1; - theobj->thesegment.flags = 0; - memcpy(theobj->thesection.sectname, "core", 5); - memcpy(theobj->thesection.segname, "SBCLRO", 7); - theobj->thesection.addr = READ_ONLY_SPACE_START; - theobj->thesection.size = READ_ONLY_SPACE_END - READ_ONLY_SPACE_START; - theobj->thesection.offset = sizeof(struct mach_header) + sizeof(struct segment_command) + sizeof(struct section); - 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; + 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, theobj, sizeof(struct simple_object_file)); + 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); - printf("-Wl,-segaddr,SBCLRO,0x%x\n",READ_ONLY_SPACE_START); return 0; }