/[cmucl]/src/lisp/darwin-lispadjuster.c
ViewVC logotype

Contents of /src/lisp/darwin-lispadjuster.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Thu Sep 15 18:26:51 2005 UTC (8 years, 7 months ago) by rtoy
Branch: MAIN
CVS Tags: sparc-tramp-assem-base, double-double-array-base, post-merge-intl-branch, merged-unicode-utf16-extfmt-2009-06-11, double-double-init-sparc-2, unicode-utf16-extfmt-2009-03-27, double-double-base, snapshot-2007-09, snapshot-2007-08, snapshot-2008-08, snapshot-2008-09, sse2-packed-2008-11-12, snapshot-2008-05, snapshot-2008-06, snapshot-2008-07, snapshot-2007-05, snapshot-2008-01, snapshot-2008-02, snapshot-2008-03, intl-branch-working-2010-02-19-1000, snapshot-2006-11, snapshot-2006-10, double-double-init-sparc, snapshot-2006-12, unicode-string-buffer-impl-base, sse2-base, release-20b-pre1, release-20b-pre2, unicode-string-buffer-base, sse2-packed-base, sparc-tramp-assem-2010-07-19, amd64-dd-start, release-19f-pre1, snapshot-2008-12, snapshot-2008-11, intl-2-branch-base, snapshot-2007-01, snapshot-2007-02, release-19e, release-19d, GIT-CONVERSION, double-double-init-ppc, release-19c, unicode-utf16-sync-2008-12, release-19c-base, cross-sol-x86-merged, label-2009-03-16, release-19f-base, merge-sse2-packed, merge-with-19f, intl-branch-working-2010-02-11-1000, unicode-snapshot-2009-05, unicode-snapshot-2009-06, double-double-init-%make-sparc, unicode-utf16-sync-2008-07, unicode-utf16-sync-2008-09, unicode-utf16-extfmts-sync-2008-12, RELEASE_20b, snapshot-2008-04, unicode-utf16-sync-label-2009-03-16, RELEASE_19f, snapshot-2007-03, release-20a-base, cross-sol-x86-base, unicode-utf16-char-support-2009-03-26, unicode-utf16-char-support-2009-03-25, unicode-utf16-extfmts-pre-sync-2008-11, snapshot-2008-10, snapshot-2007-04, snapshot-2010-12, snapshot-2010-11, unicode-utf16-sync-2008-11, snapshot-2007-07, snapshot-2011-09, snapshot-2011-06, snapshot-2011-07, snapshot-2011-04, snapshot-2007-06, snapshot-2011-02, snapshot-2011-03, snapshot-2011-01, pre-merge-intl-branch, double-double-array-checkpoint, double-double-reader-checkpoint-1, release-19d-base, release-19e-pre1, double-double-irrat-end, release-19e-pre2, snapshot-2010-05, snapshot-2010-04, snapshot-2010-07, snapshot-2010-06, snapshot-2010-01, snapshot-2010-03, snapshot-2010-02, release-19d-pre2, release-19d-pre1, snapshot-2010-08, double-double-init-checkpoint-1, double-double-reader-base, label-2009-03-25, cross-sol-x86-2010-12-20, double-double-init-x86, sse2-checkpoint-2008-10-01, intl-branch-2010-03-18-1300, snapshot-2005-11, double-double-sparc-checkpoint-1, sse2-merge-with-2008-11, sse2-merge-with-2008-10, snapshot-2005-10, RELEASE_20a, snapshot-2005-12, release-20a-pre1, snapshot-2009-11, snapshot-2009-12, unicode-utf16-extfmt-2009-06-11, portable-clx-import-2009-06-16, unicode-utf16-string-support, release-19c-pre1, cross-sparc-branch-base, release-19e-base, intl-branch-base, double-double-irrat-start, unicode-utf16-base, portable-clx-base, snapshot-2009-08, snapshot-2007-12, snapshot-2007-10, snapshot-2007-11, snapshot-2009-02, snapshot-2009-01, snapshot-2009-07, snapshot-2009-05, snapshot-2009-04, snapshot-2006-02, snapshot-2006-03, snapshot-2006-01, snapshot-2006-06, snapshot-2006-07, snapshot-2006-04, snapshot-2006-05, pre-telent-clx, snapshot-2006-08, snapshot-2006-09, HEAD
Branch point for: double-double-reader-branch, double-double-array-branch, RELEASE-19F-BRANCH, portable-clx-branch, cross-sparc-branch, RELEASE-20B-BRANCH, unicode-string-buffer-branch, sparc-tramp-assem-branch, release-19d-branch, sse2-packed-branch, RELEASE-20A-BRANCH, amd64-dd-branch, double-double-branch, unicode-string-buffer-impl-branch, intl-branch, unicode-utf16-branch, cross-sol-x86-branch, release-19e-branch, sse2-branch, release-19c-branch, intl-2-branch, unicode-utf16-extfmt-branch
Changes since 1.2: +68 -55 lines
File MIME type: text/plain
Indent all source files using GNU indent using the config in
.indent.pro.
1 /* Modify the final lisp binary to enlarge the generated CMUCLRO segment */
2 #include <stdlib.h>
3 #include <string.h>
4 #include <mach-o/loader.h>
5 #include <sys/types.h>
6 #include <sys/uio.h>
7 #include <unistd.h>
8 #include <fcntl.h>
9 #include <stdio.h>
10 #include "validate.h"
11
12 #ifdef DEBUG
13 #define dprintf printf
14 #else
15 #define dprintf(...)
16 #endif
17
18 int
19 main(int argc, char **argv)
20 {
21 char *filename;
22 int fd;
23 int i, result;
24 off_t curpos;
25 struct mach_header theheader;
26 struct segment_command thesegment;
27 char segname[17];
28
29 if (argc != 2)
30 return 1;
31 filename = argv[1];
32
33 fd = open(filename, O_RDWR, 0755);
34 read(fd, &theheader, sizeof(theheader));
35
36 if ((theheader.magic != MH_MAGIC) || (theheader.filetype != MH_EXECUTE))
37 return 2;
38
39 dprintf("Reading %d commands:\n", theheader.ncmds);
40
41 for (i = 0; i < theheader.ncmds; i++) {
42 curpos = lseek(fd, 0, SEEK_CUR);
43 dprintf("Reading command %d (%d bytes):\n", i,
44
45 sizeof(struct load_command));
46 read(fd, &thesegment, sizeof(struct load_command));
47
48 dprintf("Command is %d, length %d\n", thesegment.cmd,
49 thesegment.cmdsize);
50 if (thesegment.cmd != LC_SEGMENT) {
51 dprintf("Skipping remainder of command...\n");
52 lseek(fd, thesegment.cmdsize - sizeof(struct load_command),
53
54 SEEK_CUR);
55 continue;
56 }
57
58 dprintf("Reading remainder of Segment command (%d bytes)",
59 sizeof(thesegment) - sizeof(struct load_command));
60 read(fd, &thesegment.segname,
61
62 sizeof(thesegment) - sizeof(struct load_command));
63 memset(segname, 0, 17);
64 memcpy(segname, thesegment.segname, 16);
65 dprintf("Segname: %s\n", segname);
66 if (0 == strncmp(thesegment.segname, "CMUCLRO", 7)) {
67 dprintf("Frobbing the segment, setting vmsize from %8X to %8X\n",
68 thesegment.vmsize, READ_ONLY_SPACE_SIZE);
69 thesegment.vmsize = READ_ONLY_SPACE_SIZE;
70 dprintf("Skipping back to %lld.\n", curpos);
71 lseek(fd, curpos, SEEK_SET);
72 dprintf("Writing %d bytes.\n", sizeof(thesegment));
73 result = write(fd, &thesegment, sizeof(thesegment));
74 if (result == -1)
75 perror("Error:");
76 close(fd);
77 return 0;
78 } else {
79 dprintf("Cmdsize = %d, Already read = %d, Now seeking %d\n",
80 thesegment.cmdsize, sizeof(thesegment),
81 thesegment.cmdsize - sizeof(thesegment));
82 lseek(fd, thesegment.cmdsize - sizeof(thesegment), SEEK_CUR);
83 }
84 }
85 close(fd);
86 return 3;
87 }

  ViewVC Help
Powered by ViewVC 1.1.5