]> Shamusworld >> Repos - rmac/commitdiff
Fix for #209 - forbid exporting expressions with unresolved symbols v2.2.12
authorggn <ggn@atari.org>
Mon, 17 Oct 2022 16:49:32 +0000 (19:49 +0300)
committerShamus Hammons <jlhamm@acm.org>
Wed, 21 Dec 2022 22:49:40 +0000 (16:49 -0600)
expr.c
rmac.h
sect.c

diff --git a/expr.c b/expr.c
index 5a9155c67832c1ee049d899415a0c924b40b4a07..30629dfae18cb1f0d8d993d2d52632874a340bba 100644 (file)
--- a/expr.c
+++ b/expr.c
@@ -585,7 +585,7 @@ be converted from a linked list into an array).
 //
 // Evaluate expression.
 // If the expression involves only ONE external symbol, the expression is
-// UNDEFINED, but it's value includes everything but the symbol value, and
+// UNDEFINED, but its value includes everything but the symbol value, and
 // 'a_esym' is set to the external symbol.
 //
 int evexpr(TOKEN * _tk, uint64_t * a_value, WORD * a_attr, SYM ** a_esym)
diff --git a/rmac.h b/rmac.h
index 3f8675c6599216b313261fec1799b548f3979790..f8c9f4c55118808b4a8bbb7b50f32389c6037dbc 100644 (file)
--- a/rmac.h
+++ b/rmac.h
@@ -262,6 +262,7 @@ PTR
 #define SIZP         0x0080            // .p (FPU pakced decimal real)
 #define SIZQ         0x0100            // .q (quad word)
 
+// Extended attributes
 #define EQUATEDREG   0x0008            // Equated register symbol
 #define UNDEF_EQUR   0x0010
 #define EQUATEDCC    0x0020
diff --git a/sect.c b/sect.c
index 20e6fcb4a32016685d68116e5024272eddcba10a..834df9d9b5d1d58f60e56ac2e030a598a50979d0 100644 (file)
--- a/sect.c
+++ b/sect.c
@@ -462,6 +462,15 @@ int ResolveFixups(int sno)
                        if (evexpr(fup->expr, &eval, &eattr, &esym) != OK)
                                continue;
 
+                       if (esym)
+                               if (!(esym->sattr & DEFINED))
+                               {
+                                       // 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");