]> Shamusworld >> Repos - rmac/blobdiff - sect.c
Version bump for last commit. :-)
[rmac] / sect.c
diff --git a/sect.c b/sect.c
index ebf80cfec02bf585886a89329dbe801022c533b9..12f9c89eae2f7eda973f63765816c21bb87f3c57 100644 (file)
--- a/sect.c
+++ b/sect.c
@@ -18,8 +18,8 @@
 #include "riscasm.h"
 #include "symbol.h"
 #include "token.h"
-#define DEF_KW
-#include "kwtab.h"
+#define DEF_REGRISC
+#include "riscregs.h"
 
 // Function prototypes
 void MakeSection(int, uint16_t);
@@ -462,6 +462,15 @@ int ResolveFixups(int sno)
                        if (evexpr(fup->expr, &eval, &eattr, &esym) != OK)
                                continue;
 
+                       if (esym)
+                               if (!(esym->sattr & DEFINED) && eval==0)
+                               {
+                                       // If our expression still has an undefined symbol at this stage, it's bad news.
+                                       // The linker is never going to resolve the expression, so that's an error.
+                                       error("cannot export complex expression with unresloved symbol '%s'", esym->sname);
+                                       continue;
+                               }
+
                        if ((CHECK_OPTS(OPT_PC_RELATIVE)) && (eattr & (DEFINED | REFERENCED | EQUATED)) == (DEFINED | REFERENCED))
                        {
                                error("relocation not allowed when o30 is enabled");
@@ -548,6 +557,9 @@ int ResolveFixups(int sno)
                                                // In this instruction the PC is located a DWORD away
                                                if (dw & FU_PCRELX)
                                                        eval += 2;
+                                               
+                                               if ((int64_t)eval > 0x7fff || (int64_t)eval < -32768)
+                                                       error(range_error);
                                        }
                                        else
                                        {
@@ -721,7 +733,7 @@ int ResolveFixups(int sno)
                        }
                        else if ((dw & FUMASKRISC) == FU_REGONE)
                        {
-                               eval -= KW_R0;
+                               eval -= REGRISC_R0;
                                if (eval > 31)
                                {
                                        error("register one value out of range");
@@ -735,7 +747,7 @@ int ResolveFixups(int sno)
                        }
                        else if ((dw & FUMASKRISC) == FU_REGTWO)
                        {
-                               eval -= KW_R0;
+                               eval -= REGRISC_R0;
                                if (eval > 31)
                                {
                                        error("register two value out of range");