[project @ 2004-10-02 07:32:25 by dons]
[ghc-hetmet.git] / ghc / rts / Linker.c
index 891cf13..d263363 100644 (file)
@@ -414,6 +414,7 @@ typedef struct _RtsSymbolVal {
       SymX(gcdIntegerIntzh_fast)               \
       SymX(gcdIntzh_fast)                      \
       SymX(genSymZh)                           \
+      SymX(genericRaise)                       \
       SymX(getProgArgv)                                \
       SymX(getStablePtr)                       \
       SymX(initLinker)                         \
@@ -3372,7 +3373,12 @@ static int relocateSection(
                    // Step 1: Figure out what the relocated value should be
                    if(scat->r_type == GENERIC_RELOC_VANILLA)
                    {
-                       word = scat->r_value + sect->offset + ((long) image);
+                        word = *wordPtr + (unsigned long) relocateAddress(
+                                                                oc,
+                                                                nSections,
+                                                                sections,
+                                                                scat->r_value)
+                                        - scat->r_value;
                    }
                    else if(scat->r_type == PPC_RELOC_SECTDIFF
                        || scat->r_type == PPC_RELOC_LO16_SECTDIFF
@@ -3492,7 +3498,7 @@ static int relocateSection(
                else if(reloc->r_type == PPC_RELOC_BR24)
                {
                    word = *wordPtr;
-                   word = (word & 0x03FFFFFC) | (word & 0x02000000) ? 0xFC000000 : 0;
+                   word = (word & 0x03FFFFFC) | ((word & 0x02000000) ? 0xFC000000 : 0);
                }
 
 
@@ -3518,7 +3524,9 @@ static int relocateSection(
 
                    if(reloc->r_pcrel)
                     {  
-                        ASSERT(word == 0);
+                            // In the .o file, this should be a relative jump to NULL
+                            // and we'll change it to a jump to a relative jump to the symbol
+                        ASSERT(-word == reloc->r_address);
                         word = symbolAddress;
                         jumpIsland = makeJumpIsland(oc,reloc->r_symbolnum,word);
                        word -= ((long)image) + sect->offset + reloc->r_address;