ref: f1441cc962dc5602f2ed600dc7fb6cfa2caaf337
parent: 50804d661ab53a5a89c1750d3168eb4580cda8a4
author: ISSOtm <[email protected]>
date: Sat Oct 12 18:16:30 EDT 2019
Make linker script error messages more descriptive Provide file names when appropriate, print memory locations in hex
--- a/src/link/script.c
+++ b/src/link/script.c
@@ -167,7 +167,8 @@
int curchar = getc_unlocked(file);
if (curchar == EOF && ferror(file))
- err(1, "%s: Unexpected error reading linker script", __func__);
+ err(1, "%s(%u): Unexpected error in %s", linkerScriptName,
+ lineNo, __func__);
return curchar;
}
@@ -212,7 +213,8 @@
do {
curchar = readChar(linkerScript);
if (curchar == EOF || isNewline(curchar))
- errx(1, "Line %u: Unterminated string", lineNo);
+ errx(1, "%s(%u): Unterminated string",
+ linkerScriptName, lineNo);
else if (curchar == '"')
/* Quotes force a string termination */
curchar = '\0';
@@ -290,8 +292,8 @@
if (tryParseNumber(str, &token.attr.number))
token.type = TOKEN_NUMBER;
else
- errx(1, "Unknown token \"%s\" on linker script line %u",
- str, lineNo);
+ errx(1, "%s(%u): Unknown token \"%s\"",
+ linkerScriptName, lineNo, str);
}
free(str);
@@ -368,11 +370,11 @@
if (type != SECTTYPE_INVALID) {
if (curaddr[type][bankID] > endaddr(type) + 1)
- errx(1, "%s(%u): PC overflowed (%u > %u)",
+ errx(1, "%s(%u): PC overflowed ($%x > $%x)",
linkerScriptName, lineNo,
curaddr[type][bankID], endaddr(type));
if (curaddr[type][bankID] < startaddr[type])
- errx(1, "%s(%u): PC underflowed (%u < %u)",
+ errx(1, "%s(%u): PC underflowed ($%x < $%x)",
linkerScriptName, lineNo,
curaddr[type][bankID], startaddr[type]);
}