changeset 470:bf32e35f1afa

fix_relocation for function table...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 02 Oct 2009 17:27:45 +0900
parents 96c941eae962
children 699ee087234e
files TaskManager/Test/test_render/spe/DrawSpan.cc
diffstat 1 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Test/test_render/spe/DrawSpan.cc	Fri Oct 02 17:14:16 2009 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpan.cc	Fri Oct 02 17:27:45 2009 +0900
@@ -395,6 +395,23 @@
     return ret;
 }
 
+void
+fix_relocation((void**)addr,int count)
+{
+    unsigned int pc;
+    unsigned int label;
+    __asm__ __volatile__(
+"         brsl %0,____LLLL\n"
+"____LLLL:"
+"         lia  %1,____LLLL"
+        : "=r" (pc), "=r" (label));
+    int offset = pc-label;
+    int i;
+    for(i=0;i<count;i++) {
+	addr[i] += offset;
+    }
+}
+
 static int
 run(SchedTask *smanager, void *rbuf, void *wbuf)
 {
@@ -409,9 +426,10 @@
     Span nop_span;
     nop_span.length_x = 1;
 
-    int (DrawSpan::*drawFunc1[2])(SchedTask *, Gptr, SpanPtr, int, int, int) = {
-        &DrawSpan::drawDot1, &DrawSpan::drawLine1
+    int (*drawFunc1[2])(SchedTask *, Gptr, SpanPtr, int, int, int) = {
+        &drawDot1, &drawLine1
     };
+    fix_relocation((void**)drawFunc1,2);
 
     uint32 display   = smanager->get_param(0);
     int screen_width = smanager->get_param(1);