X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=sect.c;h=781a81bda516c5e5fdbf7f0f06351a8a3e63f69e;hp=f24c8c13312193eda4b81c4e9698322118d38099;hb=HEAD;hpb=22203fdc3bec792b0cd2df838eda54d571af7449 diff --git a/sect.c b/sect.c index f24c8c1..12f9c89 100644 --- a/sect.c +++ b/sect.c @@ -18,7 +18,8 @@ #include "riscasm.h" #include "symbol.h" #include "token.h" - +#define DEF_REGRISC +#include "riscregs.h" // Function prototypes void MakeSection(int, uint16_t); @@ -461,9 +462,18 @@ 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 o10 is enabled"); + error("relocation not allowed when o30 is enabled"); continue; } } @@ -475,7 +485,7 @@ int ResolveFixups(int sno) if ((CHECK_OPTS(OPT_PC_RELATIVE)) && (eattr & (DEFINED | REFERENCED | EQUATED)) == (DEFINED | REFERENCED)) { - error("relocation not allowed when o10 is enabled"); + error("relocation not allowed when o30 is enabled"); continue; } @@ -547,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 { @@ -589,7 +602,7 @@ int ResolveFixups(int sno) *locp = 0x71; if (optim_warn_flag) - warn("bra.s with zero offset converted to NOP"); + warn("o6: bra.s with zero offset converted to NOP"); continue; } @@ -720,6 +733,7 @@ int ResolveFixups(int sno) } else if ((dw & FUMASKRISC) == FU_REGONE) { + eval -= REGRISC_R0; if (eval > 31) { error("register one value out of range"); @@ -733,6 +747,7 @@ int ResolveFixups(int sno) } else if ((dw & FUMASKRISC) == FU_REGTWO) { + eval -= REGRISC_R0; if (eval > 31) { error("register two value out of range");