ref: 4c5d5c708591fa878fcba297172da2d51579f908
parent: 4419f0d54f32eaf3e34b8b9154b71d832bdb903c
author: Jakub Kądziołka <kuba@kadziolka.net>
date: Mon Oct 12 09:28:00 EDT 2020
Don't consider difference of invalid labels constant If a label is defined outside of a section, avoid trying to obtain its value.
--- a/src/asm/rpn.c
+++ b/src/asm/rpn.c
@@ -307,7 +307,9 @@
if (!sym1 || !sym || sym1->type != SYM_LABEL || sym->type != SYM_LABEL)
return false;
- return sym_GetSection(sym1) == sym_GetSection(sym);
+ struct Section const *section1 = sym_GetSection(sym1);
+ struct Section const *section2 = sym_GetSection(sym);
+ return section1 && (section1 == section2);
}
static bool isDiffConstant(struct Expression const *src1,
--- /dev/null
+++ b/test/asm/use-label-outside-section.asm
@@ -1,0 +1,3 @@
+lab:
+ PRINTV lab-lab
+ PRINTT "\n"
--- /dev/null
+++ b/test/asm/use-label-outside-section.err
@@ -1,0 +1,5 @@
+ERROR: use-label-outside-section.asm(1):
+ Label "lab" created outside of a SECTION
+ERROR: use-label-outside-section.asm(2):
+ Expected constant expression: 'lab' is not constant at assembly time
+error: Assembly aborted (2 errors)!
--- /dev/null
+++ b/test/asm/use-label-outside-section.out
@@ -1,0 +1,1 @@
+$0