[uCsimm] 32-bit PIC patches for the uCsimm !

From: Erwin Authried (eauth@softsys.co.at)
Date: Wed Jan 05 2000 - 16:14:28 EST


I've played with the gcc's machine description, and I think
that I have found a solution to break the 16-bit limit on the
text segment. In the m68k machine description for m68k-pic-coff, three lines
have to be modified. A fixed register (a4) is used to load the
distance to the symbol before each function call.
The a4 register is added in CALL_USED_REGISTER because
it is clobbered during each call to a function.
I have tried to compile a few programs with the patched
compiler, and it seems to work fine. To get >64k binaries,
the libraries must be recompiled, I haven't had the time to
try this. The data segment is handled in the same way as
before, thus data+bss still can't exceed 64k. The 64k limitiation
on the text segment must be removed from the linker script (uC-linux-pic.ld).
I'm looking forward to suggestions for improvements.

-Erwin

A short example program shows how the adressing works:

--------------------------------------------------------
extern int some_func();
extern int some_var;

foo()
{
  bar(some_func,&some_var);
}
--------------------------------------------------------
#m68k-pic-coff-gcc -S -O2 foo.c
        .file "foo.c"
gcc2_compiled.:
__gnu_compiled_c:
.text
        .even
.globl foo
foo:
        link.w %a6,#0
        pea some_var(%a5)
        lea some_func-.-8,%a0
        lea 0(%pc,%a0),%a0
        move.l %a0,-(%sp)
        lea bar-.-8,%a4
        jsr 0(%pc,%a4)
        unlk %a6
        rts
--------------------------------------------------------

diff -u1 m68k.md.orig m68k.md
--- m68k.md.orig Wed Jan 5 13:25:34 2000
+++ m68k.md Wed Jan 5 21:20:53 2000
@@ -810,3 +810,4 @@
   "TARGET_PCREL"
- "lea %a1(%%pc),%0")
+;; 32-bit offset for text seg. load
+ "lea %a1-.-8,%0\;lea 0(%%pc,%0),%0")
 
@@ -5993,3 +5994,3 @@
     else
- return \"bsr.w %0\";
+ return \"lea %0-.-8,%%a4\;jsr 0(%%pc,%%a4)\";
   }
@@ -6066,3 +6067,3 @@
     else
- return \"bsr.w %1\";
+ return \"lea %1-.-8,%%a4\;jsr 0(%%pc,%%a4)\";
   }

diff -u1 m68kpic.h.orig m68kpic.h
--- m68kpic.h.orig Wed Jan 5 18:38:03 2000
+++ m68kpic.h Wed Jan 5 18:38:36 2000
@@ -37,2 +37,3 @@
 
+/* a4 is declared as used register */
 #undef CALL_USED_REGISTERS
@@ -40,3 +41,3 @@
  {1, 1, 0, 0, 0, 0, 0, 0, \
- 1, 1, 0, 0, 0, 1, 0, 1, \
+ 1, 1, 0, 0, 1, 1, 0, 1, \
   1, 1, 0, 0, 0, 0, 0, 0 }

This message resent by the ucsimm@uclinux.com list server http://www.uClinux.com/



This archive was generated by hypermail 2b30 : Sun Apr 07 2002 - 00:01:33 EST