[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cinvoke-svn] r110 - in trunk/cinvoke: lib/arch test
From: |
will |
Subject: |
[cinvoke-svn] r110 - in trunk/cinvoke: lib/arch test |
Date: |
22 Aug 2006 15:02:35 -0400 |
Author: will
Date: 2006-08-22 15:02:34 -0400 (Tue, 22 Aug 2006)
New Revision: 110
Modified:
trunk/cinvoke/lib/arch/gcc_sparc_unix.c
trunk/cinvoke/test/runtests.c
Log:
another test passes
Modified: trunk/cinvoke/lib/arch/gcc_sparc_unix.c
===================================================================
--- trunk/cinvoke/lib/arch/gcc_sparc_unix.c 2006-08-15 15:26:50 UTC (rev
109)
+++ trunk/cinvoke/lib/arch/gcc_sparc_unix.c 2006-08-22 19:02:34 UTC (rev
110)
@@ -78,117 +78,71 @@
return CINV_SUCCESS;
}
-/*
-const static int LEN = 4096;
-*/
-// XXX
-char *arch_callback_stub(void *functionp, void *param,
- short stacksize, cinv_callconv_t cc, cinv_type_t types[], int
numparams) {
-/* short functionphi = ((int)functionp >> 16);
- short functionplo = ((int)functionp & 0xFFFF);
- short paramhi = ((int)param >> 16);
- short paramlo = ((int)param & 0xFFFF);
- int needscopy = 0, i, numints = 0;
+const static int LEN = 8192;
- for (i = 0; i < numparams; i++) {
- if (isflt(types[i])) {
- if (types[i] == CINV_T_FLOAT)
- numints++;
- else
- numints += 2;
- } else {
- if (types[i] == CINV_T_EXTRALONG)
- numints += 2;
- else
- numints ++;
- }
+void copy_hi(void *dest, int val) {
+ int tmp;
+ memcpy(&tmp, dest, 4);
+ tmp &= 0xFFC00000;
+ tmp |= val;
+ memcpy(dest, &tmp, 4);
+}
+void copy_lo(void *dest, short val) {
+ short tmp;
+ memcpy(&tmp, dest, 2);
+ tmp &= 0xFC00;
+ tmp |= val;
+ memcpy(dest, &tmp, 2);
+}
- if (numints == 9 && types[i] == CINV_T_EXTRALONG) {
- needscopy = 1;
- break;
- }
- }
-
+char *arch_callback_stub(void *functionp, void *param,
+ short stacksize, cinv_callconv_t cc, cinv_type_t types[], int
numparams) {
+ int functionphi = ((int)functionp >> 10);
+ short functionplo = ((int)functionp & 0x3FF);
+ int paramhi = ((int)param >> 10);
+ short paramlo = ((int)param & 0x3FF);
+
char *ret = mmap(0, LEN, PROT_EXEC|PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0);
if (ret == MAP_FAILED)
return NULL;
+ //void f() {
+ // __asm__("mov %i0, %g5\n"
+ // "mov %i1, %o1\n"
+ // "mov %i2, %o2\n"
+ // "mov %i3, %o3\n"
+ // "mov %i4, %o4\n"
+ // "mov %i5, %o5\n"
+ // "sethi %hi(0xaaaab800), %g1\n"
+ // "or %g1, 0x3bb, %l0\n"
+ // "sethi %hi(0xccccdc00), %g1\n"
+ // "or %g1, 0x1dd, %o0\n"
+ // "call %l0\n"
+ // "nop\n"
+ // "nop\n");
+ //}
+ memcpy(ret,
+ "\x9d\xe3\xbf\x90\x8a\x10\x00\x18"
+ "\x92\x10\x00\x19\x94\x10\x00\x1a"
+ "\x96\x10\x00\x1b\x99\x10\x00\x1c"
+ "\x9a\x10\x00\x1d"
+ "\x03\x2a\xaa\xae\x9a\x10\x63\xbb"
+ "\x03\x33\x33\x37\x90\x10\x61\xdd"
+ "\x9f\xc3\x40\x00\x01\x00\x00\x00"
+ "\x01\x00\x00\x00\x81\xc7\xe0\x08"
+ "\x81\xe8\x00\x00",
+ 64);
+ copy_hi(ret + 28, functionphi);
+ copy_lo(ret + 34, functionplo);
+ copy_hi(ret + 36, paramhi);
+ copy_lo(ret + 42, paramlo);
- if (!needscopy) {
- //void f() {
- // __asm("mr r2, r3" ::: "r2");
- // ((void (*)(void *))0xAAAABBBB)((void *)0xCCCCDDDD);
- //}
- memcpy(ret,
- "\x7c\x08\x02\xa6\xbf\xc1\xff\xf8"
- "\x90\x01\x00\x08\x94\x21\xff\xb0"
- "\x7c\x3e\x0b\x78\x7c\x62\x1b\x78"
- "\x3c\x00\xaa\xaa\x60\x00\xbb\xbb"
- "\x3c\x60\xcc\xcc\x60\x63\xdd\xdd"
- "\x7c\x0c\x03\x78\x7d\x89\x03\xa6"
- "\x4e\x80\x04\x21\x80\x21\x00\x00"
- "\x80\x01\x00\x08\x7c\x08\x03\xa6"
- "\xbb\xc1\xff\xf8\x4e\x80\x00\x20",
- 72);
-
- memcpy(ret + 26, &functionphi, 2);
- memcpy(ret + 30, &functionplo, 2);
- memcpy(ret + 34, ¶mhi, 2);
- memcpy(ret + 38, ¶mlo, 2);
- } else {
- short offset = 80 + ARCH_STACK_SKIPTOP + (7 * 4);
- offset &= 0x7FF;
-
- //void f2() {
- // __asm("lwz r10 3822(r1)"); // 0xEEE
- // __asm("mr r2, r3" ::: "r2");
- // ((void (*)(void *))0xAAAABBBB)((void *)0xCCCCDDDD);
- //}
- memcpy(ret,
- "\x7c\x08\x02\xa6\xbf\xc1\xff\xf8"
- "\x90\x01\x00\x08\x94\x21\xff\xb0"
- "\x7c\x3e\x0b\x78\x91\x41\x0e\xee"
- "\x7c\x62\x1b\x78\x3c\x00\xaa\xaa"
- "\x60\x00\xbb\xbb\x3c\x60\xcc\xcc"
- "\x60\x63\xdd\xdd\x7c\x0c\x03\x78"
- "\x7d\x89\x03\xa6\x4e\x80\x04\x21"
- "\x80\x21\x00\x00\x80\x01\x00\x08"
- "\x7c\x08\x03\xa6\xbb\xc1\xff\xf8"
- "\x4e\x80\x00\x20",
- 76);
-
- memcpy(ret + 22, &offset, 2);
- memcpy(ret + 30, &functionphi, 2);
- memcpy(ret + 34, &functionplo, 2);
- memcpy(ret + 38, ¶mhi, 2);
- memcpy(ret + 42, ¶mlo, 2);
- }
-
- // the following block is a ppc oddity which is neccessary due to
- // the instruction cache and data cache not being linked. in
- // order to modify and execute code on ppc we have to flush it out
- // of the data cache, then invalidate the instruction cache. this
- // will ensure that when the code is executed it is running our fresh
- // copy from memory. Much praise to H D Moore for pointing this out @
- // http://www.uninformed.org/?v=1&a=1&t=pdf.
- int *c = (int *)ret;
- for (i = 0; i < 76; i++) {
- __asm("lwz r2, %0" :: "m" (c) : "r2");
- __asm("dcbf 0, r2");
- __asm("sync");
- __asm("icbi 0, r2");
- __asm("isync");
- c++;
- }
-
-
- return ret; */
- return NULL;
+ return ret;
}
-// XXX
+
void arch_free_stub(char *stub) {
-/* munmap(stub, LEN);*/
+ munmap(stub, LEN);
}
int arch_is_register_parm(cinv_callconv_t callingconvention, int index,
Modified: trunk/cinvoke/test/runtests.c
===================================================================
--- trunk/cinvoke/test/runtests.c 2006-08-15 15:26:50 UTC (rev 109)
+++ trunk/cinvoke/test/runtests.c 2006-08-22 19:02:34 UTC (rev 110)
@@ -436,7 +436,7 @@
UPDATE(test6, "e", "iefdc");
UPDATE0(test7);
UPDATE0(test8);
- SKIP_UPDATE(test9, "", "p");
+ UPDATE(test9, "", "p");
UPDATE(test10, "f", "isclliils");
SKIP_UPDATE(test11, "", "p");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cinvoke-svn] r110 - in trunk/cinvoke: lib/arch test,
will <=