[patch] adjust libgloss addresses for 64-bit

Eric Christopher erchrist@cisco.com
Thu Apr 14 22:08:00 GMT 2005

Here's another shot at this. The problem that we encounter is that for
64-bit addresses "la" (or dla for that matter) does not sign extend the
constant passed in the case of:

la $2,0x80000000

leaving us with a zero-extended value in a register which is
unpredictable as far as the standard (and at least one chip out there)
is concerned. One option would be to modify the assembler to
automatically sign-extend when in the presence of constants that are
smaller than a single register.

Not a bad idea, but we should also just be precise in what we pass as
well. Since gas will accept sign extended constants from la when we're
using a 64-bit pointers we can probably get by with this patch as well.
The issue of whether or not to automagically sign extend when we load
addresses is a separate one I think really in this case.



2005-04-12  Eric Christopher  <echristo@redhat.com>

        * mips/regs.S: For __mips64 sign-extend K0BASE. Clean
	up K1BASE_ADDR handling.

Index: mips/regs.S
RCS file: /cvs/src/src/libgloss/mips/regs.S,v
retrieving revision 1.3
diff -u -p -r1.3 regs.S
--- mips/regs.S 3 Apr 2004 01:02:51 -0000       1.3
+++ mips/regs.S 14 Apr 2005 22:04:32 -0000
@@ -53,15 +53,16 @@
 #define fp1    $f1

 /* Useful memory constants: */
-#define K0BASE         0x80000000
 #ifndef __mips64
+#define K0BASE          0x80000000
 #define K1BASE         0xA0000000
 #define K0BASE_ADDR    ((char *)K0BASE)
 #define K1BASE_ADDR    ((char *)K1BASE)
-#define K1BASE         0xFFFFFFFFA0000000LL
+#define K0BASE          0xFFFFFFFF80000000
+#define K1BASE         0xFFFFFFFFA0000000
 #define K0BASE_ADDR    ((char *)0xFFFFFFFF80000000LL)
-#define K1BASE_ADDR    ((char *)K1BASE)
+#define K1BASE_ADDR    ((char *)0xFFFFFFFFA0000000LL)

 #define PHYS_TO_K1(a)   ((unsigned)(a) | K1BASE)

More information about the Newlib mailing list