Преглед изворни кода

adapted to 64-bit

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7796 8c9fc860-2736-0410-a75d-ab315db34111
eth.guenter пре 7 година
родитељ
комит
524cc31747
2 измењених фајлова са 22 додато и 7 уклоњено
  1. 7 2
      UnixAos/boot/Makefile
  2. 15 5
      UnixAos/boot/OberonLoader.c

+ 7 - 2
UnixAos/boot/Makefile

@@ -1,3 +1,8 @@
 
-OberonLoader:	OberonLoader.c
-	gcc -m32 OberonLoader.c -ldl -lc -o OberonLoader
+all:	OberonLoader.32 OberonLoader.64
+
+OberonLoader.32:	OberonLoader.c
+	gcc -m32 OberonLoader.c -ldl -lc -o OberonLoader.32
+
+OberonLoader.64:	OberonLoader.c
+	gcc -m64 OberonLoader.c -ldl -lc -o OberonLoader.64

+ 15 - 5
UnixAos/boot/OberonLoader.c

@@ -6,6 +6,9 @@
    Compile command:
       gcc -m32 -s -O OberonLoader.c -ldl -o OberonLoader
 
+      gcc -m64 -s -O OberonLoader.c -ldl -o OberonLoader
+
+
    The statically linked oberon binary 'oberon.bin' has to be
    appended to this loader by the following A2-command:
 
@@ -23,19 +26,18 @@
 #include <string.h>
 #include <dlfcn.h>
 
-#define Offset 10*1024	/* startpos of oberon.bin if it is appended to the loader binary */
+#define Offset 16*1024	/* startpos of the appended oberon binary */
 #define BlkSize 4*1024
 
 typedef void (*OberonProc)();
 typedef void *addr;
 typedef unsigned int uint;
 
-typedef struct {  /* cf. Generic.Unix.I386.Glue.Mod */
+typedef struct {  /* cf. Generic.Unix.*.Glue.Mod */
     /* Oberon --> loader: */
     char id[24];		/* must match coreID */
     int  codesize;	
-    int  relocations;		/* if base = 0 */
-    addr base;			/* must be 0 or match the address of buf */
+    int  relocations;
     OberonProc entry;		/* Glue.Init0 */
     /* loader --> Oberon: */
     addr *dlopenaddr;
@@ -47,7 +49,11 @@ typedef struct {  /* cf. Generic.Unix.I386.Glue.Mod */
     addr *cout;
 } *Header;
 
-char *coreID = "Oberon32G.binary";
+#if defined(__LP64__) || defined(_LP64)
+   char *coreID = "Oberon64G.binary";	/* cf. Generic.Unix.AMD64.Glue.Mod */
+#else
+   char *coreID = "Oberon32G.binary";	/* cf. Generic.Unix.I386.Glue.Mod */
+#endif
 
 addr buf;
 int fd;
@@ -75,7 +81,11 @@ void Relocate( uint relocations ) {
 
    for (i=0; i<relocations; i++) {
       a = buf + ReadInteger();
+#if defined(__LP64__) || defined(_LP64)
+      *a = buf+(ulong)(*a);
+#else
       *a = buf+(uint)(*a);
+#endif
    }
 }