ref: 023a3c037f102fcaa5e037b762c33d3537a67472
parent: 828edb7403c05eb4837b36e256584dec400af55e
author: ISSOtm <[email protected]>
date: Sun Apr 12 18:52:32 EDT 2020
Properly handle missing symbols Fixes #512
--- a/src/link/patch.c
+++ b/src/link/patch.c
@@ -337,7 +337,11 @@
symbol = getSymbol(fileSymbols, value);
- if (strcmp(symbol->name, "@")) {
+ if (!symbol) {
+ error("%s: Unknown symbol \"%s\"",
+ patch->fileName,
+ fileSymbols[value]->name);
+ } else if (strcmp(symbol->name, "@")) {
value = symbol->value;
/* Symbols attached to sections have offsets */
if (symbol->section)
--- /dev/null
+++ b/test/link/sym-noexist.asm
@@ -1,0 +1,3 @@
+SECTION "Test", ROM0
+ jp where
+ dw nothing
--- /dev/null
+++ b/test/link/sym-noexist.out
@@ -1,0 +1,3 @@
+error: sym-noexist.asm(3): Unknown symbol "nothing"
+error: sym-noexist.asm(2): Unknown symbol "where"
+Linking failed with 2 errors