/[cmucl]/src/lisp/irix-asm-munge.c
ViewVC logotype

Contents of /src/lisp/irix-asm-munge.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Thu Sep 15 18:26:52 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.1: +70 -66 lines
File MIME type: text/plain
Indent all source files using GNU indent using the config in
.indent.pro.
1 /* This program takes an object file assumed to be the output of assembling
2 mips-assem.s and munges certain locations to have the right values, in
3 order to work around a bug (SGI may disagree) in SGI's assembler that
4 disallows .word, .byte, etc in .text sections in PIC code (but not in
5 non_shared).
6
7 Specifically, we stuck "break 11" where we need to munge afterwards, and
8 put global labels beforehand. "break 11" is 0x000B000D
9
10 mipsmungelra points to one break which should have been
11 .word type_ReturnPcHeader, so we replace it with that value as an int
12 undefined_tramp points 4 bytes before two breaks which should be replaced
13 by 0x0417FECC and 0x01000000 respectively (they were magic numbers in the
14 original code too)
15 function_end_breakpoint_guts points to a break that should have been
16 .word type_ReturnPcHeader, so replace it too.
17
18 The file is written in place.
19 */
20 #include <stdio.h>
21 #include <unistd.h>
22 #include <libelf.h>
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 #include <fcntl.h>
26 #include <assert.h>
27 #include <nlist.h>
28 #include "lisp.h"
29 #include "internals.h"
30
31 struct nlist nl[] = {
32 {"mipsmungelra", 0, 0},
33 {"undefined_tramp", 0, 0},
34 {"function_end_breakpoint_guts", 0, 0},
35 {NULL, 0, 0}
36 };
37
38 main(int argc, char **argv)
39 {
40 int fd;
41 Elf *elf;
42 Elf32_Ehdr *ehdr;
43 Elf_Scn *scn;
44 Elf_Data *data;
45 Elf32_Half ndx;
46 Elf32_Shdr *shdr;
47 unsigned int *textdata;
48
49 if (argc != 2)
50 exit(2);
51
52 assert(!nlist(argv[1], nl));
53 assert(nl[0].n_value && !(nl[0].n_value & 0x3));
54 assert(nl[1].n_value && !(nl[1].n_value & 0x3));
55 assert(nl[2].n_value && !(nl[2].n_value & 0x3));
56
57 if (elf_version(EV_CURRENT) == EV_NONE) {
58 fprintf(stderr, "ELF punted! Recompile %s\n", argv[0]);
59 exit(1);
60 }
61
62 fd = open(argv[1], O_RDWR);
63 if (fd < 0) {
64 perror("open");
65 exit(1);
66 }
67
68 elf = elf_begin(fd, ELF_C_RDWR, NULL);
69
70 ehdr = elf32_getehdr(elf);
71 assert(ehdr);
72 /* want SHT_PROGBITS section named .text */
73 ndx = ehdr->e_shstrndx;
74 scn = NULL;
75 while ((scn = elf_nextscn(elf, scn))) {
76 char *name = NULL;
77
78 if ((shdr = elf32_getshdr(scn)))
79 name = elf_strptr(elf, ndx, (size_t) shdr->sh_name);
80 if (!strcmp(name, ".text"))
81 break;
82 }
83
84 data = elf_getdata(scn, NULL);
85 assert(data && data->d_size && !data->d_off);
86 textdata = (unsigned int *) data->d_buf;
87
88 /* process */
89 assert(textdata[nl[0].n_value / 4] == 0x000B000D);
90 textdata[nl[0].n_value / 4] = type_ReturnPcHeader;
91
92 assert(textdata[nl[1].n_value / 4] == 0x000A000D);
93 assert(textdata[nl[1].n_value / 4 + 1] == 0x000B000D);
94 assert(textdata[nl[1].n_value / 4 + 2] == 0x000B000D);
95 textdata[nl[1].n_value / 4 + 1] = 0x0417FECC;
96 textdata[nl[1].n_value / 4 + 2] = 0x01000000;
97
98 assert(textdata[nl[2].n_value / 4] == 0x000B000D);
99 textdata[nl[2].n_value / 4] = type_ReturnPcHeader;
100
101 elf_flagdata(data, ELF_C_SET, ELF_F_DIRTY);
102 elf_update(elf, ELF_C_WRITE);
103 elf_end(elf);
104 }

  ViewVC Help
Powered by ViewVC 1.1.5