mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 10:42:07 +00:00
Make linker script error messages more descriptive
Provide file names when appropriate, print memory locations in hex
This commit is contained in:
@@ -167,7 +167,8 @@ static int readChar(FILE *file)
|
|||||||
int curchar = getc_unlocked(file);
|
int curchar = getc_unlocked(file);
|
||||||
|
|
||||||
if (curchar == EOF && ferror(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;
|
return curchar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +213,8 @@ static struct LinkerScriptToken const *nextToken(void)
|
|||||||
do {
|
do {
|
||||||
curchar = readChar(linkerScript);
|
curchar = readChar(linkerScript);
|
||||||
if (curchar == EOF || isNewline(curchar))
|
if (curchar == EOF || isNewline(curchar))
|
||||||
errx(1, "Line %u: Unterminated string", lineNo);
|
errx(1, "%s(%u): Unterminated string",
|
||||||
|
linkerScriptName, lineNo);
|
||||||
else if (curchar == '"')
|
else if (curchar == '"')
|
||||||
/* Quotes force a string termination */
|
/* Quotes force a string termination */
|
||||||
curchar = '\0';
|
curchar = '\0';
|
||||||
@@ -290,8 +292,8 @@ static struct LinkerScriptToken const *nextToken(void)
|
|||||||
if (tryParseNumber(str, &token.attr.number))
|
if (tryParseNumber(str, &token.attr.number))
|
||||||
token.type = TOKEN_NUMBER;
|
token.type = TOKEN_NUMBER;
|
||||||
else
|
else
|
||||||
errx(1, "Unknown token \"%s\" on linker script line %u",
|
errx(1, "%s(%u): Unknown token \"%s\"",
|
||||||
str, lineNo);
|
linkerScriptName, lineNo, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(str);
|
free(str);
|
||||||
@@ -368,11 +370,11 @@ struct SectionPlacement *script_NextSection(void)
|
|||||||
|
|
||||||
if (type != SECTTYPE_INVALID) {
|
if (type != SECTTYPE_INVALID) {
|
||||||
if (curaddr[type][bankID] > endaddr(type) + 1)
|
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,
|
linkerScriptName, lineNo,
|
||||||
curaddr[type][bankID], endaddr(type));
|
curaddr[type][bankID], endaddr(type));
|
||||||
if (curaddr[type][bankID] < startaddr[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,
|
linkerScriptName, lineNo,
|
||||||
curaddr[type][bankID], startaddr[type]);
|
curaddr[type][bankID], startaddr[type]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user