Robustly disallow overwriting builtin symbols (#817)

This commit is contained in:
Jakub Kądziołka
2021-03-31 15:03:57 +02:00
committed by GitHub
parent 61a9bfd33c
commit 937c9888a4
7 changed files with 119 additions and 7 deletions

View File

@@ -379,6 +379,7 @@ static struct Symbol *createNonrelocSymbol(char const *symbolName, bool numeric)
error("'%s' already defined at ", symbolName);
dumpFilename(symbol);
putc('\n', stderr);
return NULL; // Don't allow overriding the symbol, that'd be bad!
} else if (!numeric) {
// The symbol has already been referenced, but it's not allowed
error("'%s' already referenced at ", symbolName);
@@ -439,6 +440,10 @@ struct Symbol *sym_RedefString(char const *symName, char const *value)
error("'%s' already defined as non-EQUS at ", symName);
dumpFilename(sym);
putc('\n', stderr);
return NULL;
} else if (sym->isBuiltin) {
error("Built-in symbol '%s' cannot be redefined\n", symName);
return NULL;
}
/*