diff --git a/src/link/patch.c b/src/link/patch.c index d9f56cea..aeab74b2 100644 --- a/src/link/patch.c +++ b/src/link/patch.c @@ -337,7 +337,11 @@ static int32_t computeRPNExpr(struct Patch const *patch, 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) diff --git a/test/link/sym-noexist.asm b/test/link/sym-noexist.asm new file mode 100644 index 00000000..f6232128 --- /dev/null +++ b/test/link/sym-noexist.asm @@ -0,0 +1,3 @@ +SECTION "Test", ROM0 + jp where + dw nothing diff --git a/test/link/sym-noexist.out b/test/link/sym-noexist.out new file mode 100644 index 00000000..035c6e3a --- /dev/null +++ b/test/link/sym-noexist.out @@ -0,0 +1,3 @@ +error: sym-noexist.asm(3): Unknown symbol "nothing" +error: sym-noexist.asm(2): Unknown symbol "where" +Linking failed with 2 errors